diff --git a/.github/actionlint.yml b/.github/actionlint.yml new file mode 100644 index 000000000000..ee9fd7bf0430 --- /dev/null +++ b/.github/actionlint.yml @@ -0,0 +1,5 @@ +paths: + .github/workflows/**/*.{yml,yaml}: + ignore: + # https://github.com/rhysd/actionlint/issues/711 + - 'reusable workflow call .+' diff --git a/.github/workflows/daily.yml b/.github/workflows/daily.yml index 7514a26b372a..559e3cdc9746 100644 --- a/.github/workflows/daily.yml +++ b/.github/workflows/daily.yml @@ -29,94 +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@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }} - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 - 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@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 - 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) - - # System package names contain no whitespace or glob characters, so word splitting is intentional. - # shellcheck disable=SC2086 - if [ "${{ runner.os }}" = "Linux" ]; then - if [ -n "$PACKAGES" ]; then - printf 'Installing APT packages:\n' - printf ' %s\n' $PACKAGES - 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' - printf ' %s\n' $PACKAGES - brew install -q $PACKAGES - fi - - if [ "${{ runner.os }}" = "Windows" ] && [ -n "$PACKAGES" ]; then - printf 'Installing Chocolatey packages:\n' - printf ' %s\n' $PACKAGES - 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 8653d846f73c..1a023d8dab71 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 3d90a7a77c33..1a9270d65bd9 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: @@ -50,6 +64,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. @@ -67,7 +82,7 @@ jobs: run: | # System package and stub directory names contain no whitespace or glob characters; split both lists into arguments. # shellcheck disable=SC2086 - if [ -n "$STUBS" ]; then + if [ -n "$STUBS" ] || [ "${{ inputs.all-stubs }}" = "true" ]; then PACKAGES=$(python tests/get_stubtest_system_requirements.py $STUBS) if [ "${{ runner.os }}" = "Linux" ]; then if [ -n "$PACKAGES" ]; then @@ -94,7 +109,9 @@ jobs: run: | if [ -n "$STUBS" ]; then echo "Testing $STUBS..." + fi + if [ -n "$STUBS" ] || [ "${{ inputs.all-stubs }}" = "true" ]; then if [ "${{ runner.os }}" = "Linux" ]; then PYTHON_EXECUTABLE="xvfb-run python" else @@ -103,7 +120,7 @@ jobs: # Stub directory names contain no whitespace or glob characters, so word splitting is intentional. # shellcheck disable=SC2086 - $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