From e63d39f0ee4b633cee153da6a4150f030f4d73eb Mon Sep 17 00:00:00 2001 From: Vivek Miglani Date: Tue, 22 Oct 2024 10:03:37 -0700 Subject: [PATCH] Update Captum rerun workflow to operate directly on workflow completion (#1410) Summary: Pull Request resolved: https://github.com/pytorch/captum/pull/1410 The initial rerun workflow cannot be triggered successfully for PRs created from forks, since the GitHub auth token provided for PRs on forks doesn't provide write access. This switches to a workflow completion trigger, which should run from the main repo and have write access to rerun the workflow. Reviewed By: craymichael Differential Revision: D64760527 fbshipit-source-id: 50163f52007153696baddee45a17f0a7aeb08fb3 --- .github/workflows/retry.yml | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/.github/workflows/retry.yml b/.github/workflows/retry.yml index 8acb101f9..848918604 100644 --- a/.github/workflows/retry.yml +++ b/.github/workflows/retry.yml @@ -1,19 +1,26 @@ -name: Retry Test +name: Rerun tests if failed on: - workflow_dispatch: - inputs: - run_id: - required: true + workflow_run: + workflows: ["Unit-tests for Conda install", "Unit-tests for Pip install with mypy type checks", "Unit-tests for Pip install"] + types: ["completed"] + +permissions: + actions: write + jobs: - rerun-on-failure: - permissions: write-all + rerun-tests: runs-on: ubuntu-latest steps: - - name: rerun ${{ inputs.run_id }} + - name: Log workflow metadata + run: | + echo "ID: ${{ github.event.workflow_run.id }}" + echo "attempt: ${{ github.event.workflow_run.run_attempt }}" + echo "event: ${{ github.event.workflow_run.conclusion }}" + echo "event: ${{ github.event.workflow_run.event }}" + - name: Rerun Failed Workflows + if: github.event.workflow_run.conclusion == 'failure' && github.event.run_attempt <= 3 env: - GH_REPO: ${{ github.repository }} GH_TOKEN: ${{ github.token }} - GH_DEBUG: api + RUN_ID: ${{ github.event.workflow_run.id }} run: | - gh run watch ${{ inputs.run_id }} > /dev/null 2>&1 - gh run rerun ${{ inputs.run_id }} --failed + gh run rerun ${RUN_ID} --repo="${{ github.repository }}" --failed