Skip to content

Add 'triage/flaky-test' label and inform if PR CI run contained flaky tests #3

Add 'triage/flaky-test' label and inform if PR CI run contained flaky tests

Add 'triage/flaky-test' label and inform if PR CI run contained flaky tests #3

name: Add 'triage/flaky-test' label and inform if PR CI run contained flaky tests
on:
workflow_run:
workflows: ["Pull Request CI"]
types:
- completed
jobs:
handle-flaky-tests-in-pr-ci:
runs-on: ubuntu-latest
permissions:
pull-requests: write
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
PR_NUMBER: ${{ github.event.number }}
steps:
- name: 'Download "jobs-with-flaky-tests" artifact'
env:
WORKFLOW_ID: ${{ github.event.workflow_run.id }}
run: gh run download $WORKFLOW_ID -n jobs-with-flaky-tests
- name: 'Add "triage/flaky-test" label'
if: ${{ hashFiles('**/jobs-with-flaky-tests') != '' }}
run: |
gh pr edit "$PR_NUMBER" --add-label 'triage/flaky-test'
- name: 'Comment on PR about flaky tests'
if: ${{ hashFiles('**/jobs-with-flaky-tests') != '' }}
run: |
gh pr comment "$PR_NUMBER" --body "Following jobs contain at least one flaky test: $(cat jobs-with-flaky-tests)"