diff --git a/.github/workflows/beest-verification.yml b/.github/workflows/beest-verification.yml new file mode 100644 index 00000000000..b8b7e435e26 --- /dev/null +++ b/.github/workflows/beest-verification.yml @@ -0,0 +1,126 @@ +name: Beest verification + +on: + workflow_dispatch: + inputs: + suite: + description: Which beest agent suite to run (GitLab triggered x86 only) + type: choice + default: x86 + options: + - x86 + - arm + - both + agent_branch_under_test: + description: Agent branch beest should deploy (empty = the branch this workflow runs on) + type: string + default: "" + agent_hash_under_test: + description: Agent commit beest should pin the image to (empty = the commit this workflow runs on) + type: string + default: "" + scenarios: + description: Beest scenario selector (empty = whatever the beest workflow defaults to) + type: string + default: "" + no_destroy: + description: Keep the beest infrastructure after the run (for debugging a failure) + type: boolean + default: false + beest_ref: + description: Ref of StackVista/beest to dispatch + type: string + default: main + +permissions: {} + +concurrency: + group: beest-verification-${{ github.ref }} + cancel-in-progress: false + +jobs: + trigger: + name: Trigger beest agent verification + runs-on: ubuntu-24.04 + timeout-minutes: 10 + permissions: {} + steps: + - name: Mint GitHub App token (dispatch beest workflows) + id: app-token + uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0 + with: + client-id: ${{ vars.BEEST_GH_APP_CLIENT_ID }} + private-key: ${{ secrets.BEEST_GH_APP_PRIVATE_KEY }} + owner: StackVista + repositories: beest + permission-actions: write + + - name: Dispatch beest verification + env: + GH_TOKEN: ${{ steps.app-token.outputs.token }} + SUITE: ${{ inputs.suite }} + AGENT_BRANCH: ${{ inputs.agent_branch_under_test || github.ref_name }} + AGENT_BRANCH_INPUT: ${{ inputs.agent_branch_under_test }} + AGENT_HASH_INPUT: ${{ inputs.agent_hash_under_test }} + AGENT_SHA: ${{ github.sha }} + SCENARIOS: ${{ inputs.scenarios }} + NO_DESTROY: ${{ inputs.no_destroy }} + BEEST_REF: ${{ inputs.beest_ref }} + run: | + set -euo pipefail + + case "${SUITE}" in + x86) workflows=("agent-x86.yml") ;; + arm) workflows=("arm.yml") ;; + both) workflows=("agent-x86.yml" "arm.yml") ;; + *) echo "::error::unknown suite '${SUITE}'"; exit 1 ;; + esac + + # A branch builds many images, so pin the exact commit rather than letting + # beest pick the newest build. Default to this run's SHA, but only when the + # branch was not overridden -- against another branch our SHA means nothing, + # so leave it unset and let beest fall back. + agent_hash="${AGENT_HASH_INPUT}" + if [ -z "${agent_hash}" ] && [ -z "${AGENT_BRANCH_INPUT}" ]; then + agent_hash="${AGENT_SHA}" + fi + + echo "agent branch under test: ${AGENT_BRANCH}" + echo "agent commit under test: ${agent_hash:-(unpinned - beest chart default)}" + + { + echo "## Beest verification dispatched" + echo + echo "| field | value |" + echo "| --- | --- |" + echo "| agent branch under test | \`${AGENT_BRANCH}\` |" + echo "| agent commit under test | \`${agent_hash:-(unpinned - beest chart default)}\` |" + echo "| suite | \`${SUITE}\` |" + echo "| scenarios | \`${SCENARIOS:-(beest default)}\` |" + echo "| keep infrastructure | \`${NO_DESTROY}\` |" + echo "| beest ref | \`${BEEST_REF}\` |" + echo + } >> "${GITHUB_STEP_SUMMARY}" + + for wf in "${workflows[@]}"; do + args=(--repo StackVista/beest --ref "${BEEST_REF}") + args+=(--field "agent_branch_under_test=${AGENT_BRANCH}") + args+=(--field "no_destroy=${NO_DESTROY}") + if [ -n "${agent_hash}" ]; then + args+=(--field "hashes_under_test=agent=${agent_hash}") + fi + if [ -n "${SCENARIOS}" ]; then + args+=(--field "scenarios=${SCENARIOS}") + fi + + echo "dispatching ${wf}" + gh workflow run "${wf}" "${args[@]}" + + # gh does not report the queued run, and every beest AWS workflow shares + # one global lock, so look the run up rather than assuming it started. + sleep 10 + url="$(gh run list --repo StackVista/beest --workflow "${wf}" \ + --limit 1 --json url --jq '.[0].url' 2>/dev/null || true)" + fallback="https://github.com/StackVista/beest/actions/workflows/${wf}" + echo "- \`${wf}\` -> ${url:-${fallback}}" >> "${GITHUB_STEP_SUMMARY}" + done