From 7c4e48d790b66e1925b32db0e78de8402f2ce953 Mon Sep 17 00:00:00 2001 From: Akuli Date: Thu, 20 Jan 2022 12:59:03 +0200 Subject: [PATCH 01/14] create issue if stubtest fails --- .github/workflows/stubtest.yml | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/.github/workflows/stubtest.yml b/.github/workflows/stubtest.yml index 639eaf7a8973..45c4cd89643b 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 @@ -54,4 +55,23 @@ jobs: - name: Install apt packages 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 }} + run: python -u tests/stubtest_third_party.py --num-shards 4 --shard-index ${{ matrix.shard-index }} 2>&1 | tee output.txt + - name: If stubtest failed, create an issue + if: ${{ failure() }} + permissions: + issues: write + uses: actions/github-script@v3 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + let forStub = "" + try { + forStub = "for " + /stubtest failed for (.*)/.exec(fs.readFileSync("output.txt", "utf-8"))[1] + } catch(e) { } + + await github.issues.create({ + owner: context.repo.owner, + repo: context.repo.repo, + title: `Stubtest failed ${forStub} on ${new Date().toDateString()}`, + body: "Stubtest runs are listed [here](https://github.com/python/typeshed/actions/workflows/stubtest.yml)." + }) From 7b66c6c0e89c217f8fa63d8a0b596bbbf4c7d617 Mon Sep 17 00:00:00 2001 From: Akuli Date: Thu, 20 Jan 2022 13:07:13 +0200 Subject: [PATCH 02/14] dis work? --- .github/workflows/stubtest.yml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/stubtest.yml b/.github/workflows/stubtest.yml index 45c4cd89643b..0b34e59228fa 100644 --- a/.github/workflows/stubtest.yml +++ b/.github/workflows/stubtest.yml @@ -60,18 +60,22 @@ jobs: if: ${{ failure() }} permissions: issues: write - uses: actions/github-script@v3 + + create-issue-on-failure: + name: Create an issue if stubtest failed + # https://github.community/t/run-github-actions-job-only-if-previous-job-has-failed/174786/2 + needs: [stubtest-stdlib, stubtest-third-party] + if: ${{ 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: | - let forStub = "" - try { - forStub = "for " + /stubtest failed for (.*)/.exec(fs.readFileSync("output.txt", "utf-8"))[1] - } catch(e) { } - await github.issues.create({ owner: context.repo.owner, repo: context.repo.repo, - title: `Stubtest failed ${forStub} on ${new Date().toDateString()}`, - body: "Stubtest runs are listed [here](https://github.com/python/typeshed/actions/workflows/stubtest.yml)." + title: `Stubtest failed on ${new Date().toDateString()}`, + body: `Stubtest runs are listed here: https://github.com/${context.repo.owner}/${context.repo.repo}/actions/workflows/stubtest.yml`, }) From 97877f4ffadef48b1e0f23e0dddfbcdb0946b6c1 Mon Sep 17 00:00:00 2001 From: Akuli Date: Thu, 20 Jan 2022 13:10:19 +0200 Subject: [PATCH 03/14] delete old thing --- .github/workflows/stubtest.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/stubtest.yml b/.github/workflows/stubtest.yml index 0b34e59228fa..b51e9a6744fd 100644 --- a/.github/workflows/stubtest.yml +++ b/.github/workflows/stubtest.yml @@ -56,10 +56,6 @@ jobs: run: sudo apt install -y $(python tests/get_apt_packages.py) - name: Run stubtest run: python -u tests/stubtest_third_party.py --num-shards 4 --shard-index ${{ matrix.shard-index }} 2>&1 | tee output.txt - - name: If stubtest failed, create an issue - if: ${{ failure() }} - permissions: - issues: write create-issue-on-failure: name: Create an issue if stubtest failed From 1943aac5994bf86a55459347bf7e3473bb68c928 Mon Sep 17 00:00:00 2001 From: Akuli Date: Thu, 20 Jan 2022 13:12:17 +0200 Subject: [PATCH 04/14] more fixening --- .github/workflows/stubtest.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/stubtest.yml b/.github/workflows/stubtest.yml index b51e9a6744fd..0d7c6d25ce9c 100644 --- a/.github/workflows/stubtest.yml +++ b/.github/workflows/stubtest.yml @@ -57,10 +57,12 @@ jobs: - name: Run stubtest run: python -u tests/stubtest_third_party.py --num-shards 4 --shard-index ${{ matrix.shard-index }} 2>&1 | tee output.txt + # 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 - # https://github.community/t/run-github-actions-job-only-if-previous-job-has-failed/174786/2 + runs-on: ubuntu-latest needs: [stubtest-stdlib, stubtest-third-party] + #if: ${{ always() && github.repository == 'python/typeshed' && (needs.stubtest-stdlib.result=='failure' || needs.stubtest-third-party.result=='failure') }} if: ${{ always() && (needs.stubtest-stdlib.result=='failure' || needs.stubtest-third-party.result=='failure') }} permissions: issues: write From 1fd6b3fca8e190ba71f7415db60475fcd4e89e30 Mon Sep 17 00:00:00 2001 From: Akuli Date: Thu, 20 Jan 2022 13:13:46 +0200 Subject: [PATCH 05/14] real if --- .github/workflows/stubtest.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/stubtest.yml b/.github/workflows/stubtest.yml index 0d7c6d25ce9c..2a3b8b7be95e 100644 --- a/.github/workflows/stubtest.yml +++ b/.github/workflows/stubtest.yml @@ -62,8 +62,7 @@ jobs: name: Create an issue if stubtest failed runs-on: ubuntu-latest needs: [stubtest-stdlib, stubtest-third-party] - #if: ${{ always() && github.repository == 'python/typeshed' && (needs.stubtest-stdlib.result=='failure' || needs.stubtest-third-party.result=='failure') }} - if: ${{ always() && (needs.stubtest-stdlib.result=='failure' || needs.stubtest-third-party.result=='failure') }} + if: ${{ always() && github.repository == 'python/typeshed' && (needs.stubtest-stdlib.result=='failure' || needs.stubtest-third-party.result=='failure') }} permissions: issues: write steps: From ae53fb69921b6001580c4a25bfac110baa248eb4 Mon Sep 17 00:00:00 2001 From: Akuli Date: Thu, 20 Jan 2022 13:14:00 +0200 Subject: [PATCH 06/14] TEMPORARY switch to Akuli/typeshed --- .github/workflows/stubtest.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/stubtest.yml b/.github/workflows/stubtest.yml index 2a3b8b7be95e..a48eefaf7b60 100644 --- a/.github/workflows/stubtest.yml +++ b/.github/workflows/stubtest.yml @@ -15,7 +15,7 @@ env: jobs: stubtest-stdlib: name: Check stdlib with stubtest - if: github.repository == 'python/typeshed' + if: github.repository == 'Akuli/typeshed' runs-on: ${{ matrix.os }} strategy: matrix: @@ -39,7 +39,7 @@ jobs: stubtest-third-party: name: Check third party stubs with stubtest - if: github.repository == 'python/typeshed' + if: github.repository == 'Akuli/typeshed' runs-on: ubuntu-latest strategy: matrix: @@ -62,7 +62,7 @@ jobs: name: Create an issue if stubtest failed runs-on: ubuntu-latest needs: [stubtest-stdlib, stubtest-third-party] - if: ${{ always() && github.repository == 'python/typeshed' && (needs.stubtest-stdlib.result=='failure' || needs.stubtest-third-party.result=='failure') }} + if: ${{ always() && github.repository == 'Akuli/typeshed' && (needs.stubtest-stdlib.result=='failure' || needs.stubtest-third-party.result=='failure') }} permissions: issues: write steps: From d3bb98b7935c4146e4c17e956c2120281a9a4b28 Mon Sep 17 00:00:00 2001 From: Akuli Date: Thu, 20 Jan 2022 13:23:20 +0200 Subject: [PATCH 07/14] revert unnecessary change --- .github/workflows/stubtest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stubtest.yml b/.github/workflows/stubtest.yml index a48eefaf7b60..48edfab2d785 100644 --- a/.github/workflows/stubtest.yml +++ b/.github/workflows/stubtest.yml @@ -55,7 +55,7 @@ jobs: - name: Install apt packages run: sudo apt install -y $(python tests/get_apt_packages.py) - name: Run stubtest - run: python -u tests/stubtest_third_party.py --num-shards 4 --shard-index ${{ matrix.shard-index }} 2>&1 | tee output.txt + 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: From 9b8be8c0d49bcbde254d4801a43c5e421a126998 Mon Sep 17 00:00:00 2001 From: Akuli Date: Thu, 20 Jan 2022 13:23:44 +0200 Subject: [PATCH 08/14] TEMPORARILY make everything pass --- .github/workflows/stubtest.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/stubtest.yml b/.github/workflows/stubtest.yml index 48edfab2d785..08c4fa3e878c 100644 --- a/.github/workflows/stubtest.yml +++ b/.github/workflows/stubtest.yml @@ -34,8 +34,8 @@ jobs: run: python -m pip install -U pip - name: Install dependencies run: pip install $(grep tomli== requirements-tests.txt) $(grep mypy== requirements-tests.txt) - - name: Run stubtest - run: python tests/stubtest_stdlib.py +# - name: Run stubtest +# run: python tests/stubtest_stdlib.py stubtest-third-party: name: Check third party stubs with stubtest @@ -54,8 +54,8 @@ jobs: run: pip install $(grep tomli== requirements-tests.txt) - name: Install apt packages 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 }} +# - 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: From aba7f6c08410304b390f17d5f5567c7d912418b3 Mon Sep 17 00:00:00 2001 From: Akuli Date: Thu, 20 Jan 2022 13:24:11 +0200 Subject: [PATCH 09/14] switch order? --- .github/workflows/stubtest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stubtest.yml b/.github/workflows/stubtest.yml index 08c4fa3e878c..66e00eb0ab1a 100644 --- a/.github/workflows/stubtest.yml +++ b/.github/workflows/stubtest.yml @@ -62,7 +62,7 @@ jobs: name: Create an issue if stubtest failed runs-on: ubuntu-latest needs: [stubtest-stdlib, stubtest-third-party] - if: ${{ always() && github.repository == 'Akuli/typeshed' && (needs.stubtest-stdlib.result=='failure' || needs.stubtest-third-party.result=='failure') }} + if: ${{ github.repository == 'Akuli/typeshed' && always() && (needs.stubtest-stdlib.result=='failure' || needs.stubtest-third-party.result=='failure') }} permissions: issues: write steps: From ed17be03be736fefd3efffe079399f6f850449e3 Mon Sep 17 00:00:00 2001 From: Akuli Date: Thu, 20 Jan 2022 13:28:17 +0200 Subject: [PATCH 10/14] Revert "TEMPORARILY make everything pass" This reverts commit 9b8be8c0d49bcbde254d4801a43c5e421a126998. --- .github/workflows/stubtest.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/stubtest.yml b/.github/workflows/stubtest.yml index 66e00eb0ab1a..48f2bb77c590 100644 --- a/.github/workflows/stubtest.yml +++ b/.github/workflows/stubtest.yml @@ -34,8 +34,8 @@ jobs: run: python -m pip install -U pip - name: Install dependencies run: pip install $(grep tomli== requirements-tests.txt) $(grep mypy== requirements-tests.txt) -# - name: Run stubtest -# run: python tests/stubtest_stdlib.py + - name: Run stubtest + run: python tests/stubtest_stdlib.py stubtest-third-party: name: Check third party stubs with stubtest @@ -54,8 +54,8 @@ jobs: run: pip install $(grep tomli== requirements-tests.txt) - name: Install apt packages 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 }} + - 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: From c9188ae83afa430ed3be91cd7bc32594826ee476 Mon Sep 17 00:00:00 2001 From: Akuli Date: Thu, 20 Jan 2022 13:39:42 +0200 Subject: [PATCH 11/14] Revert "TEMPORARY switch to Akuli/typeshed" This reverts commit ae53fb69921b6001580c4a25bfac110baa248eb4. --- .github/workflows/stubtest.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/stubtest.yml b/.github/workflows/stubtest.yml index 48f2bb77c590..24ba049f73c3 100644 --- a/.github/workflows/stubtest.yml +++ b/.github/workflows/stubtest.yml @@ -15,7 +15,7 @@ env: jobs: stubtest-stdlib: name: Check stdlib with stubtest - if: github.repository == 'Akuli/typeshed' + if: github.repository == 'python/typeshed' runs-on: ${{ matrix.os }} strategy: matrix: @@ -39,7 +39,7 @@ jobs: stubtest-third-party: name: Check third party stubs with stubtest - if: github.repository == 'Akuli/typeshed' + if: github.repository == 'python/typeshed' runs-on: ubuntu-latest strategy: matrix: @@ -62,7 +62,7 @@ jobs: name: Create an issue if stubtest failed runs-on: ubuntu-latest needs: [stubtest-stdlib, stubtest-third-party] - if: ${{ github.repository == 'Akuli/typeshed' && always() && (needs.stubtest-stdlib.result=='failure' || needs.stubtest-third-party.result=='failure') }} + if: ${{ github.repository == 'python/typeshed' && always() && (needs.stubtest-stdlib.result=='failure' || needs.stubtest-third-party.result=='failure') }} permissions: issues: write steps: From 35240cd17ab6002069c57919cc4f09a9b859c7f4 Mon Sep 17 00:00:00 2001 From: Akuli Date: Thu, 20 Jan 2022 18:02:20 +0200 Subject: [PATCH 12/14] Update .github/workflows/stubtest.yml Co-authored-by: Nikita Sobolev --- .github/workflows/stubtest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stubtest.yml b/.github/workflows/stubtest.yml index 24ba049f73c3..b7eb86f9a04c 100644 --- a/.github/workflows/stubtest.yml +++ b/.github/workflows/stubtest.yml @@ -62,7 +62,7 @@ jobs: 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') }} + if: ${{ github.repository == 'python/typeshed' && always() && (needs.stubtest-stdlib.result == 'failure' || needs.stubtest-third-party.result == 'failure') }} permissions: issues: write steps: From fe142c2577030931b66df739dc548bd4cc0f393f Mon Sep 17 00:00:00 2001 From: Akuli Date: Thu, 20 Jan 2022 18:04:40 +0200 Subject: [PATCH 13/14] hard coded --- .github/workflows/stubtest.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/stubtest.yml b/.github/workflows/stubtest.yml index b7eb86f9a04c..2de7bbe5b2e5 100644 --- a/.github/workflows/stubtest.yml +++ b/.github/workflows/stubtest.yml @@ -71,8 +71,8 @@ jobs: github-token: ${{secrets.GITHUB_TOKEN}} script: | await github.issues.create({ - owner: context.repo.owner, - repo: context.repo.repo, + owner: "python", + repo: "typeshed", title: `Stubtest failed on ${new Date().toDateString()}`, - body: `Stubtest runs are listed here: https://github.com/${context.repo.owner}/${context.repo.repo}/actions/workflows/stubtest.yml`, + body: `Stubtest runs are listed here: https://github.com/python/typeshed/actions/workflows/stubtest.yml`, }) From 133ac8cda35bb9bd60d36d588b91dad162a48b20 Mon Sep 17 00:00:00 2001 From: Akuli Date: Thu, 20 Jan 2022 18:07:47 +0200 Subject: [PATCH 14/14] string --- .github/workflows/stubtest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stubtest.yml b/.github/workflows/stubtest.yml index 2de7bbe5b2e5..fd7b0a7fbbf4 100644 --- a/.github/workflows/stubtest.yml +++ b/.github/workflows/stubtest.yml @@ -74,5 +74,5 @@ jobs: 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`, + body: "Stubtest runs are listed here: https://github.com/python/typeshed/actions/workflows/stubtest.yml", })