Now that default permissions are read-only, we must enable specific permissions for certain workflow jobs. This fixes every job except "update screenshots", which has unresolved permissions issues.
36 lines
1.2 KiB
YAML
36 lines
1.2 KiB
YAML
name: Deflake Tests
|
|
|
|
# Runs when the Selenum lab test or PR test workflows complete. This will run
|
|
# with full privileges, even if the other workflow doesn't. That allows us to
|
|
# trigger re-runs if we think the results might be flaky. A test run will be
|
|
# given up to 3 runs to succeed.
|
|
on:
|
|
workflow_run:
|
|
workflows:
|
|
- Selenium Lab Tests
|
|
- Build and Test
|
|
types: [completed]
|
|
|
|
jobs:
|
|
deflake:
|
|
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
# "Write" to Actions to enable rerun command.
|
|
actions: write
|
|
|
|
steps:
|
|
- name: Check run count and re-run workflow
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
gh api /repos/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }} > run.json
|
|
RUNS=$(jq -r .run_attempt < run.json)
|
|
if [[ "$RUNS" -lt 3 ]]; then
|
|
echo "$RUNS failed runs so far; re-running workflow."
|
|
gh run rerun ${{ github.event.workflow_run.id }} --failed -R ${{ github.repository }}
|
|
else
|
|
echo "$RUNS failed runs so far; not re-running workflow."
|
|
fi
|