From 37c01e11c4db153ba4e9439adaaf1eea4d2c6e4b Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Mon, 10 Aug 2026 16:04:26 +0200 Subject: [PATCH 1/7] [CI] Reuse stubtest workflows --- .github/workflows/daily.yml | 82 ++-------------------- .github/workflows/stubtest_stdlib.yml | 2 + .github/workflows/stubtest_third_party.yml | 21 +++++- 3 files changed, 26 insertions(+), 79 deletions(-) diff --git a/.github/workflows/daily.yml b/.github/workflows/daily.yml index bda568659b9f..24a4cf22c65f 100644 --- a/.github/workflows/daily.yml +++ b/.github/workflows/daily.yml @@ -29,85 +29,13 @@ env: jobs: stubtest-stdlib: - name: "stubtest: stdlib" - if: ${{ github.repository == 'python/typeshed' || github.event_name != 'schedule' }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: ["ubuntu-latest", "windows-latest", "macos-latest"] - python-version: ["3.10", "3.11", "3.12", "3.13", "3.14", "3.15"] - exclude: - # https://github.com/python/typeshed/issues/15694 - - os: "windows-latest" - python-version: "3.10" - fail-fast: false - - steps: - - uses: actions/checkout@v7 - - name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }} - uses: actions/setup-python@v6 - with: - python-version: ${{ matrix.python-version }} - cache: pip - cache-dependency-path: requirements-tests.txt - allow-prereleases: true - check-latest: true - - name: Install dependencies - run: pip install -r requirements-tests.txt - - name: Run stubtest - run: python tests/stubtest_stdlib.py + uses: "$/.github/workflows/stubtest_stdlib.yml" 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@v7 - - 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 }} + uses: "$/.github/workflows/stubtest_third_party.yml" + with: + all-stubs: true + sharded: true stub-uploader: name: stub_uploader tests diff --git a/.github/workflows/stubtest_stdlib.yml b/.github/workflows/stubtest_stdlib.yml index 5a4ad30473f6..36829acc1372 100644 --- a/.github/workflows/stubtest_stdlib.yml +++ b/.github/workflows/stubtest_stdlib.yml @@ -11,6 +11,7 @@ on: - ".github/workflows/stubtest_stdlib.yml" - "tests/**" # When requirements.txt changes, we run `daily.yml`, which includes stdlib stubtest + workflow_call: permissions: contents: read @@ -27,6 +28,7 @@ concurrency: jobs: stubtest-stdlib: name: "stubtest: stdlib" + if: ${{ github.repository == 'python/typeshed' || github.event_name != 'schedule' }} runs-on: ${{ matrix.os }} strategy: matrix: diff --git a/.github/workflows/stubtest_third_party.yml b/.github/workflows/stubtest_third_party.yml index 540a609ca1c2..01ee10f7a419 100644 --- a/.github/workflows/stubtest_third_party.yml +++ b/.github/workflows/stubtest_third_party.yml @@ -7,6 +7,18 @@ on: - ".github/workflows/stubtest_third_party.yml" - "tests/**" # When requirements.txt changes, we run `daily.yml`, which includes third-party stubtest + workflow_call: + inputs: + all-stubs: + description: "Run on all stubs, not only changed" + required: false + default: false + type: boolean + sharded: + description: "Split the run across 4 shards" + required: false + default: false + type: boolean permissions: contents: read @@ -28,11 +40,13 @@ concurrency: jobs: 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: ${{ inputs.sharded && fromJSON('[0, 1, 2, 3]') || fromJSON('[0]') }} fail-fast: false steps: @@ -49,6 +63,7 @@ jobs: - name: Install dependencies run: pip install -r requirements-tests.txt - name: Determine changed stubs + if: ${{ ! inputs.all-stubs }} shell: bash run: | # This only runs stubtest on changed stubs, because it is much faster. @@ -64,7 +79,7 @@ jobs: - name: Install required system packages shell: bash run: | - if [ -n "$STUBS" ]; then + if [ -n "$STUBS" -o "${{ inputs.all-stubs }}" = "true" ]; then PACKAGES=$(python tests/get_stubtest_system_requirements.py $STUBS) if [ "${{ runner.os }}" = "Linux" ]; then if [ -n "$PACKAGES" ]; then @@ -88,14 +103,16 @@ jobs: run: | if [ -n "$STUBS" ]; then echo "Testing $STUBS..." + fi + if [ -n "$STUBS" -o "${{ inputs.all-stubs }}" = "true" ]; then 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 + $PYTHON_EXECUTABLE tests/stubtest_third_party.py --ci-platforms-only --num-shards ${{ inputs.sharded && 4 || 1 }} --shard-index ${{ matrix.shard-index }} $STUBS else echo "Nothing to test" fi From 7ec70b727b289851c89de0882284a14570f1a404 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Mon, 10 Aug 2026 16:13:17 +0200 Subject: [PATCH 2/7] Change two stubs for testings purposes --- stubs/croniter/croniter/croniter.pyi | 1 + stubs/lupa/lupa/version.pyi | 1 + 2 files changed, 2 insertions(+) diff --git a/stubs/croniter/croniter/croniter.pyi b/stubs/croniter/croniter/croniter.pyi index b9ba661e3ca9..0c5284403d05 100644 --- a/stubs/croniter/croniter/croniter.pyi +++ b/stubs/croniter/croniter/croniter.pyi @@ -169,6 +169,7 @@ class croniter(Generic[_R_co]): implement_cron_bug: bool = False, second_at_beginning: bool = False, expand_from_start_time: bool = False, + x: int = 1, ) -> None: ... @overload diff --git a/stubs/lupa/lupa/version.pyi b/stubs/lupa/lupa/version.pyi index c5dd95466063..ae2bd2e73a84 100644 --- a/stubs/lupa/lupa/version.pyi +++ b/stubs/lupa/lupa/version.pyi @@ -1,3 +1,4 @@ from typing import Final +# abc __version__: Final[str] From 779acdfdeed847fa564249a1b3f86023e4c70439 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Mon, 10 Aug 2026 16:16:48 +0200 Subject: [PATCH 3/7] Revert "Change two stubs for testings purposes" This reverts commit 7ec70b727b289851c89de0882284a14570f1a404. --- stubs/croniter/croniter/croniter.pyi | 1 - stubs/lupa/lupa/version.pyi | 1 - 2 files changed, 2 deletions(-) diff --git a/stubs/croniter/croniter/croniter.pyi b/stubs/croniter/croniter/croniter.pyi index 0c5284403d05..b9ba661e3ca9 100644 --- a/stubs/croniter/croniter/croniter.pyi +++ b/stubs/croniter/croniter/croniter.pyi @@ -169,7 +169,6 @@ class croniter(Generic[_R_co]): implement_cron_bug: bool = False, second_at_beginning: bool = False, expand_from_start_time: bool = False, - x: int = 1, ) -> None: ... @overload diff --git a/stubs/lupa/lupa/version.pyi b/stubs/lupa/lupa/version.pyi index ae2bd2e73a84..c5dd95466063 100644 --- a/stubs/lupa/lupa/version.pyi +++ b/stubs/lupa/lupa/version.pyi @@ -1,4 +1,3 @@ from typing import Final -# abc __version__: Final[str] From 44356f7e13cb2a7ec43321508681536fd8d0350a Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Mon, 10 Aug 2026 16:46:41 +0200 Subject: [PATCH 4/7] Fix CI Don't key off github.workflow: when called as a reusable workflow, it resolves to the *caller's* name, which would collide with the caller's own concurrency group and deadlock (the jobs would never be scheduled). --- .github/workflows/stubtest_stdlib.yml | 2 +- .github/workflows/stubtest_third_party.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/stubtest_stdlib.yml b/.github/workflows/stubtest_stdlib.yml index 36829acc1372..70b662ed1f13 100644 --- a/.github/workflows/stubtest_stdlib.yml +++ b/.github/workflows/stubtest_stdlib.yml @@ -22,7 +22,7 @@ env: TERM: xterm-256color # needed for FORCE_COLOR to work on mypy on Ubuntu, see https://github.com/python/mypy/issues/13817 concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + group: stubtest-stdlib-${{ github.head_ref || github.run_id }} cancel-in-progress: true jobs: diff --git a/.github/workflows/stubtest_third_party.yml b/.github/workflows/stubtest_third_party.yml index 01ee10f7a419..37a8fc5b25bc 100644 --- a/.github/workflows/stubtest_third_party.yml +++ b/.github/workflows/stubtest_third_party.yml @@ -34,7 +34,7 @@ env: TERM: xterm-256color # needed for FORCE_COLOR to work on mypy on Ubuntu, see https://github.com/python/mypy/issues/13817 concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + group: stubtest-third-party-${{ github.head_ref || github.run_id }} cancel-in-progress: true jobs: From 950e1062d3f6d8accdcfa27ecb5cb7eeb98fe6ec Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Mon, 10 Aug 2026 16:47:55 +0200 Subject: [PATCH 5/7] Revert "Fix CI" This reverts commit 44356f7e13cb2a7ec43321508681536fd8d0350a. --- .github/workflows/stubtest_stdlib.yml | 2 +- .github/workflows/stubtest_third_party.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/stubtest_stdlib.yml b/.github/workflows/stubtest_stdlib.yml index 70b662ed1f13..36829acc1372 100644 --- a/.github/workflows/stubtest_stdlib.yml +++ b/.github/workflows/stubtest_stdlib.yml @@ -22,7 +22,7 @@ env: TERM: xterm-256color # needed for FORCE_COLOR to work on mypy on Ubuntu, see https://github.com/python/mypy/issues/13817 concurrency: - group: stubtest-stdlib-${{ github.head_ref || github.run_id }} + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true jobs: diff --git a/.github/workflows/stubtest_third_party.yml b/.github/workflows/stubtest_third_party.yml index 37a8fc5b25bc..01ee10f7a419 100644 --- a/.github/workflows/stubtest_third_party.yml +++ b/.github/workflows/stubtest_third_party.yml @@ -34,7 +34,7 @@ env: TERM: xterm-256color # needed for FORCE_COLOR to work on mypy on Ubuntu, see https://github.com/python/mypy/issues/13817 concurrency: - group: stubtest-third-party-${{ github.head_ref || github.run_id }} + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true jobs: From 6f7c0983785a55eca93fe5837b0ede9dfcfa8411 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Mon, 10 Aug 2026 16:49:22 +0200 Subject: [PATCH 6/7] Reapply "Fix CI" This reverts commit 950e1062d3f6d8accdcfa27ecb5cb7eeb98fe6ec. --- .github/workflows/stubtest_stdlib.yml | 2 +- .github/workflows/stubtest_third_party.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/stubtest_stdlib.yml b/.github/workflows/stubtest_stdlib.yml index 36829acc1372..70b662ed1f13 100644 --- a/.github/workflows/stubtest_stdlib.yml +++ b/.github/workflows/stubtest_stdlib.yml @@ -22,7 +22,7 @@ env: TERM: xterm-256color # needed for FORCE_COLOR to work on mypy on Ubuntu, see https://github.com/python/mypy/issues/13817 concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + group: stubtest-stdlib-${{ github.head_ref || github.run_id }} cancel-in-progress: true jobs: diff --git a/.github/workflows/stubtest_third_party.yml b/.github/workflows/stubtest_third_party.yml index 01ee10f7a419..37a8fc5b25bc 100644 --- a/.github/workflows/stubtest_third_party.yml +++ b/.github/workflows/stubtest_third_party.yml @@ -34,7 +34,7 @@ env: TERM: xterm-256color # needed for FORCE_COLOR to work on mypy on Ubuntu, see https://github.com/python/mypy/issues/13817 concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + group: stubtest-third-party-${{ github.head_ref || github.run_id }} cancel-in-progress: true jobs: From 29fabe1394a0bed0c9d1806aabaf584398f99a12 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Mon, 10 Aug 2026 16:50:40 +0200 Subject: [PATCH 7/7] More fixes --- .github/workflows/daily.yml | 4 ++-- .github/workflows/stubtest_stdlib.yml | 2 +- .github/workflows/stubtest_third_party.yml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/daily.yml b/.github/workflows/daily.yml index 24a4cf22c65f..254258202197 100644 --- a/.github/workflows/daily.yml +++ b/.github/workflows/daily.yml @@ -29,10 +29,10 @@ env: jobs: stubtest-stdlib: - uses: "$/.github/workflows/stubtest_stdlib.yml" + uses: $/.github/workflows/stubtest_stdlib.yml stubtest-third-party: - uses: "$/.github/workflows/stubtest_third_party.yml" + uses: $/.github/workflows/stubtest_third_party.yml with: all-stubs: true sharded: true diff --git a/.github/workflows/stubtest_stdlib.yml b/.github/workflows/stubtest_stdlib.yml index 70b662ed1f13..4ac93d89c3b4 100644 --- a/.github/workflows/stubtest_stdlib.yml +++ b/.github/workflows/stubtest_stdlib.yml @@ -22,7 +22,7 @@ env: TERM: xterm-256color # needed for FORCE_COLOR to work on mypy on Ubuntu, see https://github.com/python/mypy/issues/13817 concurrency: - group: stubtest-stdlib-${{ github.head_ref || github.run_id }} + group: stubtest-stdlib-${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true jobs: diff --git a/.github/workflows/stubtest_third_party.yml b/.github/workflows/stubtest_third_party.yml index 37a8fc5b25bc..73926e21e817 100644 --- a/.github/workflows/stubtest_third_party.yml +++ b/.github/workflows/stubtest_third_party.yml @@ -34,7 +34,7 @@ env: TERM: xterm-256color # needed for FORCE_COLOR to work on mypy on Ubuntu, see https://github.com/python/mypy/issues/13817 concurrency: - group: stubtest-third-party-${{ github.head_ref || github.run_id }} + group: stubtest-third-party-${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true jobs: