diff --git a/.github/workflows/stubtest.yml b/.github/workflows/stubtest.yml index 639eaf7a8973..fd7b0a7fbbf4 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 @@ -55,3 +56,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", + })