Feature: Allow setting a user agent directly #265
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
pull_request: | |
branches: | |
- main | |
- develop | |
concurrency: | |
group: test-${{ github.ref_name }} | |
cancel-in-progress: true | |
env: | |
PYTHONUNBUFFERED: "1" | |
FORCE_COLOR: "1" | |
jobs: | |
lint: | |
name: Lint | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
steps: | |
- | |
uses: actions/checkout@v4 | |
- | |
name: Set up Python 3.11 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
cache: 'pip' | |
- | |
name: Install Hatch | |
run: | | |
pip3 --quiet install --upgrade hatch uv | |
hatch --version | |
uv --version | |
- | |
name: Lint project | |
run: | | |
hatch fmt --check | |
- | |
name: Check project typing | |
run: | | |
hatch run typing:run | |
- | |
name: Check files with pre-commit | |
uses: pre-commit/[email protected] | |
test: | |
name: Test (Python ${{ matrix.python-version }}) | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
needs: | |
- lint | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: [ '3.9', '3.10', '3.11', '3.12', '3.13', 'pypy3.9', 'pypy3.10'] | |
steps: | |
- | |
uses: actions/checkout@v4 | |
- | |
name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
id: py-setup | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: 'pip' | |
- | |
name: Pull Docker images | |
run: | | |
docker compose --file tests/docker/docker-compose.ci-test.yml pull | |
- | |
name: Install Hatch | |
run: | | |
pip3 --quiet install --upgrade hatch uv | |
hatch --version | |
uv --version | |
- | |
name: Show environment | |
run: | | |
hatch test --show --python ${{ matrix.python-version }} | |
- | |
name: Run tests | |
run: | | |
hatch test --cover --junitxml=junit.xml -o junit_family=legacy --python ${{ matrix.python-version }} | |
- | |
name: Upload coverage to Codecov | |
if: matrix.python-version == '3.11' | |
uses: codecov/codecov-action@v5 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
- | |
name: Upload test results to Codecov | |
if: ${{ !cancelled() }} | |
uses: codecov/test-results-action@v1 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
flags: python-${{ matrix.python-version }} | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
needs: | |
- lint | |
steps: | |
- | |
uses: actions/checkout@v4 | |
- | |
name: Set up Python 3.11 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
cache: 'pip' | |
- | |
name: Install Hatch | |
run: | | |
pip3 --quiet install --upgrade hatch uv | |
hatch --version | |
uv --version | |
- | |
name: Build | |
run: | | |
hatch build --clean | |
- | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build-artifacts | |
path: dist/* | |
if-no-files-found: error | |
retention-days: 7 | |
create-release: | |
name: Release | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/tags/') | |
permissions: | |
contents: write | |
needs: | |
- build | |
- test | |
steps: | |
- | |
uses: actions/checkout@v4 | |
- | |
uses: actions/download-artifact@v4 | |
with: | |
name: build-artifacts | |
path: dist | |
- | |
name: Get latest release info | |
id: query-release-info | |
uses: release-flow/keep-a-changelog-action@v3 | |
with: | |
command: query | |
version: ${{ github.ref_name }} | |
- | |
name: Display release info | |
run: | | |
echo "Version: ${{ steps.query-release-info.outputs.version }}" | |
echo "Date: ${{ steps.query-release-info.outputs.release-date }}" | |
echo "${{ steps.query-release-info.outputs.release-notes }}" | |
- | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: "dist/*.tar.gz,dist/*.whl" | |
body: ${{ steps.query-release-info.outputs.release-notes }} | |
pypi-publish: | |
name: Publish | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/tags/') | |
permissions: | |
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing | |
needs: | |
- build | |
- test | |
steps: | |
- | |
uses: actions/download-artifact@v4 | |
with: | |
name: build-artifacts | |
path: dist | |
- | |
name: Publish build to PyPI | |
uses: pypa/[email protected] |