Skip to content

Commit

Permalink
Use a queue to limit access to test infra
Browse files Browse the repository at this point in the history
  • Loading branch information
mkjpryor committed Nov 29, 2023
1 parent 53f7748 commit 6976105
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions .github/workflows/test-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ on:
branches:
- main

# Use the head ref for workflow concurrency, with cancellation
# This should mean that any previous workflows for a PR get cancelled when a new commit is pushed
concurrency:
group: ${{ github.head_ref }}
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true

jobs:
Expand All @@ -23,25 +25,29 @@ jobs:
- name: PR must be from a branch in the stackhpc/azimuth-capi-operator repo
run: exit ${{ github.event.pull_request.head.repo.full_name == 'stackhpc/azimuth-capi-operator' && '0' || '1' }}

# Use a job that does nothing but is protected by an environment as a guard
# This allows us to control access to test infrastructure
wait_for_approval:
needs: [fail_on_remote]
runs-on: ubuntu-latest
environment: ci-approval
steps:
- run: exit 0

publish_artifacts:
needs: [wait_for_approval]
needs: [fail_on_remote]
uses: ./.github/workflows/build-push-artifacts.yaml
with:
ref: ${{ github.event.pull_request.head.sha }}
secrets: inherit

run_azimuth_tests:
# We want jobs to wait in a queue for a slot to run, so as not to overload the test infra
# GitHub concurrency _almost_ does this, except the queue length is one :-(
# There is a feature request for what we need https://github.com/orgs/community/discussions/12835
# Until that is implemented, the only other viable option is a busy wait
wait_in_queue:
needs: [publish_artifacts]
runs-on: ubuntu-latest
steps:
- name: Wait for an available slot
uses: stackhpc/github-actions/workflow-concurrency@master
with:
max-concurrency: 1

run_azimuth_tests:
needs: [wait_in_queue]
runs-on: ubuntu-latest
steps:
# Check out the configuration repository
- name: Set up Azimuth environment
Expand Down

0 comments on commit 6976105

Please sign in to comment.