-
Notifications
You must be signed in to change notification settings - Fork 20
75 lines (68 loc) · 3.13 KB
/
benchmark-machine.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
name: Benchmark machine
on:
workflow_dispatch:
inputs:
docker_tag:
description: The tag of docker image to pull
default: 'latest'
required: true
env:
INSTANCE_ID: ${{ secrets.BENCHMARK_INSTANCE_ID }}
BENCHMARK_SSH_USER: ${{ secrets.BENCHMARK_SSH_USER }}
BENCHMARK_SSH_KEY: ${{ secrets.BENCHMARK_SSH_KEY }}
jobs:
## run the benchmarking remotely
benchmark-machine:
runs-on: jumphost.azure
steps:
- name: Checkout codes on ${{ github.ref }}
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up AWS CLI
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
# TODO: maybe use GHA to start/stop remote instance
- name: Start remote instance
timeout-minutes: 10
id: start_instance
run: |
aws ec2 start-instances --instance-ids ${{ env.INSTANCE_ID }}
sleep 5
instance_status="aws ec2 describe-instance-status --instance-ids ${{ env.INSTANCE_ID }} --query 'InstanceStatuses[0].InstanceStatus.Status' --output text"
system_status="aws ec2 describe-instance-status --instance-ids ${{ env.INSTANCE_ID }} --query 'InstanceStatuses[0].SystemStatus.Status' --output text"
SECONDS=0
while : ; do
if [ "$(eval $instance_status)" = "ok" ] && [ "$(eval $system_status)" = "ok" ]; then
break
else
sleep 20
SECONDS=$((SECONDS + 20))
fi
done
echo "Remote instance reachable now after $SECONDS seconds"
remote_ip=`aws ec2 describe-instances --filters 'Name=instance-state-name,Values=running' 'Name=instance-id,Values=${{ env.INSTANCE_ID }}' --query 'Reservations[*].Instances[*].[PublicIpAddress]' --output text`
echo "Running instances ip address: $remote_ip"
echo "remote_ip=$remote_ip" >> $GITHUB_OUTPUT
# exit status should propagate through ssh
- name: Remotely benchmark machine
timeout-minutes: 10
run: |
echo "Running instances ip address: ${{ steps.start_instance.outputs.remote_ip }}"
cat << EOF > ./benchmark-server-key.pem
${{ env.BENCHMARK_SSH_KEY }}
EOF
chmod 600 ./benchmark-server-key.pem
ssh -x -o StrictHostKeychecking=no "${{ steps.start_instance.outputs.remote_ip }}" -l ${{ env.BENCHMARK_SSH_USER }} -i ./benchmark-server-key.pem \
docker pull litentry/litentry-parachain:${{ github.event.inputs.docker_tag }} && \
docker run --rm litentry/litentry-parachain:${{ github.event.inputs.docker_tag }} benchmark machine --allow-fail --chain=litmus-dev
- name: Stop remote instance
if: always()
run: |
aws ec2 stop-instances --instance-ids ${{ env.INSTANCE_ID }}
sleep 5
ret=`aws ec2 describe-instance-status --instance-ids ${{ env.INSTANCE_ID }} | jq '.InstanceStatuses[0].InstanceState.Name'`
echo "Remote instance running state: $ret"