Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
add benchmark runner
Browse files Browse the repository at this point in the history
  • Loading branch information
J-HowHuang committed Apr 26, 2024
1 parent e00296f commit 94d43f0
Showing 1 changed file with 46 additions and 13 deletions.
59 changes: 46 additions & 13 deletions .github/workflows/benchmark_group_2.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
name: benchmark-group-2
on: [pull_request, push]
jobs:
start-server-runner:
start-runner:
name: Start self-hosted EC2 runner
runs-on: ubuntu-latest
outputs:
label: ${{ steps.start-ec2-runner.outputs.label }}
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
server-label: ${{ steps.start-server-ec2-runner.outputs.label }}
server-ec2-instance-id: ${{ steps.start-server-ec2-runner.outputs.ec2-instance-id }}
private-ip: ${{ steps.get-private-ip.outputs.private-ip }}
benchmark-label: ${{ steps.start-benchmark-ec2-runner.outputs.label }}
benchmark-ec2-instance-id: ${{ steps.start-benchmark-ec2-runner.outputs.ec2-instance-id }}
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.GROUP_2_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.GROUP_2_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ vars.AWS_REGION }}
- name: Start EC2 runner
id: start-ec2-runner
- name: Start Server EC2 runner
id: start-server-ec2-runner
uses: machulav/ec2-github-runner@v2
with:
mode: start
github-token: ${{ secrets.GROUP_2_GH_PERSONAL_ACCESS_TOKEN }}
ec2-image-id: ami-00ac4dc229afc39b1
ec2-instance-type: c5.xlarge
subnet-id: subnet-0f0b102aeba4b75f7
security-group-id: sg-01dbe69e3eaf89995
- name: Start Benchmark EC2 runner
id: start-benchmark-ec2-runner
uses: machulav/ec2-github-runner@v2
with:
mode: start
Expand All @@ -29,18 +41,18 @@ jobs:
id: get-private-ip
run: |
echo "private-ip=$(aws ec2 describe-instances \
--instance-id ${{ steps.start-ec2-runner.outputs.ec2-instance-id }} \
--instance-id ${{ steps.start-server-ec2-runner.outputs.ec2-instance-id }} \
--query 'Reservations[0].Instances[0].PrivateIpAddress' | tr -d '"')" \
>> $GITHUB_OUTPUT
run-server:
name: Start the ISTZIIO server
needs: start-server-runner # required to start the main job when the runner is ready
runs-on: ${{ needs.start-server-runner.outputs.label }} # run the job on the newly created runner
needs: start-runner # required to start the main job when the runner is ready
runs-on: ${{ needs.start-runner.outputs.server-label }} # run the job on the newly created runner
env:
SERVER_ROOT: ${{ github.workspace }}/server
AWS_ACCESS_KEY_ID: ${{ secrets.GROUP_2_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.GROUP_2_AWS_SECRET_ACCESS_KEY }}
SERVER_IP: ${{ needs.start-server-runner.outputs.private-ip }}
SERVER_IP: ${{ needs.start-runner.outputs.private-ip }}
steps:
- name: debug
run: echo $SERVER_IP
Expand All @@ -60,11 +72,25 @@ jobs:
cat ${{ github.workspace }}/logs/app_6379.log
- name: test server
run: echo $(curl -sSL $SERVER_IP:26379/s3/test1.txt)
run-benchmark:
name: Run Benchmark
needs:
- start-runner
- run-server
runs-on: ${{ needs.start-runner.outputs.label }} # run the job on the newly created runner
env:
SERVER_IP: ${{ needs.start-runner.outputs.private-ip }}
steps:
- name: Clone Server
uses: actions/checkout@v4
- name: Run Benchmark
run: cargo run
stop-runner:
name: Stop self-hosted EC2 runner
needs:
- start-server-runner # required to get output from the start-server-runner job
- start-runner # required to get output from the start-runner job
- run-server # required to wait when the main job is done
- run-benchmark
runs-on: ubuntu-latest
if: ${{ always() }} # required to stop the runner even if the error happened in the previous jobs
steps:
Expand All @@ -74,11 +100,18 @@ jobs:
aws-access-key-id: ${{ secrets.GROUP_2_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.GROUP_2_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ vars.AWS_REGION }}
- name: Stop EC2 runner
- name: Stop Server EC2 runner
uses: machulav/ec2-github-runner@v2
with:
mode: stop
github-token: ${{ secrets.GROUP_2_GH_PERSONAL_ACCESS_TOKEN }}
label: ${{ needs.start-runner.outputs.server-label }}
ec2-instance-id: ${{ needs.start-runner.outputs.server-ec2-instance-id }}
- name: Stop Benchmark EC2 runner
uses: machulav/ec2-github-runner@v2
with:
mode: stop
github-token: ${{ secrets.GROUP_2_GH_PERSONAL_ACCESS_TOKEN }}
label: ${{ needs.start-server-runner.outputs.label }}
ec2-instance-id: ${{ needs.start-server-runner.outputs.ec2-instance-id }}
label: ${{ needs.start-runner.outputs.benchmark-label }}
ec2-instance-id: ${{ needs.start-runner.outputs.benchmark-ec2-instance-id }}

0 comments on commit 94d43f0

Please sign in to comment.