From 61495d80aab35d30bf548f99c6f54db4dd97f539 Mon Sep 17 00:00:00 2001 From: Akuli Date: Thu, 20 Jan 2022 18:24:14 +0200 Subject: [PATCH] Automatically create an issue if the nightly stubtest run fails (#6978) Co-authored-by: Nikita Sobolev --- .github/workflows/stubtest.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/workflows/stubtest.yml b/.github/workflows/stubtest.yml index bca892f98..9429773fa 100644 --- a/.github/workflows/stubtest.yml +++ b/.github/workflows/stubtest.yml @@ -5,6 +5,7 @@ on: schedule: - cron: "0 0 * * *" +# Please keep the permissions minimal, as stubtest runs arbitrary code from pypi. permissions: contents: read @@ -57,3 +58,23 @@ jobs: run: sudo apt install -y $(python tests/get_apt_packages.py) - name: Run stubtest run: python tests/stubtest_third_party.py --num-shards 4 --shard-index ${{ matrix.shard-index }} + + # https://github.community/t/run-github-actions-job-only-if-previous-job-has-failed/174786/2 + create-issue-on-failure: + name: Create an issue if stubtest failed + runs-on: ubuntu-latest + needs: [stubtest-stdlib, stubtest-third-party] + if: ${{ github.repository == 'python/typeshed' && always() && (needs.stubtest-stdlib.result == 'failure' || needs.stubtest-third-party.result == 'failure') }} + permissions: + issues: write + steps: + - uses: actions/github-script@v3 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + await github.issues.create({ + owner: "python", + repo: "typeshed", + title: `Stubtest failed on ${new Date().toDateString()}`, + body: "Stubtest runs are listed here: https://github.com/python/typeshed/actions/workflows/stubtest.yml", + })