diff --git a/.github/workflows/daily.yml b/.github/workflows/daily.yml index bda568659b9f..254258202197 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..4ac93d89c3b4 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 @@ -21,12 +22,13 @@ 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.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true 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..73926e21e817 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 @@ -22,17 +34,19 @@ 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.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true 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