-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add direwolf automation (#2527)
* chore: add bash script for direwolf test run * chore: add direwolf github workflow * fix: syntax corrections
- Loading branch information
Showing
2 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: Run CLI Direwolf Tests | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
releaseChannel: | ||
type: choice | ||
description: Channel to run the Direwolf tests against | ||
required: true | ||
options: | ||
- stable | ||
- beta | ||
- alpha | ||
direwolfEnvironment: | ||
type: choice | ||
description: Direwolf environment | ||
required: false | ||
options: | ||
- production | ||
- staging | ||
default: staging | ||
|
||
workflow_call: | ||
inputs: | ||
releaseChannel: | ||
type: string | ||
description: Channel to run the Direwolf tests against | ||
required: true | ||
default: stable | ||
direwolfEnvironment: | ||
type: string | ||
description: Direwolf environment | ||
required: false | ||
default: staging | ||
|
||
jobs: | ||
run-direwolf-tests: | ||
name: Run Direwolf CLI tests | ||
runs-on: pub-hk-ubuntu-22.04-small | ||
timeout-minutes: 20 | ||
environment: direwolf | ||
steps: | ||
- name: set direwolf environment UUID | ||
run: | | ||
direwolf_UUID=${{ secrets.DIREWOLF_CLOUD_UUID_STAGING }} | ||
if [[ ${{ inputs.direwolfEnvironment }} == 'production' ]] | ||
then direwolf_UUID=${{ secrets.DIREWOLF_CLOUD_UUID_PRODUCTION }} | ||
fi | ||
echo "DIREWOLF_CLOUD_UUID=direwolf_UUID" >> $GITHUB_ENV | ||
- uses: actions/checkout@v3 | ||
- name: Install jq | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y awscli jq | ||
- name: run direwolf suite | ||
run: ./scripts/direwolf-test-run | ||
env: | ||
HEROKU_CLI_VERSION: ${{ inputs.releaseChannel }} | ||
DIREWOLF_TOKEN: ${{ secrets.DEV_TOOLING_DIREWOLF_TOKEN }} | ||
DIREWOLF_CLOUD_UUID: ${{ env.DIREWOLF_CLOUD_UUID }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
DIREWOLF_SUITE="cli" | ||
|
||
# default CLI version is stable | ||
HEROKU_CLI_VERSION=${HEROKU_CLI_VERSION:="stable"} | ||
|
||
DIREWOLF_URL="https://$DIREWOLF_TOKEN@direwolf-api.herokai.com" | ||
|
||
POST_BODY=$(jq --null-input \ | ||
--arg cloud "$DIREWOLF_CLOUD_UUID" \ | ||
--arg suite "$DIREWOLF_SUITE" \ | ||
--arg env "$HEROKU_CLI_VERSION" \ | ||
'{"cloud": { "id": $cloud }, "suite": { "label": $suite }, "env": { "HEROKU_CLI_VERSION": $env }}') | ||
|
||
echo "Enqueuing: $POST_BODY" | ||
|
||
RUN_INFO=$(curl -sf $DIREWOLF_URL/runs \ | ||
-H "Content-Type: application/json" \ | ||
-d "${POST_BODY}") | ||
|
||
RUN_ID=$(echo $RUN_INFO | jq -r '.id') | ||
RUN_URL="https://direwolf.herokai.com/dashboard?run=$RUN_ID" | ||
echo "Enqueued: $RUN_URL" | ||
|
||
echo -n "Running: ..." | ||
RUN_STATE="running" | ||
while [[ $RUN_STATE == "running" ]]; do | ||
echo -n "." | ||
RUN_INFO=$(curl -sf $DIREWOLF_URL/runs/$RUN_ID) | ||
RUN_STATE=$(echo $RUN_INFO | jq -r '.state') | ||
sleep 10 | ||
done | ||
echo " done" | ||
echo "Result: $RUN_STATE" | ||
echo "Details:" | ||
curl -sf $DIREWOLF_URL/runs/$RUN_ID/results | \ | ||
jq -r '.[] | .state + "\t\t" + .class + ": " + .label' | \ | ||
sort | ||
|
||
[[ $RUN_STATE == "passed" ]] || exit 1 |