-
Notifications
You must be signed in to change notification settings - Fork 10
312 lines (270 loc) · 13.5 KB
/
continuous-benchmarking-provisioning.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
name: Provision VM and setup self-hosted runner
on:
workflow_dispatch:
schedule:
- cron: "0 23 * * 0"
jobs:
setup-aws-vm:
runs-on: ubuntu-latest
env:
AWS_RUNNER_NAME: stellar-continuous-aws
steps:
- uses: actions/checkout@v4
- name: Configure AWS credentials using EASE lab account
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
aws-region: us-west-1
- name: Create SSH public key file
run: |
mkdir -p $HOME/.ssh
echo ${{ vars.SSH_PUBLIC_KEY }} > $HOME/.ssh/id_rsa.pub
cat $HOME/.ssh/id_rsa.pub
- name: Create AWS EC2 instance
run: |
aws ec2 run-instances \
--block-device-mappings 'DeviceName=/dev/sda1,Ebs={VolumeSize=16}' \
--image-id ami-036cafe742923b3d9 \
--instance-type t3a.small \
--key-name stellar-ssh-key \
--region us-west-1 \
--tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=${{ env.AWS_RUNNER_NAME }}}]'
id: create-vm
- name: Get public IP address
run: echo ip=$(aws ec2 describe-instances --filters "Name=tag:Name,Values=${{ env.AWS_RUNNER_NAME }}" --query "Reservations[*].Instances[*].PublicIpAddress" --output text) >> $GITHUB_OUTPUT
id: get-ip
- name: Create a registration token for self-hosted runners
run: |
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/vhive-serverless/STeLLAR/actions/runners/registration-token \
| echo token=$(jq -r .token) > $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ secrets.DEPLOY_SELF_HOSTED_RUNNER_TOKEN }}
id: get-registration-token
- name: Setup SSH key on current GitHub-hosted runner
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Setup self-hosted runner
env:
GH_TOKEN: ${{ secrets.DEPLOY_SELF_HOSTED_RUNNER_TOKEN }}
uses: nick-fields/retry@v2
with:
timeout_minutes: 30
max_attempts: 5
retry_wait_seconds: 10
command: |
# Exit if runner is already set up
RUNNER_STATUS=$(gh api -H "Accept: application/vnd.github+json" /repos/vhive-serverless/STeLLAR/actions/runners | grep 'aws')
echo "Runner Status: $RUNNER_STATUS"
if [ -n "$RUNNER_STATUS" ]; then
echo "Runner with label 'aws' is already set up and running."
exit 0
fi
# Connection status
CONNECTION_READY_STATUS=describe_instance=$(aws ec2 describe-instances --query 'Reservations[*].Instances[*].{Instance:InstanceId,State:State.Name,PublicIP:PublicIpAddress}' --output table)
echo "$CONNECTION_READY_STATUS"
# Connect via SSH to instance
ssh -o StrictHostKeyChecking=no ubuntu@${{ steps.get-ip.outputs.ip }} "
echo 'Installing STeLLAR dependencies'
curl -o stellar-setup.sh https://raw.githubusercontent.com/vhive-serverless/STeLLAR/main/scripts/setup.sh
chmod +x stellar-setup.sh
./stellar-setup.sh
echo 'Setup self-hosted runner'
mkdir actions-runner && cd actions-runner
curl -o actions-runner-linux-x64-2.315.0.tar.gz -L https://github.com/actions/runner/releases/download/v2.315.0/actions-runner-linux-x64-2.315.0.tar.gz
tar xzf ./actions-runner-linux-x64-2.315.0.tar.gz
./config.sh --url https://github.com/vhive-serverless/STeLLAR --token ${{ steps.get-registration-token.outputs.token }} --name ${{ env.AWS_RUNNER_NAME }} --labels aws
tmux new-session -d -s github-actions-runner 'bash ./run.sh'
"
setup-cloudflare-vm:
runs-on: ubuntu-latest
env:
CLOUDFLARE_RUNNER_NAME: stellar-continuous-cloudflare
steps:
- uses: actions/checkout@v4
- name: Configure AWS credentials using EASE lab account
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
aws-region: us-east-2
- name: Create SSH public key file
run: |
mkdir -p $HOME/.ssh
echo ${{ vars.SSH_PUBLIC_KEY }} > $HOME/.ssh/id_rsa.pub
cat $HOME/.ssh/id_rsa.pub
- name: Create AWS EC2 instance
run: |
aws ec2 run-instances \
--block-device-mappings 'DeviceName=/dev/sda1,Ebs={VolumeSize=16}' \
--image-id ami-0f30a9c3a48f3fa79 \
--instance-type t2.micro \
--key-name stellar-ssh-key \
--region us-east-2 \
--tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=${{ env.CLOUDFLARE_RUNNER_NAME }}}]'
id: create-vm
- name: Get public IP address
run: echo ip=$(aws ec2 describe-instances --filters "Name=tag:Name,Values=${{ env.CLOUDFLARE_RUNNER_NAME }}" --query "Reservations[*].Instances[*].PublicIpAddress" --output text) >> $GITHUB_OUTPUT
id: get-ip
- name: Create a registration token for self-hosted runners
run: |
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/vhive-serverless/STeLLAR/actions/runners/registration-token \
| echo token=$(jq -r .token) > $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ secrets.DEPLOY_SELF_HOSTED_RUNNER_TOKEN }}
id: get-registration-token
- name: Setup SSH key on current GitHub-hosted runner
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Setup self-hosted runner
env:
GH_TOKEN: ${{ secrets.DEPLOY_SELF_HOSTED_RUNNER_TOKEN }}
uses: nick-fields/retry@v2
with:
timeout_minutes: 30
max_attempts: 5
retry_wait_seconds: 10
command: |
# "Exit if runner is already set up"
RUNNER_STATUS=$(gh api -H "Accept: application/vnd.github+json" /repos/vhive-serverless/STeLLAR/actions/runners | grep 'cloudflare')
echo "Runner Status: $RUNNER_STATUS"
if [ -n "$RUNNER_STATUS" ]; then
echo "Runner with label 'cloudflare' is already set up and running"
exit 0
fi
# connection status
CONNECTION_READY_STATUS=describe_instance=$(aws ec2 describe-instances --query 'Reservations[*].Instances[*].{Instance:InstanceId,State:State.Name,,PublicIP:PublicIpAddress}' --output table)
echo "$CONNECTION_READY_STATUS"
# connect via SSH to instance
ssh -o StrictHostKeyChecking=no ubuntu@${{ steps.get-ip.outputs.ip }} "
echo 'Installing STeLLAR dependencies'
curl -o stellar-setup.sh https://raw.githubusercontent.com/vhive-serverless/STeLLAR/main/scripts/setup.sh
chmod +x stellar-setup.sh
./stellar-setup.sh
curl -o cloudflare-setup.sh https://raw.githubusercontent.com/vhive-serverless/STeLLAR/main/scripts/cloudflare/setup.sh
chmod +x cloudflare-setup.sh
./cloudflare-setup.sh
echo 'Setup self-hosted runner'
mkdir actions-runner && cd actions-runner
curl -o actions-runner-linux-x64-2.315.0.tar.gz -L https://github.com/actions/runner/releases/download/v2.315.0/actions-runner-linux-x64-2.315.0.tar.gz
tar xzf ./actions-runner-linux-x64-2.315.0.tar.gz
./config.sh --url https://github.com/vhive-serverless/STeLLAR --token ${{ steps.get-registration-token.outputs.token }} --name ${{ env.CLOUDFLARE_RUNNER_NAME }} --labels cloudflare
tmux new-session -d -s github-actions-runner 'bash ./run.sh'
"
setup-azure-vm:
runs-on: ubuntu-latest
permissions: write-all
steps:
- uses: actions/checkout@v4
- name: Setup Azure CLI
uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Create Azure resource group
run: az group create --name github-actions-runners --location westus
- name: Create SSH public key file
run: |
mkdir -p $HOME/.ssh
echo ${{ vars.SSH_PUBLIC_KEY }} > $HOME/.ssh/id_rsa.pub
cat $HOME/.ssh/id_rsa.pub
- name: Create Azure SSH Key resource
run: |
az sshkey create \
--resource-group github-actions-runners \
--name stellar-ssh-key \
--location westus \
--public-key @$HOME/.ssh/id_rsa.pub
- name: Create Azure VM
run: |
az vm create \
--name github-actions-runner \
--resource-group github-actions-runners \
--image Ubuntu2204 \
--public-ip-sku Standard \
--size Standard_B1ms \
--ssh-key-name stellar-ssh-key
id: create-vm
- name: Get public IP address
run: echo ip=$(az vm show --show-details --resource-group github-actions-runners --name github-actions-runner --query publicIps --output tsv) >> $GITHUB_OUTPUT
id: get-ip
- name: Create a registration token for self-hosted runners
run: |
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/vhive-serverless/STeLLAR/actions/runners/registration-token \
| echo token=$(jq -r .token) > $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ secrets.DEPLOY_SELF_HOSTED_RUNNER_TOKEN }}
id: get-registration-token
- name: Setup SSH key on current GitHub-hosted runner
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Setup self-hosted runner
run: |
ssh -o StrictHostKeyChecking=no runner@${{ steps.get-ip.outputs.ip }} "
echo 'Installing STeLLAR dependencies'
curl -o stellar-setup.sh https://raw.githubusercontent.com/vhive-serverless/STeLLAR/main/scripts/setup.sh
chmod +x stellar-setup.sh
./stellar-setup.sh
echo 'Setup self-hosted runner'
mkdir actions-runner && cd actions-runner
curl -o actions-runner-linux-x64-2.315.0.tar.gz -L https://github.com/actions/runner/releases/download/v2.315.0/actions-runner-linux-x64-2.315.0.tar.gz
tar xzf ./actions-runner-linux-x64-2.315.0.tar.gz
./config.sh --url https://github.com/vhive-serverless/STeLLAR --token ${{ steps.get-registration-token.outputs.token }} --name stellar-continuous-azure --labels azure
tmux new-session -d -s github-actions-runner 'bash ./run.sh'
"
setup-gcr-vm:
runs-on: ubuntu-latest
permissions: write-all
steps:
- uses: actions/checkout@v4
- id: auth
name: Configure GCR credentials
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.GCR_CREDENTIALS }}
- name: Set up gcloud
uses: google-github-actions/setup-gcloud@v1
with:
version: ">= 363.0.0"
- name: Create a registration token for self-hosted runners
run: |
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/vhive-serverless/STeLLAR/actions/runners/registration-token \
| echo token=$(jq -r .token) > $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ secrets.DEPLOY_SELF_HOSTED_RUNNER_TOKEN }}
id: get-registration-token
- name: Create GCloud Compute Engine VM
run: gcloud compute instances create github-actions-runner-gcr --zone=us-west1-a --image=stellar-continuous-gcr-disk --image-project=stellar-benchmarking --machine-type=e2-small
- name: Setup self-hosted runner
run: |
gcloud compute ssh --zone "us-west1-a" "User@github-actions-runner-gcr" --project "stellar-benchmarking" --command '
sudo rm -r ./actions-runner &&
echo "Installing STeLLAR dependencies" &&
curl -o stellar-setup.sh https://raw.githubusercontent.com/vhive-serverless/STeLLAR/main/scripts/setup.sh &&
chmod +x stellar-setup.sh &&
./stellar-setup.sh &&
echo "Setup self-hosted runner" &&
mkdir actions-runner && cd actions-runner &&
curl -o actions-runner-linux-x64-2.315.0.tar.gz -L https://github.com/actions/runner/releases/download/v2.315.0/actions-runner-linux-x64-2.315.0.tar.gz &&
tar xzf ./actions-runner-linux-x64-2.315.0.tar.gz &&
printf "\nstellar-continuous-gcr\ngcr\n" | ./config.sh --url https://github.com/vhive-serverless/STeLLAR --token ${{ steps.get-registration-token.outputs.token }} &&
tmux new-session -d -s github-actions-runner-gcr "bash ./run.sh"
'