From 257bf6c0a48edbdb2db1de58f327b843ad68b72e Mon Sep 17 00:00:00 2001 From: Dana Doherty Date: Wed, 4 Sep 2024 14:24:32 +0100 Subject: [PATCH] (CAT-1820) - add resuable workflow job for rerunning acceptance tests --- .github/workflows/ci.yml | 21 +++++++++++++++++++-- .github/workflows/nightly.yml | 2 +- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e26434186..b02602ee9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,6 +10,7 @@ on: workflow_dispatch: env: + SOURCE_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} jobs: @@ -28,7 +29,7 @@ jobs: ruby_version: "3.2" name: "spec (ruby ${{ matrix.ruby_version }})" uses: "puppetlabs/cat-github-actions/.github/workflows/gem_ci.yml@main" - secrets: "inherit" + secrets: inherit with: rake_task: 'spec:coverage' ruby_version: ${{ matrix.ruby_version }} @@ -52,9 +53,25 @@ jobs: ruby_version: "3.2" name: "acceptance (ruby ${{ matrix.ruby_version }} | ${{ matrix.os }})" uses: "puppetlabs/cat-github-actions/.github/workflows/gem_acceptance.yml@main" - secrets: "inherit" + secrets: inherit with: ruby_version: ${{ matrix.ruby_version }} puppet_version: ${{ matrix.puppet_gem_version }} rake_task: 'acceptance:local' runs_on: ${{ matrix.os }} + + rerun: + needs: "acceptance" + # (2) continue ONLY IF "acceptance" fails + if: always() && needs.acceptance.result == 'failure' + + # (4) "use" the custom action to retrigger the failed "acceptance job" above + # NOTE: pass the SOURCE_GITHUB_TOKEN to the custom action because (a) it must have + # this to trigger the reusable workflow that restarts the failed job; and + # (b) custom actions do not have access to the calling workflow's secrets + name: "rerun" + uses: "puppetlabs/cat-github-actions/.github/workflows/workflow-restarter.yml@cat_1820" + secrets: inherit + with: + repo: ${{ github.repository }} + run_id: ${{ github.run_id }} diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 849422c75..8ac4ed167 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -68,7 +68,7 @@ jobs: # this to trigger the reusable workflow that restarts the failed job; and # (b) custom actions do not have access to the calling workflow's secrets - name: Trigger reusable workflow - uses: ./.github/actions/workflow-restarter-proxy + uses: "puppetlabs/cat-github-actions/.github/workflows/workflow-restarter.yml@cat_1820" env: SOURCE_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: