Skip to content

Rerun Workflow with Known Errors #527

Rerun Workflow with Known Errors

Rerun Workflow with Known Errors #527

name: Rerun Workflow with Known Errors
on:
workflow_run:
workflows:
- Linux (Ubuntu 20.04, Python 3.11)
- Linux ARM64 (Ubuntu 20.04, Python 3.11)
- Linux Static CC (Ubuntu 22.04, Python 3.11, Clang)
- Linux RISC-V with Conan (Ubuntu 22.04, Python 3.10)
- Windows (VS 2019, Python 3.11)
- Windows Conditional Compilation (VS 2022, Python 3.11)
types:
- completed
pull_request:
paths:
- '.github/workflows/workflow_rerunner.yml'
- '.github/scripts/workflow_rerun/**'
permissions: read-all
jobs:
rerun:
name: Rerun Workflow
if: ${{ github.event.workflow_run.conclusion == 'failure' }} # Run only for the failed workflows
runs-on: aks-linux-2-cores-8gb
permissions:
actions: write
contents: read
statuses: read
checks: read
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
sparse-checkout: '.github/scripts/workflow_rerun'
- name: Install deps
run: pip3 install PyGithub==2.2.0 requests==2.31.0
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- name: Rerun
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
export PYTHONPATH=${{ github.workspace }}/.github/scripts/workflow_rerun:${{ github.workspace }}/.github/scripts:$PYTHONPATH
python3 ${{ github.workspace }}/.github/scripts/workflow_rerun/rerunner.py \
--run-id ${{ github.event.workflow_run.id }} \
--repository-name ${GITHUB_REPOSITORY}
- name: Rerun Retriggered (Ticket ${{ env.FOUND_ERROR_TICKET }})
if: ${{ env.PIPELINE_RETRIGGERED == 'true' }}
run: echo "Rerun retriggered for ${{ github.event.workflow_run.html_url }} with ticket ${{ env.FOUND_ERROR_TICKET }}"
rerunner_tests:
name: Rerunner Tests
if: ${{ github.event_name == 'pull_request' }}
runs-on: aks-linux-2-cores-8gb
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
sparse-checkout: '.github/scripts/workflow_rerun'
lfs: true
- name: Install deps
run: pip3 install PyGithub==2.2.0 requests==2.31.0
- name: Test Rerunner (Tests)
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
working-directory: ${{ github.workspace }}/.github/scripts/workflow_rerun
run: |
export PYTHONPATH=${{ github.workspace }}/.github/scripts/workflow_rerun:${{ github.workspace }}/.github/scripts:$PYTHONPATH
python3 -m unittest tests/*_test.py
- name: Test Rerunner (CLI)
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
working-directory: ${{ github.workspace }}/.github/scripts/workflow_rerun
run: |
export PYTHONPATH=${{ github.workspace }}/.github/scripts/workflow_rerun:${{ github.workspace }}/.github/scripts:$PYTHONPATH
# Need to get a run id with successful status for log analyzing
# cannot lock a run id as logs get deleted after some time
run_id=$(python3 -c "from github import Github, Auth; import os; github=Github(auth=Auth.Token(token=os.environ.get('GITHUB_TOKEN'))); repo = github.get_repo('${GITHUB_REPOSITORY}'); run_id = repo.get_workflow_runs(status='success')[0].id; print(run_id)")
python3 rerunner.py --repository-name ${GITHUB_REPOSITORY} --run-id $run_id --dry-run