forked from cowsql/raft
-
Notifications
You must be signed in to change notification settings - Fork 0
117 lines (112 loc) · 3.59 KB
/
benchmark.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
name: Benchmark
on:
workflow_dispatch:
inputs:
keep:
description: "Keep BMC server"
type: boolean
default: false
# schedule:
# - cron: '12 4 * * *'
jobs:
github:
name: On GitHub
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
repository: cowsql/cowsql-ci
- name: Run checks
env:
BENCHER_API_TOKEN: ${{ secrets.BENCHER_API_TOKEN }}
run: |
./bin/check --testbed github
bmc-deploy:
name: On BMC - deploy
runs-on: ubuntu-22.04
outputs:
id: ${{ steps.create.outputs.id }}
address: ${{ steps.wait.outputs.address}}
steps:
- name: Create
uses: phoenixnap-github-actions/create-server-bmc@v1
id: create
with:
clientid: ${{secrets.BMC_CLIENT_ID}}
clientsecret: ${{secrets.BMC_CLIENT_SECRET}}
hostname: "bmc"
image: "ubuntu/jammy"
location: "ASH"
type: "s1.c1.medium"
- name: Wait
id: wait
env:
ID: ${{ steps.create.outputs.id }}
AUTH_URL: https://auth.phoenixnap.com/auth/realms/BMC/protocol/openid-connect/token
API_URL: https://api.phoenixnap.com/bmc/v1/servers
CLIENT_ID: ${{secrets.BMC_CLIENT_ID}}
CLIENT_SECRET: ${{secrets.BMC_CLIENT_SECRET}}
run: |
for i in $(seq 30); do
DATA="client_id=${CLIENT_ID}&client_secret=${CLIENT_SECRET}&grant_type=client_credentials"
ACCESS_TOKEN=$(curl -s -X POST -d "${DATA}" ${AUTH_URL} | jq -r .access_token)
HEADER="Authorization: Bearer ${ACCESS_TOKEN}"
STATUS=$(curl -s -H "${HEADER}" ${API_URL}/${ID}/ | jq -r .status)
echo status: $STATUS
if [ "$STATUS" = "powered-on" ]; then
break
fi
sleep 60
done
if [ "$STATUS" != "powered-on" ]; then
echo "Server still not ready: $STATUS"
exit 1
fi
ADDR=$(curl -s -H "${HEADER}" ${API_URL}/${ID}/ | jq -r .publicIpAddresses[0])
echo "address=$ADDR" >> $GITHUB_OUTPUT
- name: Update kernel
env:
SSH: "ssh -o StrictHostKeyChecking=no -i ~/.ssh/bmc ubuntu@${{ steps.wait.outputs.address}}"
run: |
mkdir -p ~/.ssh/
echo "${{secrets.BMC_SSH_KEY}}" > ~/.ssh/bmc
chmod 600 ~/.ssh/bmc
$SSH sudo apt-get install -y git
$SSH git clone --depth 1 https://github.com/cowsql/cowsql-ci.git ci
$SSH /home/ubuntu/ci/bin/install-kernel
$SSH sudo reboot || true
sleep 30
for i in $(seq 60); do
$SSH true 2>/dev/null && break
sleep 5
done
$SSH true
bmc-run:
name: On BMC - run
runs-on: ubuntu-22.04
needs: bmc-deploy
env:
SSH: "ssh -o StrictHostKeyChecking=no -i ~/.ssh/bmc ubuntu@${{ needs.bmc-deploy.outputs.address}}"
steps:
- name: Setup SSH key
run: |
mkdir -p ~/.ssh/
echo "${{secrets.BMC_SSH_KEY}}" > ~/.ssh/bmc
chmod 600 ~/.ssh/bmc
- name: Run checks
env:
BENCHER_API_TOKEN: ${{ secrets.BENCHER_API_TOKEN }}
run: |
$SSH "BENCHER_API_TOKEN=$BENCHER_API_TOKEN /home/ubuntu/ci/bin/check --testbed bmc"
bmc-delete:
name: On BMC - delete
runs-on: ubuntu-22.04
if: always() && (inputs.keep == '' || inputs.keep == 'false')
needs: [bmc-deploy, bmc-run]
steps:
- name: Delete
uses: phoenixnap-github-actions/delete-server-bmc@v1
with:
clientid: ${{secrets.BMC_CLIENT_ID}}
clientsecret: ${{secrets.BMC_CLIENT_SECRET}}
serverid: ${{ needs.bmc-deploy.outputs.id}}