Skip to content

Commit f62f875

Browse files
authored
P-876 add azure-cli (#2844)
* add azure-cli * update * update * azure --> aws * update * update
1 parent b40c7cd commit f62f875

File tree

2 files changed

+45
-23
lines changed

2 files changed

+45
-23
lines changed

.github/workflows/benchmark-machine.yml

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,27 @@ on:
99
required: true
1010

1111
env:
12-
INSTANCE_ID: ${{ secrets.BENCHMARK_INSTANCE_ID }} # remote AWS host to run benchmarking
12+
INSTANCE_ID: ${{ secrets.BENCHMARK_INSTANCE_ID }}
1313
BENCHMARK_SSH_USER: ${{ secrets.BENCHMARK_SSH_USER }}
14-
BENCHMARK_SSH_KEYPATH: ${{ secrets.BENCHMARK_SSH_KEYPATH }}
14+
BENCHMARK_SSH_KEY: ${{ secrets.BENCHMARK_SSH_KEY }}
1515

1616
jobs:
1717
## run the benchmarking remotely
1818
benchmark-machine:
19-
runs-on: jumphost
19+
runs-on: ubuntu-latest
2020
steps:
2121
- name: Checkout codes on ${{ github.ref }}
2222
uses: actions/checkout@v4
2323
with:
2424
fetch-depth: 0
2525

26-
# TODO: maybe use GHA to start/stop remote instance
26+
- name: Set up AWS CLI
27+
uses: aws-actions/configure-aws-credentials@v2
28+
with:
29+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
30+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
31+
aws-region: us-east-1
32+
2733
- name: Start remote instance
2834
timeout-minutes: 10
2935
id: start_instance
@@ -38,26 +44,30 @@ jobs:
3844
break
3945
else
4046
sleep 20
47+
SECONDS=$((SECONDS + 20))
4148
fi
4249
done
4350
echo "Remote instance reachable now after $SECONDS seconds"
44-
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`
45-
echo "Running instances ip address: $remote_ip"
51+
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)
52+
echo "Running instances IP address: $remote_ip"
4653
echo "remote_ip=$remote_ip" >> $GITHUB_OUTPUT
4754
48-
# exit status should propagate through ssh
4955
- name: Remotely benchmark machine
5056
timeout-minutes: 10
5157
run: |
52-
echo "Running instances ip address: ${{ steps.start_instance.outputs.remote_ip }}"
53-
ssh -x -o StrictHostKeychecking=no "${{ steps.start_instance.outputs.remote_ip }}" -l ${{ env.BENCHMARK_SSH_USER }} -i ${{ env.BENCHMARK_SSH_KEYPATH }} \
54-
docker pull litentry/litentry-parachain:${{ github.event.inputs.docker_tag }} && \
55-
docker run --rm litentry/litentry-parachain:${{ github.event.inputs.docker_tag }} benchmark machine --allow-fail --chain=litmus-dev
58+
echo "Running instance's IP address: ${{ steps.start_instance.outputs.remote_ip }}"
59+
cat << EOF > ./benchmark-server-key.pem
60+
${{ env.BENCHMARK_SSH_KEY }}
61+
EOF
62+
chmod 600 ./benchmark-server-key.pem
63+
ssh -o StrictHostKeyChecking=no -i ./benchmark-server-key.pem "${{ env.BENCHMARK_SSH_USER }}@${{ steps.start_instance.outputs.remote_ip }}" \
64+
"docker pull litentry/litentry-parachain:${{ github.event.inputs.docker_tag }} && \
65+
docker run --rm litentry/litentry-parachain:${{ github.event.inputs.docker_tag }} benchmark machine --allow-fail --chain=litmus-dev"
5666
5767
- name: Stop remote instance
5868
if: always()
5969
run: |
6070
aws ec2 stop-instances --instance-ids ${{ env.INSTANCE_ID }}
6171
sleep 5
62-
ret=`aws ec2 describe-instance-status --instance-ids ${{ env.INSTANCE_ID }} | jq '.InstanceStatuses[0].InstanceState.Name'`
72+
ret=$(aws ec2 describe-instance-status --instance-ids ${{ env.INSTANCE_ID }} --query 'InstanceStatuses[0].InstanceState.Name' --output text)
6373
echo "Remote instance running state: $ret"

.github/workflows/benchmark-runtime-weights.yml

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ on:
3030
required: true
3131

3232
env:
33-
INSTANCE_ID: ${{ secrets.BENCHMARK_INSTANCE_ID }} # remote AWS host to run benchmarking
33+
INSTANCE_ID: ${{ secrets.BENCHMARK_INSTANCE_ID }}
3434
BENCHMARK_SSH_USER: ${{ secrets.BENCHMARK_SSH_USER }}
35-
BENCHMARK_SSH_KEYPATH: ${{ secrets.BENCHMARK_SSH_KEYPATH }}
35+
BENCHMARK_SSH_KEY: ${{ secrets.BENCHMARK_SSH_KEY }}
3636
DOCKER_BUILDKIT: 1
3737

3838
jobs:
@@ -77,7 +77,7 @@ jobs:
7777
7878
## run the benchmarking remotely
7979
benchmark:
80-
runs-on: jumphost
80+
runs-on: ubuntu-latest
8181
needs: build-docker
8282
# see https://github.com/actions/runner/issues/491
8383
if: |
@@ -111,25 +111,33 @@ jobs:
111111
run: |
112112
docker pull litentry/litentry-parachain:runtime-benchmarks
113113
114+
- name: Set up AWS CLI
115+
uses: aws-actions/configure-aws-credentials@v2
116+
with:
117+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
118+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
119+
aws-region: us-east-1
120+
114121
# TODO: maybe use GHA to start/stop remote instance
115122
- name: Start remote instance
116123
timeout-minutes: 10
117124
id: start_instance
118125
run: |
119-
aws ec2 start-instances --region ap-southeast-1 --instance-ids ${{ env.INSTANCE_ID }}
126+
aws ec2 start-instances --instance-ids ${{ env.INSTANCE_ID }}
120127
sleep 5
121-
instance_status="aws ec2 describe-instance-status --region ap-southeast-1 --instance-ids ${{ env.INSTANCE_ID }} --query 'InstanceStatuses[0].InstanceStatus.Status' --output text"
122-
system_status="aws ec2 describe-instance-status --region ap-southeast-1 --instance-ids ${{ env.INSTANCE_ID }} --query 'InstanceStatuses[0].SystemStatus.Status' --output text"
128+
instance_status="aws ec2 describe-instance-status --instance-ids ${{ env.INSTANCE_ID }} --query 'InstanceStatuses[0].InstanceStatus.Status' --output text"
129+
system_status="aws ec2 describe-instance-status --instance-ids ${{ env.INSTANCE_ID }} --query 'InstanceStatuses[0].SystemStatus.Status' --output text"
123130
SECONDS=0
124131
while : ; do
125132
if [ "$(eval $instance_status)" = "ok" ] && [ "$(eval $system_status)" = "ok" ]; then
126133
break
127134
else
128135
sleep 20
136+
SECONDS=$((SECONDS + 20))
129137
fi
130138
done
131139
echo "Remote instance reachable now after $SECONDS seconds"
132-
remote_ip=`aws ec2 describe-instances --region ap-southeast-1 --filters 'Name=instance-state-name,Values=running' 'Name=instance-id,Values=${{ env.INSTANCE_ID }}' --query 'Reservations[*].Instances[*].[PublicIpAddress]' --output text`
140+
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`
133141
echo "Running instances ip address: $remote_ip"
134142
echo "remote_ip=$remote_ip" >> $GITHUB_OUTPUT
135143
@@ -144,20 +152,24 @@ jobs:
144152
if [ "$arg" = "*" ]; then
145153
arg="\\$arg";
146154
fi
155+
cat << EOF > ./benchmark-server-key.pem
156+
${{ env.BENCHMARK_SSH_KEY }}
157+
EOF
158+
chmod 600 ./benchmark-server-key.pem
147159
for c in $chain; do
148-
ssh -x -o StrictHostKeychecking=no ${{ secrets.BENCHMARK_INSTANCE_IP }} -l ${{ env.BENCHMARK_SSH_USER }} 'bash -s' < scripts/benchmark-weight-remote.sh "$c" "${GITHUB_REF#refs/heads/}" "$arg"
160+
ssh -x -i ./benchmark-server-key.pem -o StrictHostKeychecking=no "${{ steps.start_instance.outputs.remote_ip }}" -l ${{ env.BENCHMARK_SSH_USER }} 'bash -s' < scripts/benchmark-weight-remote.sh "$c" "${GITHUB_REF#refs/heads/}" "$arg"
149161
echo "copy generated weights files back ..."
150-
scp -o StrictHostKeychecking=no "${{ env.BENCHMARK_SSH_USER }}"@"${{ secrets.BENCHMARK_INSTANCE_IP }}":/tmp/litentry-parachain/runtime/$c/src/weights/*.rs runtime/$c/src/weights/
162+
scp -o StrictHostKeychecking=no -i ./benchmark-server-key.pem "${{ env.BENCHMARK_SSH_USER }}"@"${{ steps.start_instance.outputs.remote_ip }}":/tmp/litentry-parachain/runtime/$c/src/weights/*.rs runtime/$c/src/weights/
151163
done
152164
echo "======================"
153165
git status
154166
155167
- name: Stop remote instance
156168
if: always()
157169
run: |
158-
aws ec2 stop-instances --region ap-southeast-1 --instance-ids ${{ env.INSTANCE_ID }}
170+
aws ec2 stop-instances --instance-ids ${{ env.INSTANCE_ID }}
159171
sleep 5
160-
ret=`aws ec2 describe-instance-status --region ap-southeast-1 --instance-ids ${{ env.INSTANCE_ID }} | jq '.InstanceStatuses[0].InstanceState.Name'`
172+
ret=`aws ec2 describe-instance-status --instance-ids ${{ env.INSTANCE_ID }} | jq '.InstanceStatuses[0].InstanceState.Name'`
161173
echo "Remote instance running state: $ret"
162174
163175
- name: Create auto PR

0 commit comments

Comments
 (0)