| name: CI | |
| on: | |
| push: | |
| branches: [main] | |
| tags: | |
| # Tags for all potential release numbers till 2030. | |
| - "2[0-9].[0-3]" # 20.0 -> 29.3 | |
| - "2[0-9].[0-3].[0-9]+" # 20.0.0 -> 29.3.[0-9]+ | |
| pull_request: | |
| schedule: | |
| - cron: 0 0 * * MON # Run every Monday at 00:00 UTC | |
| workflow_dispatch: | |
| # allow manual runs on branches without a PR | |
| env: | |
| # The "FORCE_COLOR" variable, when set to 1, | |
| # tells Nox to colorize itself. | |
| FORCE_COLOR: "1" | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} | |
| cancel-in-progress: true | |
| jobs: | |
| docs: | |
| name: docs | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| - uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0 | |
| with: | |
| python-version: "3.x" | |
| - run: python -m pip install . | |
| - run: python -m pip install nox | |
| - run: python -m nox -s docs | |
| determine-changes: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| tests: ${{ steps.filter.outputs.tests }} | |
| vendoring: ${{ steps.filter.outputs.vendoring }} | |
| steps: | |
| # For pull requests it's not necessary to checkout the code | |
| - uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4 | |
| id: filter | |
| with: | |
| filters: | | |
| vendoring: | |
| # Anything that's touching "vendored code" | |
| - "src/pip/_vendor/**" | |
| - "pyproject.toml" | |
| - "noxfile.py" | |
| tests: | |
| # Anything that's touching code-related stuff | |
| - ".github/workflows/ci.yml" | |
| - "src/**" | |
| - "tests/**" | |
| - "noxfile.py" | |
| # Holds the pytest configuration and the test dependency groups. | |
| - "pyproject.toml" | |
| # The test suite should also run when cutting a release | |
| # (which is the only time this file is modified). | |
| - "NEWS.rst" | |
| if: github.event_name == 'pull_request' | |
| packaging: | |
| name: packaging / ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, windows-latest] | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| - uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0 | |
| with: | |
| python-version: "3.x" | |
| - name: Set up git credentials | |
| run: | | |
| git config --global user.email "pypa-dev@googlegroups.com" | |
| git config --global user.name "pip" | |
| - run: python -m pip install . | |
| - run: python -m pip install nox | |
| - run: python -m nox -s prepare-release -- 99.9 | |
| - run: python -m nox -s build-release -- 99.9 | |
| - run: pipx run check-sdist | |
| vendoring: | |
| name: vendoring | |
| runs-on: ubuntu-latest | |
| needs: [determine-changes] | |
| if: >- | |
| needs.determine-changes.outputs.vendoring == 'true' || | |
| github.event_name != 'pull_request' | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| - uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0 | |
| with: | |
| python-version: "3.x" | |
| - run: python -m pip install . | |
| - run: python -m pip install nox | |
| - run: python -m nox -s vendoring | |
| - run: git diff --exit-code | |
| tests-unix: | |
| name: tests / ${{ matrix.python.version || matrix.python }} / ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| needs: [determine-changes] | |
| if: >- | |
| needs.determine-changes.outputs.tests == 'true' || | |
| github.event_name != 'pull_request' | |
| strategy: | |
| fail-fast: true | |
| matrix: | |
| os: [ubuntu-latest, macos-latest] | |
| python: | |
| - "3.10" | |
| - "3.11" | |
| - "3.12" | |
| - "3.13" | |
| - "3.14" | |
| - "3.15" | |
| - "3.14t" | |
| include: | |
| # Oldest patches catch backport regressions. Use their Ubuntu 24.04 builds. | |
| # See: https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json | |
| - os: ubuntu-24.04 | |
| python: { key: "3.10", version: "3.10.4" } | |
| - os: ubuntu-24.04 | |
| python: { key: "3.11", version: "3.11.0" } | |
| - os: ubuntu-24.04 | |
| python: { key: "3.12", version: "3.12.0" } | |
| - os: ubuntu-24.04 | |
| python: { key: "3.13", version: "3.13.0" } | |
| - os: ubuntu-24.04 | |
| python: { key: "3.14", version: "3.14.0" } | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| - uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0 | |
| with: | |
| python-version: ${{ matrix.python.version || matrix.python }} | |
| allow-prereleases: true | |
| - name: Set PYTHON_GIL | |
| if: endsWith(matrix.python.version || matrix.python, 't') | |
| run: | | |
| echo "PYTHON_GIL=0" >> "$GITHUB_ENV" | |
| - name: Install Ubuntu dependencies | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install brz subversion | |
| - name: Install MacOS dependencies | |
| if: runner.os == 'macOS' | |
| run: | | |
| DEPS=breezy | |
| if ! which svn; then | |
| DEPS="${DEPS} subversion" | |
| fi | |
| brew install ${DEPS} | |
| - run: python -m pip install . | |
| - run: python -m pip install nox | |
| # Main check | |
| - name: Run unit tests | |
| run: >- | |
| python -m nox -s test-${{ matrix.python.key || matrix.python }} -- | |
| tests/unit | |
| --verbose --numprocesses auto --showlocals | |
| - name: Run integration tests | |
| run: >- | |
| python -m nox -s test-${{ matrix.python.key || matrix.python }} --no-install -- | |
| tests/functional | |
| --verbose --numprocesses auto --showlocals | |
| --durations=15 | |
| tests-windows: | |
| name: tests / ${{ matrix.python }} / ${{ matrix.os }} / ${{ matrix.group }} | |
| runs-on: ${{ matrix.os }}-latest | |
| needs: [determine-changes] | |
| if: >- | |
| needs.determine-changes.outputs.tests == 'true' || | |
| github.event_name != 'pull_request' | |
| strategy: | |
| fail-fast: true | |
| matrix: | |
| os: [Windows] | |
| python: | |
| - "3.10" | |
| # Commented out, since Windows tests are expensively slow, | |
| # only test the oldest and newest Python supported by pip | |
| # - "3.11" | |
| # - "3.12" | |
| # - "3.13" | |
| - "3.14" | |
| - "3.15" | |
| - "3.14t" | |
| # Windows is slow, so shard unit + functional across runners, split by a | |
| # stable hash of each test's node id (see --num-test-groups in conftest). | |
| group: [1, 2, 3] | |
| steps: | |
| # The D: drive is significantly faster than the system C: drive. | |
| # https://github.com/actions/runner-images/issues/8755 | |
| - name: Set TEMP to D:/Temp | |
| run: | | |
| mkdir "D:\\Temp" | |
| echo "TEMP=D:\\Temp" >> $env:GITHUB_ENV | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| - uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0 | |
| with: | |
| python-version: ${{ matrix.python }} | |
| allow-prereleases: true | |
| - name: Set PYTHON_GIL | |
| if: endsWith(matrix.python, 't') | |
| run: | | |
| echo "PYTHON_GIL=0" >> "$GITHUB_ENV" | |
| - name: Install Subversion | |
| shell: pwsh | |
| run: | | |
| for ($i = 1; $i -le 3; $i++) { | |
| winget source reset --force | |
| winget source update winget | |
| winget install --source winget --accept-source-agreements --accept-package-agreements -e --id Slik.Subversion | |
| if ($LASTEXITCODE -eq 0) { break } | |
| if ($i -eq 3) { exit $LASTEXITCODE } | |
| Start-Sleep -Seconds (10 * $i) | |
| } | |
| echo "C:\Program Files\SlikSvn\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append | |
| - run: python -m pip install . | |
| - run: python -m pip install nox | |
| # Main check. worksteal rebalances the long tail of slow install tests | |
| # onto idle workers: | |
| # https://pytest-xdist.readthedocs.io/en/stable/distribution.html | |
| - name: Run tests (shard ${{ matrix.group }} of 3) | |
| run: >- | |
| python -m nox -s test-${{ matrix.python }} -- | |
| tests/unit tests/functional | |
| --num-test-groups 3 --test-group ${{ matrix.group }} | |
| --verbose --numprocesses auto --showlocals --durations=15 | |
| --dist worksteal | |
| tests-zipapp: | |
| name: tests / zipapp | |
| runs-on: ubuntu-latest | |
| needs: [determine-changes] | |
| if: >- | |
| needs.determine-changes.outputs.tests == 'true' || | |
| github.event_name != 'pull_request' | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| - uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0 | |
| with: | |
| python-version: "3.11" | |
| - name: Install Ubuntu dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install brz subversion | |
| - run: python -m pip install . | |
| - run: python -m pip install nox | |
| # Main check | |
| - name: Run integration tests | |
| run: >- | |
| python -m nox -s test-3.11 -- | |
| tests/functional | |
| --verbose --numprocesses auto --showlocals | |
| --durations=15 | |
| --use-zipapp | |
| check: # This job does nothing and is only used for the branch protection | |
| if: always() | |
| needs: | |
| - determine-changes | |
| - docs | |
| - packaging | |
| - tests-unix | |
| - tests-windows | |
| - tests-zipapp | |
| - vendoring | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Decide whether the needed jobs succeeded or failed | |
| uses: re-actors/alls-green@b5b5b37504aa4183270bd3d855c52a67f212be35 # release/v1 | |
| with: | |
| allowed-skips: >- | |
| ${{ | |
| ( | |
| needs.determine-changes.outputs.vendoring != 'true' | |
| && github.event_name == 'pull_request' | |
| ) | |
| && 'vendoring' | |
| || '' | |
| }} | |
| , | |
| ${{ | |
| ( | |
| needs.determine-changes.outputs.tests != 'true' | |
| && github.event_name == 'pull_request' | |
| ) | |
| && ' | |
| tests-unix, | |
| tests-windows, | |
| tests-zipapp, | |
| ' | |
| || '' | |
| }} | |
| jobs: ${{ toJSON(needs) }} |