Skip to content

Commit

Permalink
chore: add direwolf automation (#2527)
Browse files Browse the repository at this point in the history
* chore: add bash script for direwolf test run

* chore: add direwolf github workflow

* fix: syntax corrections
  • Loading branch information
k80bowman authored Nov 6, 2023
1 parent 44d28f3 commit fb60f05
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/direwolf.yml
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 }}
43 changes: 43 additions & 0 deletions scripts/direwolf-test-run
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

0 comments on commit fb60f05

Please sign in to comment.