Skip to content

Benchmark

Benchmark #265

Workflow file for this run

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}}