| # Prior to releases, this will run additional stress tests, plus tests for all supported versions of |
| # the requests library. Expected runtime is upwards of 20mins depending on runner availability, |
| # which is why these are only run for releases. |
| name: Deploy |
| |
| on: |
| push: |
| tags: ['v*'] |
| workflow_dispatch: |
| inputs: |
| pre-release-suffix: |
| description: 'Version suffix for pre-releases ("a", "b", "rc", etc.)' |
| required: false |
| default: 'dev' |
| pre-release-version: |
| description: 'Version number for pre-releases; defaults to build number' |
| required: false |
| default: '' |
| skip-stress: |
| description: 'Set to "true" to skip stress tests' |
| required: false |
| default: 'false' |
| skip-publish: |
| description: 'Set to "true" to skip publishing to PyPI' |
| required: false |
| default: 'false' |
| |
| env: |
| LATEST_PY_VERSION: '3.14' |
| PYTEST_VERBOSE: 'true' |
| STRESS_TEST_MULTIPLIER: 7 |
| |
| jobs: |
| # Run additional integration stress tests |
| test-stress: |
| if: ${{ github.event.inputs.skip-stress != 'true' }} |
| runs-on: ubuntu-latest |
| |
| services: |
| nginx: |
| image: mccutchen/go-httpbin |
| ports: |
| - 8080:8080 |
| |
| steps: |
| # Install dependencies, with caching |
| - uses: actions/checkout@v7 |
| - uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0 |
| with: |
| enable-cache: true |
| cache-dependency-glob: uv.lock |
| - name: Install dependencies |
| run: | |
| uv python install ${{ env.LATEST_PY_VERSION }} |
| uv sync --all-extras |
| |
| # Start integration test databases |
| - uses: supercharge/mongodb-github-action@315db7fe45ac2880b7758f1933e6e5d59afd5e94 # 1.12.1 |
| with: |
| mongodb-version: 8 |
| - uses: supercharge/redis-github-action@bc274cb7238cd63a45029db04ee48c07a72609fd # 1.8.1 |
| with: |
| redis-version: 7 |
| - uses: rrainn/dynamodb-action@36eaff1005b37a22258716d4280f9e0377b834aa # v4.0.0 |
| |
| # Run tests |
| - name: Run stress tests |
| run: uv run nox -e stress -- ${{ env.STRESS_TEST_MULTIPLIER }} |
| |
| # Run unit tests without any optional dependencies installed |
| test-minimum-deps: |
| runs-on: ubuntu-latest |
| |
| steps: |
| # Install dependencies |
| - uses: actions/checkout@v7 |
| - uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0 |
| - name: Install dependencies |
| run: | |
| uv python install ${{ env.LATEST_PY_VERSION }} |
| uv sync |
| |
| # Run tests |
| - name: Run tests with no optional dependencies |
| run: uv run pytest -n auto tests/unit |
| |
| # Run unit tests for all supported platforms and python versions |
| # On python latest python, run tests for all supported requests versions |
| test: |
| strategy: |
| matrix: |
| os: [ubuntu-latest, macos-latest, windows-latest] |
| python-version: |
| [ |
| '3.15', |
| '3.14', |
| '3.13', |
| '3.12', |
| '3.11', |
| '3.10', |
| '3.9', |
| '3.8', |
| 'pypy3.11', |
| 'pypy3.10', |
| ] |
| requests-version: [latest] |
| exclude: |
| - os: windows-latest |
| python-version: 'pypy3.10' |
| - os: windows-latest |
| python-version: 'pypy3.11' |
| # TODO: Could this be less verbose? Maybe a dynamic matrix? Also, env isn't supported here. |
| include: |
| - python-version: '3.14' |
| os: ubuntu-latest |
| requests-version: '2.22' |
| - python-version: '3.14' |
| os: ubuntu-latest |
| requests-version: '2.23' |
| - python-version: '3.14' |
| os: ubuntu-latest |
| requests-version: '2.24' |
| - python-version: '3.14' |
| os: ubuntu-latest |
| requests-version: '2.25' |
| - python-version: '3.14' |
| os: ubuntu-latest |
| requests-version: '2.26' |
| - python-version: '3.14' |
| os: ubuntu-latest |
| requests-version: '2.27' |
| - python-version: '3.14' |
| os: ubuntu-latest |
| requests-version: '2.28' |
| - python-version: '3.14' |
| os: ubuntu-latest |
| requests-version: '2.29' |
| - python-version: '3.14' |
| os: ubuntu-latest |
| requests-version: '2.30' |
| - python-version: '3.14' |
| os: ubuntu-latest |
| requests-version: '2.31' |
| - python-version: '3.14' |
| os: ubuntu-latest |
| requests-version: '2.32' |
| - python-version: '3.14' |
| os: ubuntu-latest |
| requests-version: '2.33' |
| fail-fast: false |
| defaults: |
| run: |
| shell: bash |
| runs-on: ${{ matrix.os }} |
| |
| steps: |
| # Install dependencies, with caching |
| - uses: actions/checkout@v7 |
| - uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0 |
| with: |
| enable-cache: true |
| cache-dependency-glob: uv.lock |
| - name: Install dependencies |
| run: | |
| uv python install ${{ matrix.python-version }} |
| uv sync --all-extras |
| if [[ "${{ matrix.requests-version }}" != "latest" ]]; then |
| uv pip install requests==${{ matrix.requests-version }}; |
| fi |
| |
| # Run tests |
| - name: Run tests |
| run: uv run pytest -n auto tests/unit |
| |
| # Deploy stable builds on tags only, and pre-release builds from manual trigger ("workflow_dispatch") |
| release: |
| if: ${{ github.event.inputs.skip-publish != 'true' }} |
| needs: [test, test-minimum-deps] |
| runs-on: ubuntu-latest |
| permissions: |
| id-token: write |
| steps: |
| - uses: actions/checkout@v7 |
| - uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0 |
| |
| - name: Set pre-release version |
| if: ${{ !startsWith(github.ref, 'refs/tags/v') }} |
| env: |
| pre-release-suffix: ${{ github.event.inputs.pre-release-suffix || 'dev' }} |
| pre-release-version: ${{ github.event.inputs.pre-release-version || github.run_number }} |
| run: | |
| PKG_VERSION=$(uvx --from=toml-cli toml get --toml-path=pyproject.toml project.version) |
| DEV_VERSION=$PKG_VERSION.${{ env.pre-release-suffix }}${{ env.pre-release-version }} |
| echo "Setting pre-release version to $DEV_VERSION" |
| uvx --from=toml-cli toml set --toml-path=pyproject.toml project.version $DEV_VERSION |
| |
| - name: Build package distributions |
| run: uv build |
| - name: Publish package distributions to PyPI |
| uses: pypa/gh-action-pypi-publish@release/v1 |