From 90e5d2646c93cc72c6ce5981e24e8b84f83f4492 Mon Sep 17 00:00:00 2001 From: donBarbos Date: Tue, 21 Oct 2025 12:28:48 +0400 Subject: [PATCH 01/13] Run stubtest only for newly released third-party package version Issue: #14838 --- .github/workflows/daily.yml | 56 +--------------- .github/workflows/stubsabot.yml | 75 +++++++++++++++++++++- .github/workflows/stubtest_third_party.yml | 2 +- scripts/stubsabot.py | 15 +++++ 4 files changed, 90 insertions(+), 58 deletions(-) diff --git a/.github/workflows/daily.yml b/.github/workflows/daily.yml index 417dbf2ebafa..a914bd85fe14 100644 --- a/.github/workflows/daily.yml +++ b/.github/workflows/daily.yml @@ -53,58 +53,6 @@ jobs: - name: Run stubtest run: python tests/stubtest_stdlib.py - stubtest-third-party: - name: "stubtest: third party" - if: ${{ github.repository == 'python/typeshed' || github.event_name != 'schedule' }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: ["ubuntu-latest", "windows-latest", "macos-latest"] - shard-index: [0, 1, 2, 3] - fail-fast: false - steps: - - uses: actions/checkout@v5 - - uses: actions/setup-python@v6 - with: - python-version: "3.13" - cache: pip - cache-dependency-path: | - requirements-tests.txt - stubs/**/METADATA.toml - - name: Install dependencies - run: pip install -r requirements-tests.txt - - name: Install required system packages - shell: bash - run: | - PACKAGES=$(python tests/get_stubtest_system_requirements.py) - - if [ "${{ runner.os }}" = "Linux" ]; then - if [ -n "$PACKAGES" ]; then - printf "Installing APT packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n" - sudo apt-get update -q && sudo apt-get install -qy $PACKAGES - fi - else - if [ "${{ runner.os }}" = "macOS" ] && [ -n "$PACKAGES" ]; then - printf "Installing Homebrew packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n" - brew install -q $PACKAGES - fi - - if [ "${{ runner.os }}" = "Windows" ] && [ -n "$PACKAGES" ]; then - printf "Installing Chocolatey packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n" - choco install -y $PACKAGES - fi - fi - - name: Run stubtest - shell: bash - run: | - if [ "${{ runner.os }}" = "Linux" ]; then - PYTHON_EXECUTABLE="xvfb-run python" - else - PYTHON_EXECUTABLE="python" - fi - - $PYTHON_EXECUTABLE tests/stubtest_third_party.py --ci-platforms-only --num-shards 4 --shard-index ${{ matrix.shard-index }} - stub-uploader: name: stub_uploader tests if: ${{ github.repository == 'python/typeshed' || github.event_name != 'schedule' }} @@ -136,8 +84,8 @@ jobs: create-issue-on-failure: name: Create issue on failure runs-on: ubuntu-latest - needs: [stubtest-stdlib, stubtest-third-party, stub-uploader] - if: ${{ github.repository == 'python/typeshed' && always() && github.event_name == 'schedule' && (needs.stubtest-stdlib.result == 'failure' || needs.stubtest-third-party.result == 'failure' || needs.stub-uploader.result == 'failure') }} + needs: [stubtest-stdlib, stub-uploader] + if: ${{ github.repository == 'python/typeshed' && always() && github.event_name == 'schedule' && (needs.stubtest-stdlib.result == 'failure' || needs.stub-uploader.result == 'failure') }} permissions: issues: write steps: diff --git a/.github/workflows/stubsabot.yml b/.github/workflows/stubsabot.yml index 9088ea21b7ef..7c1b1dbca96b 100644 --- a/.github/workflows/stubsabot.yml +++ b/.github/workflows/stubsabot.yml @@ -18,6 +18,8 @@ jobs: name: Upgrade stubs with stubsabot if: github.repository == 'python/typeshed' runs-on: ubuntu-latest + outputs: + STUBS: ${{ steps.runstubsabot.outputs.STUBS }} steps: - uses: actions/checkout@v5 with: @@ -37,14 +39,81 @@ jobs: - name: Install dependencies run: uv pip install -r requirements-tests.txt --system - name: Run stubsabot - run: GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} python scripts/stubsabot.py --action-level everything + id: runstubsabot + run: | + GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} python scripts/stubsabot.py --action-level everything + echo "Stubs that should be tested by stubtest: $STUBS" + echo "STUBS=$STUBS" >> $GITHUB_OUTPUT + + stubtest-third-party: + name: "stubtest: third party" + if: github.repository == 'python/typeshed' + runs-on: ${{ matrix.os }} + needs: [stubsabot] + strategy: + matrix: + os: ["ubuntu-latest", "windows-latest", "macos-latest"] + fail-fast: false + env: + STUBS: ${{ needs.stubsabot.outputs.STUBS }} + steps: + - uses: actions/checkout@v5 + with: + fetch-depth: 0 + - uses: actions/setup-python@v6 + with: + python-version: "3.13" + cache: pip + cache-dependency-path: | + requirements-tests.txt + stubs/**/METADATA.toml + - name: Install dependencies + run: pip install -r requirements-tests.txt + - name: Install required system packages + shell: bash + run: | + if [ -n "$STUBS" ]; then + PACKAGES=$(python tests/get_stubtest_system_requirements.py $STUBS) + if [ "${{ runner.os }}" = "Linux" ]; then + if [ -n "$PACKAGES" ]; then + printf "Installing APT packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n" + sudo apt-get update -q && sudo apt-get install -qy $PACKAGES + fi + else + if [ "${{ runner.os }}" = "macOS" ] && [ -n "$PACKAGES" ]; then + printf "Installing Homebrew packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n" + brew install -q $PACKAGES + fi + + if [ "${{ runner.os }}" = "Windows" ] && [ -n "$PACKAGES" ]; then + printf "Installing Chocolatey packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n" + choco install -y $PACKAGES + fi + fi + fi + - name: Run stubtest + shell: bash + run: | + if [ -n "$STUBS" ]; then + echo "Testing $STUBS..." + + if [ "${{ runner.os }}" = "Linux" ]; then + PYTHON_EXECUTABLE="xvfb-run python" + else + PYTHON_EXECUTABLE="python" + fi + + $PYTHON_EXECUTABLE tests/stubtest_third_party.py --ci-platforms-only $STUBS + else + echo "Nothing to test" + fi # https://github.community/t/run-github-actions-job-only-if-previous-job-has-failed/174786/2 create-issue-on-failure: name: Create issue on failure runs-on: ubuntu-latest - needs: [stubsabot] - if: ${{ github.repository == 'python/typeshed' && always() && (needs.stubsabot.result == 'failure') }} + needs: [stubsabot, stubtest-third-party] + if: ${{ github.repository == 'python/typeshed' && always() && (needs.stubsabot.result == 'failure' || needs.stubtest-third-party.result == 'failure') }} steps: - uses: actions/github-script@v8 with: diff --git a/.github/workflows/stubtest_third_party.yml b/.github/workflows/stubtest_third_party.yml index 7f7ce1ca5408..0153412e4107 100644 --- a/.github/workflows/stubtest_third_party.yml +++ b/.github/workflows/stubtest_third_party.yml @@ -52,7 +52,7 @@ jobs: shell: bash run: | # This only runs stubtest on changed stubs, because it is much faster. - # Use the daily.yml workflow to run stubtest on all third party stubs. + # Use the stubsabot.yml workflow to run stubtest on third-party stubs. function find_stubs { git diff --name-only origin/${{ github.base_ref }} HEAD | \ egrep ^stubs/ | cut -d "/" -f 2 | sort -u | \ diff --git a/scripts/stubsabot.py b/scripts/stubsabot.py index 60b905fbfb2b..6f3e1a454c93 100755 --- a/scripts/stubsabot.py +++ b/scripts/stubsabot.py @@ -620,6 +620,15 @@ async def has_no_longer_updated_release(release_to_download: PypiReleaseDownload return await with_extracted_archive(release_to_download, session=session, handler=parse_no_longer_updated_from_archive) +def is_new_release(upload_datetime: datetime.datetime) -> bool: + if upload_datetime.tzinfo is None: + upload_datetime = upload_datetime.replace(tzinfo=datetime.timezone.utc) + else: + upload_datetime = upload_datetime.astimezone(datetime.timezone.utc) + yesterday = datetime.datetime.now(tz=datetime.timezone.utc) - datetime.timedelta(days=1) + return upload_datetime > yesterday + + async def determine_action(distribution: str, session: aiohttp.ClientSession) -> Update | NoUpdate | Obsolete | Remove | Error: try: return await determine_action_no_error_handling(distribution, session) @@ -663,6 +672,12 @@ async def determine_action_no_error_handling( latest_version = latest_release.version obsolete_since = await find_first_release_with_py_typed(pypi_info, session=session) if obsolete_since is None and latest_version in stub_info.version_spec: + if is_new_release(latest_release.upload_date): + stubs = os.environ.get("STUBS", "").strip() + if stubs: + stubs = f"{stubs} {latest_release.distribution}" + else: + stubs = latest_release.distribution return NoUpdate(stub_info.distribution, "up to date") relevant_version = obsolete_since.version if obsolete_since else latest_version From c1457f620f91d4c0496c9fa6ef7d0bb59791b596 Mon Sep 17 00:00:00 2001 From: donBarbos Date: Tue, 21 Oct 2025 20:43:19 +0400 Subject: [PATCH 02/13] Fix problem with evn var --- .github/workflows/stubsabot.yml | 1 + scripts/stubsabot.py | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.github/workflows/stubsabot.yml b/.github/workflows/stubsabot.yml index 7c1b1dbca96b..4e7ccbd5909b 100644 --- a/.github/workflows/stubsabot.yml +++ b/.github/workflows/stubsabot.yml @@ -42,6 +42,7 @@ jobs: id: runstubsabot run: | GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} python scripts/stubsabot.py --action-level everything + STUBS=$(cat /tmp/stubs.txt) echo "Stubs that should be tested by stubtest: $STUBS" echo "STUBS=$STUBS" >> $GITHUB_OUTPUT diff --git a/scripts/stubsabot.py b/scripts/stubsabot.py index 6f3e1a454c93..961318e16cd9 100755 --- a/scripts/stubsabot.py +++ b/scripts/stubsabot.py @@ -46,6 +46,8 @@ POLICY_MONTHS_DELTA = 6 +DEFAULT_STUBTEST_FILE = Path("/tmp/stubs.txt") # Sync with `stubsabot` github job + class ActionLevel(enum.IntEnum): def __new__(cls, value: int, doc: str) -> Self: @@ -629,6 +631,17 @@ def is_new_release(upload_datetime: datetime.datetime) -> bool: return upload_datetime > yesterday +def append_stub_to_stubtest_list(distribution: str, *, file_path: Path = DEFAULT_STUBTEST_FILE) -> None: + if Path.exists(file_path): + with Path.open(file_path, "r") as f: + stubs = f.read().strip() + else: + stubs = "" + stubs = f"{stubs} {distribution}" if stubs else distribution + with Path.open(file_path, "w") as f: + f.write(stubs) + + async def determine_action(distribution: str, session: aiohttp.ClientSession) -> Update | NoUpdate | Obsolete | Remove | Error: try: return await determine_action_no_error_handling(distribution, session) @@ -673,11 +686,7 @@ async def determine_action_no_error_handling( obsolete_since = await find_first_release_with_py_typed(pypi_info, session=session) if obsolete_since is None and latest_version in stub_info.version_spec: if is_new_release(latest_release.upload_date): - stubs = os.environ.get("STUBS", "").strip() - if stubs: - stubs = f"{stubs} {latest_release.distribution}" - else: - stubs = latest_release.distribution + append_stub_to_stubtest_list(latest_release.distribution) return NoUpdate(stub_info.distribution, "up to date") relevant_version = obsolete_since.version if obsolete_since else latest_version From 300b45bc0a8521bf41fe8524e7bb973327d4304c Mon Sep 17 00:00:00 2001 From: donBarbos Date: Wed, 22 Oct 2025 20:15:25 +0400 Subject: [PATCH 03/13] Back stubtest-third-party for requirements.txt chages cases --- .github/workflows/daily.yml | 50 ++++++++++++++++++++++ .github/workflows/stubtest_third_party.yml | 1 - 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/.github/workflows/daily.yml b/.github/workflows/daily.yml index a914bd85fe14..9ab5eb2f0972 100644 --- a/.github/workflows/daily.yml +++ b/.github/workflows/daily.yml @@ -53,6 +53,56 @@ jobs: - name: Run stubtest run: python tests/stubtest_stdlib.py + # This job only runs when requirements.txt is changed + stubtest-third-party: + name: "stubtest: third party" + if: ${{ github.repository == 'python/typeshed' && github.event_name != 'schedule' }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: ["ubuntu-latest", "windows-latest", "macos-latest"] + shard-index: [0, 1, 2, 3] + fail-fast: false + steps: + - uses: actions/checkout@v5 + - uses: actions/setup-python@v6 + with: + python-version: "3.13" + cache: pip + cache-dependency-path: | + requirements-tests.txt + stubs/**/METADATA.toml + - name: Install dependencies + run: pip install -r requirements-tests.txt + - name: Install required system packages + shell: bash + run: | + PACKAGES=$(python tests/get_stubtest_system_requirements.py) + if [ "${{ runner.os }}" = "Linux" ]; then + if [ -n "$PACKAGES" ]; then + printf "Installing APT packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n" + sudo apt-get update -q && sudo apt-get install -qy $PACKAGES + fi + else + if [ "${{ runner.os }}" = "macOS" ] && [ -n "$PACKAGES" ]; then + printf "Installing Homebrew packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n" + brew install -q $PACKAGES + fi + if [ "${{ runner.os }}" = "Windows" ] && [ -n "$PACKAGES" ]; then + printf "Installing Chocolatey packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n" + choco install -y $PACKAGES + fi + fi + - name: Run stubtest + shell: bash + run: | + if [ "${{ runner.os }}" = "Linux" ]; then + PYTHON_EXECUTABLE="xvfb-run python" + else + PYTHON_EXECUTABLE="python" + fi + $PYTHON_EXECUTABLE tests/stubtest_third_party.py --ci-platforms-only --num-shards 4 --shard-index ${{ matrix.shard-index }} + stub-uploader: name: stub_uploader tests if: ${{ github.repository == 'python/typeshed' || github.event_name != 'schedule' }} diff --git a/.github/workflows/stubtest_third_party.yml b/.github/workflows/stubtest_third_party.yml index 0153412e4107..3b35d49fcfea 100644 --- a/.github/workflows/stubtest_third_party.yml +++ b/.github/workflows/stubtest_third_party.yml @@ -52,7 +52,6 @@ jobs: shell: bash run: | # This only runs stubtest on changed stubs, because it is much faster. - # Use the stubsabot.yml workflow to run stubtest on third-party stubs. function find_stubs { git diff --name-only origin/${{ github.base_ref }} HEAD | \ egrep ^stubs/ | cut -d "/" -f 2 | sort -u | \ From 98e610299a4019580f5b1cef6ee0dc91e636c5dd Mon Sep 17 00:00:00 2001 From: donBarbos Date: Wed, 22 Oct 2025 21:20:22 +0400 Subject: [PATCH 04/13] use grep instead of tmp file --- .github/workflows/stubsabot.yml | 15 ++++++++++++--- scripts/stubsabot.py | 16 ++-------------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/.github/workflows/stubsabot.yml b/.github/workflows/stubsabot.yml index 4e7ccbd5909b..aea645583786 100644 --- a/.github/workflows/stubsabot.yml +++ b/.github/workflows/stubsabot.yml @@ -40,11 +40,20 @@ jobs: run: uv pip install -r requirements-tests.txt --system - name: Run stubsabot id: runstubsabot + shell: bash run: | - GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} python scripts/stubsabot.py --action-level everything - STUBS=$(cat /tmp/stubs.txt) - echo "Stubs that should be tested by stubtest: $STUBS" + # Parse stubsabot.py output to find stubs that should be tested. + set -o pipefail + exec 5>&1 + STUBS=$(script -qfc "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} python scripts/stubsabot.py --action-level everything" /dev/null \ + | tee >(cat - >&5) \ + | sed -r "s/\x1B\[[0-9;]*[mK]//g" \ + | grep 'should be tested by stubsabot' \ + | awk '{print $1}' \ + | xargs) + exit_code=$? echo "STUBS=$STUBS" >> $GITHUB_OUTPUT + exit $exit_code stubtest-third-party: name: "stubtest: third party" diff --git a/scripts/stubsabot.py b/scripts/stubsabot.py index 961318e16cd9..5e362fa14944 100755 --- a/scripts/stubsabot.py +++ b/scripts/stubsabot.py @@ -46,8 +46,6 @@ POLICY_MONTHS_DELTA = 6 -DEFAULT_STUBTEST_FILE = Path("/tmp/stubs.txt") # Sync with `stubsabot` github job - class ActionLevel(enum.IntEnum): def __new__(cls, value: int, doc: str) -> Self: @@ -631,17 +629,6 @@ def is_new_release(upload_datetime: datetime.datetime) -> bool: return upload_datetime > yesterday -def append_stub_to_stubtest_list(distribution: str, *, file_path: Path = DEFAULT_STUBTEST_FILE) -> None: - if Path.exists(file_path): - with Path.open(file_path, "r") as f: - stubs = f.read().strip() - else: - stubs = "" - stubs = f"{stubs} {distribution}" if stubs else distribution - with Path.open(file_path, "w") as f: - f.write(stubs) - - async def determine_action(distribution: str, session: aiohttp.ClientSession) -> Update | NoUpdate | Obsolete | Remove | Error: try: return await determine_action_no_error_handling(distribution, session) @@ -686,7 +673,8 @@ async def determine_action_no_error_handling( obsolete_since = await find_first_release_with_py_typed(pypi_info, session=session) if obsolete_since is None and latest_version in stub_info.version_spec: if is_new_release(latest_release.upload_date): - append_stub_to_stubtest_list(latest_release.distribution) + # Next print should be parsed by github action, see `stubsabot.yml` + print(colored(f"{stub_info.distribution} should be tested by stubsabot", "blue")) return NoUpdate(stub_info.distribution, "up to date") relevant_version = obsolete_since.version if obsolete_since else latest_version From b6bee4e83324c14331b72b3f2ac1f6490b1912c5 Mon Sep 17 00:00:00 2001 From: donBarbos Date: Wed, 22 Oct 2025 21:27:08 +0400 Subject: [PATCH 05/13] revert empty lines --- .github/workflows/daily.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/daily.yml b/.github/workflows/daily.yml index 9ab5eb2f0972..d47fc990455d 100644 --- a/.github/workflows/daily.yml +++ b/.github/workflows/daily.yml @@ -78,6 +78,7 @@ jobs: shell: bash run: | PACKAGES=$(python tests/get_stubtest_system_requirements.py) + if [ "${{ runner.os }}" = "Linux" ]; then if [ -n "$PACKAGES" ]; then printf "Installing APT packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n" @@ -88,6 +89,7 @@ jobs: printf "Installing Homebrew packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n" brew install -q $PACKAGES fi + if [ "${{ runner.os }}" = "Windows" ] && [ -n "$PACKAGES" ]; then printf "Installing Chocolatey packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n" choco install -y $PACKAGES @@ -101,6 +103,7 @@ jobs: else PYTHON_EXECUTABLE="python" fi + $PYTHON_EXECUTABLE tests/stubtest_third_party.py --ci-platforms-only --num-shards 4 --shard-index ${{ matrix.shard-index }} stub-uploader: From de680109a6e6356d73a2bcb416a0c83784c4e96b Mon Sep 17 00:00:00 2001 From: donBarbos Date: Wed, 22 Oct 2025 21:42:31 +0400 Subject: [PATCH 06/13] temp diff to trigger on my fork --- .github/workflows/stubsabot.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/stubsabot.yml b/.github/workflows/stubsabot.yml index aea645583786..fa683a1db06f 100644 --- a/.github/workflows/stubsabot.yml +++ b/.github/workflows/stubsabot.yml @@ -16,7 +16,6 @@ env: jobs: stubsabot: name: Upgrade stubs with stubsabot - if: github.repository == 'python/typeshed' runs-on: ubuntu-latest outputs: STUBS: ${{ steps.runstubsabot.outputs.STUBS }} @@ -57,7 +56,6 @@ jobs: stubtest-third-party: name: "stubtest: third party" - if: github.repository == 'python/typeshed' runs-on: ${{ matrix.os }} needs: [stubsabot] strategy: @@ -123,7 +121,7 @@ jobs: name: Create issue on failure runs-on: ubuntu-latest needs: [stubsabot, stubtest-third-party] - if: ${{ github.repository == 'python/typeshed' && always() && (needs.stubsabot.result == 'failure' || needs.stubtest-third-party.result == 'failure') }} + if: ${{ always() && (needs.stubsabot.result == 'failure' || needs.stubtest-third-party.result == 'failure') }} steps: - uses: actions/github-script@v8 with: From a5c213e89fb1a5f94c9482528edb88445bb5dec1 Mon Sep 17 00:00:00 2001 From: donBarbos Date: Wed, 22 Oct 2025 21:47:11 +0400 Subject: [PATCH 07/13] =?UTF-8?q?attempt=20=E2=84=962?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/stubsabot.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/stubsabot.yml b/.github/workflows/stubsabot.yml index fa683a1db06f..77be09e4797d 100644 --- a/.github/workflows/stubsabot.yml +++ b/.github/workflows/stubsabot.yml @@ -16,15 +16,12 @@ env: jobs: stubsabot: name: Upgrade stubs with stubsabot + if: github.repository == 'donBarbos/typeshed' runs-on: ubuntu-latest outputs: STUBS: ${{ steps.runstubsabot.outputs.STUBS }} steps: - uses: actions/checkout@v5 - with: - # use an ssh key so that checks automatically run on stubsabot PRs - ssh-key: ${{ secrets.STUBSABOT_SSH_PRIVATE_KEY }} - fetch-depth: 0 - uses: actions/setup-python@v6 with: python-version: "3.13" @@ -56,6 +53,7 @@ jobs: stubtest-third-party: name: "stubtest: third party" + if: github.repository == 'donBarbos/typeshed' runs-on: ${{ matrix.os }} needs: [stubsabot] strategy: @@ -121,7 +119,7 @@ jobs: name: Create issue on failure runs-on: ubuntu-latest needs: [stubsabot, stubtest-third-party] - if: ${{ always() && (needs.stubsabot.result == 'failure' || needs.stubtest-third-party.result == 'failure') }} + if: ${{ github.repository == 'donBarbos/typeshed' && always() && (needs.stubsabot.result == 'failure' || needs.stubtest-third-party.result == 'failure') }} steps: - uses: actions/github-script@v8 with: From 1267aebee7d41db6d7d4ea0664d49ab3bdf88e6d Mon Sep 17 00:00:00 2001 From: donBarbos Date: Wed, 22 Oct 2025 21:54:00 +0400 Subject: [PATCH 08/13] =?UTF-8?q?attempt=20=E2=84=963?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/stubsabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stubsabot.yml b/.github/workflows/stubsabot.yml index 77be09e4797d..2ac6e9520637 100644 --- a/.github/workflows/stubsabot.yml +++ b/.github/workflows/stubsabot.yml @@ -41,7 +41,7 @@ jobs: # Parse stubsabot.py output to find stubs that should be tested. set -o pipefail exec 5>&1 - STUBS=$(script -qfc "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} python scripts/stubsabot.py --action-level everything" /dev/null \ + STUBS=$(script -qfc "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} python scripts/stubsabot.py --action-level nothing" /dev/null \ | tee >(cat - >&5) \ | sed -r "s/\x1B\[[0-9;]*[mK]//g" \ | grep 'should be tested by stubsabot' \ From d01bc96aa399cfc949cbedc3902093bc3bf38176 Mon Sep 17 00:00:00 2001 From: donBarbos Date: Wed, 22 Oct 2025 22:48:10 +0400 Subject: [PATCH 09/13] rewrite bash script --- .github/workflows/stubsabot.yml | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/.github/workflows/stubsabot.yml b/.github/workflows/stubsabot.yml index 2ac6e9520637..5795fab7ccbb 100644 --- a/.github/workflows/stubsabot.yml +++ b/.github/workflows/stubsabot.yml @@ -39,15 +39,22 @@ jobs: shell: bash run: | # Parse stubsabot.py output to find stubs that should be tested. - set -o pipefail exec 5>&1 - STUBS=$(script -qfc "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} python scripts/stubsabot.py --action-level nothing" /dev/null \ - | tee >(cat - >&5) \ - | sed -r "s/\x1B\[[0-9;]*[mK]//g" \ - | grep 'should be tested by stubsabot' \ - | awk '{print $1}' \ - | xargs) - exit_code=$? + EXIT_FILE=$(mktemp) + STUBS_FILE=$(mktemp) + script -q /dev/null -c ' + python scripts/stubsabot.py --action-level nothing + echo $? > '"$EXIT_FILE"' + ' 2>&1 | while IFS= read -r line; do + echo "$line" >&5 + clean=$(echo "$line" | sed -r "s/\x1B\[[0-9;]*[mK]//g") + if [[ $clean == *"should be tested by stubsabot"* ]]; then + echo "${clean%% *}" >> "$STUBS_FILE" + fi + done + exit_code=$(cat "$EXIT_FILE") + STUBS=$(xargs < "$STUBS_FILE") + rm "$EXIT_FILE" "$STUBS_FILE" echo "STUBS=$STUBS" >> $GITHUB_OUTPUT exit $exit_code From dd1062d5870d907201a1e6bbfc3ed29579ee5640 Mon Sep 17 00:00:00 2001 From: donBarbos Date: Wed, 22 Oct 2025 22:54:30 +0400 Subject: [PATCH 10/13] revert temp diff --- .github/workflows/stubsabot.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/stubsabot.yml b/.github/workflows/stubsabot.yml index 5795fab7ccbb..6003087930f6 100644 --- a/.github/workflows/stubsabot.yml +++ b/.github/workflows/stubsabot.yml @@ -16,12 +16,16 @@ env: jobs: stubsabot: name: Upgrade stubs with stubsabot - if: github.repository == 'donBarbos/typeshed' + if: github.repository == 'python/typeshed' runs-on: ubuntu-latest outputs: STUBS: ${{ steps.runstubsabot.outputs.STUBS }} steps: - uses: actions/checkout@v5 + with: + # use an ssh key so that checks automatically run on stubsabot PRs + ssh-key: ${{ secrets.STUBSABOT_SSH_PRIVATE_KEY }} + fetch-depth: 0 - uses: actions/setup-python@v6 with: python-version: "3.13" @@ -43,7 +47,7 @@ jobs: EXIT_FILE=$(mktemp) STUBS_FILE=$(mktemp) script -q /dev/null -c ' - python scripts/stubsabot.py --action-level nothing + GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} python scripts/stubsabot.py --action-level everything echo $? > '"$EXIT_FILE"' ' 2>&1 | while IFS= read -r line; do echo "$line" >&5 @@ -54,13 +58,12 @@ jobs: done exit_code=$(cat "$EXIT_FILE") STUBS=$(xargs < "$STUBS_FILE") - rm "$EXIT_FILE" "$STUBS_FILE" echo "STUBS=$STUBS" >> $GITHUB_OUTPUT exit $exit_code stubtest-third-party: name: "stubtest: third party" - if: github.repository == 'donBarbos/typeshed' + if: github.repository == 'python/typeshed' runs-on: ${{ matrix.os }} needs: [stubsabot] strategy: @@ -126,7 +129,7 @@ jobs: name: Create issue on failure runs-on: ubuntu-latest needs: [stubsabot, stubtest-third-party] - if: ${{ github.repository == 'donBarbos/typeshed' && always() && (needs.stubsabot.result == 'failure' || needs.stubtest-third-party.result == 'failure') }} + if: ${{ github.repository == 'python/typeshed' && always() && (needs.stubsabot.result == 'failure' || needs.stubtest-third-party.result == 'failure') }} steps: - uses: actions/github-script@v8 with: From 2d942675fbcb42bcb40614a656fd9be4c877aca2 Mon Sep 17 00:00:00 2001 From: donBarbos Date: Wed, 22 Oct 2025 22:57:05 +0400 Subject: [PATCH 11/13] fix typo --- scripts/stubsabot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/stubsabot.py b/scripts/stubsabot.py index 5e362fa14944..9f56a08c50e7 100755 --- a/scripts/stubsabot.py +++ b/scripts/stubsabot.py @@ -674,7 +674,7 @@ async def determine_action_no_error_handling( if obsolete_since is None and latest_version in stub_info.version_spec: if is_new_release(latest_release.upload_date): # Next print should be parsed by github action, see `stubsabot.yml` - print(colored(f"{stub_info.distribution} should be tested by stubsabot", "blue")) + print(colored(f"{stub_info.distribution} should be tested by stubtest", "blue")) return NoUpdate(stub_info.distribution, "up to date") relevant_version = obsolete_since.version if obsolete_since else latest_version From 315781a09ed47ad56a40ab9ff463b1b5b28d1e6c Mon Sep 17 00:00:00 2001 From: donBarbos Date: Fri, 24 Oct 2025 09:20:53 +0400 Subject: [PATCH 12/13] fix same type in github action --- .github/workflows/stubsabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stubsabot.yml b/.github/workflows/stubsabot.yml index 6003087930f6..c3de7c80c29b 100644 --- a/.github/workflows/stubsabot.yml +++ b/.github/workflows/stubsabot.yml @@ -52,7 +52,7 @@ jobs: ' 2>&1 | while IFS= read -r line; do echo "$line" >&5 clean=$(echo "$line" | sed -r "s/\x1B\[[0-9;]*[mK]//g") - if [[ $clean == *"should be tested by stubsabot"* ]]; then + if [[ $clean == *"should be tested by stubtest"* ]]; then echo "${clean%% *}" >> "$STUBS_FILE" fi done From ffe2356c08d44b6c5613b9205c57047260d46fca Mon Sep 17 00:00:00 2001 From: donBarbos Date: Fri, 24 Oct 2025 11:10:16 +0400 Subject: [PATCH 13/13] revert comment --- .github/workflows/stubtest_third_party.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/stubtest_third_party.yml b/.github/workflows/stubtest_third_party.yml index 3b35d49fcfea..7f7ce1ca5408 100644 --- a/.github/workflows/stubtest_third_party.yml +++ b/.github/workflows/stubtest_third_party.yml @@ -52,6 +52,7 @@ jobs: shell: bash run: | # This only runs stubtest on changed stubs, because it is much faster. + # Use the daily.yml workflow to run stubtest on all third party stubs. function find_stubs { git diff --name-only origin/${{ github.base_ref }} HEAD | \ egrep ^stubs/ | cut -d "/" -f 2 | sort -u | \