Updated version (#226) #152
This file contains hidden or 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: Run Checks | |
on: | |
push: | |
branches: [ "prod/2.x" ] | |
pull_request: | |
branches: [ "prod/2.x" ] | |
merge_group: | |
jobs: | |
test: | |
strategy: | |
matrix: | |
python: [ "3.9", "3.10", "3.11", "3.12", "3.13" ] | |
os: [ ubuntu-latest, macos-latest, windows-latest ] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4.2.2 | |
- name: Set up Python | |
uses: actions/setup-python@v5.3.0 | |
with: | |
python-version: ${{ matrix.python }} | |
- name: Get Python Version | |
id: get_python_version | |
run: echo "python_version=$(python --version)" >> $GITHUB_OUTPUT | |
shell: bash | |
- name: Cache dependencies | |
uses: actions/cache@v4 | |
with: | |
path: .venv | |
key: ${{ runner.os }}-${{ steps.get_python_version.outputs.python_version }}-dependencies-${{ hashFiles('**/poetry.lock') }} | |
restore-keys: | | |
${{ runner.os }}-${{ steps.get_python_version.outputs.python_version }}-dependencies | |
- name: Install Poetry | |
run: pip install poetry | |
- name: Install Dependencies | |
run: poetry install | |
- name: Check formatting | |
run: poetry run ruff format . --check | |
- name: Run mypy | |
run: poetry run task mypy --show-error-codes | |
- name: Lint | |
run: poetry run ruff check . | |
- name: Run pytest without coverage | |
if: matrix.os != 'ubuntu-latest' | |
run: poetry run task test | |
env: | |
TASKIPY: true | |
- name: Run pytest with coverage | |
if: matrix.os == 'ubuntu-latest' | |
run: poetry run task test_with_coverage | |
env: | |
TASKIPY: true | |
- run: mv .coverage .coverage.${{ matrix.python }} | |
if: matrix.os == 'ubuntu-latest' | |
- name: Store coverage report | |
uses: actions/upload-artifact@v4.4.3 | |
if: matrix.os == 'ubuntu-latest' | |
with: | |
name: coverage-${{ matrix.python }} | |
path: .coverage.${{ matrix.python }} | |
if-no-files-found: error | |
include-hidden-files: true | |
coverage: | |
name: Combine & check coverage | |
needs: test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4.2.2 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12" | |
- name: Download coverage reports | |
uses: actions/download-artifact@v4.1.8 | |
with: | |
merge-multiple: true | |
- name: Create Virtual Environment | |
run: python -m venv .venv | |
- name: Combine coverage & fail if it's <100%. | |
run: | | |
# Install coverage | |
.venv/bin/pip install --upgrade coverage[toml] | |
# Find all of the downloaded coverage reports and combine them | |
.venv/bin/python -m coverage combine | |
# Create html report | |
.venv/bin/python -m coverage html --skip-covered --skip-empty | |
# Report in Markdown and write to summary. | |
.venv/bin/python -m coverage report --format=markdown >> $GITHUB_STEP_SUMMARY | |
# Report again and fail if under 100%. | |
.venv/bin/python -m coverage report --fail-under=100 | |
- name: Upload HTML report if check failed. | |
uses: actions/upload-artifact@v4.4.3 | |
with: | |
name: html-report | |
path: htmlcov | |
if: ${{ failure() }} | |
integration: | |
name: Integration Tests | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
httpx_version: | |
- "0.20.0" | |
- "" | |
services: | |
openapi-test-server: | |
image: ghcr.io/openapi-generators/openapi-test-server:0.0.1 | |
ports: | |
- "3000:3000" | |
steps: | |
- uses: actions/checkout@v4.2.2 | |
- name: Set up Python | |
uses: actions/setup-python@v5.3.0 | |
with: | |
python-version: "3.9" | |
- name: Get Python Version | |
id: get_python_version | |
run: echo "python_version=$(python --version)" >> $GITHUB_OUTPUT | |
- name: Cache dependencies | |
uses: actions/cache@v4 | |
with: | |
path: .venv | |
key: ${{ runner.os }}-${{ steps.get_python_version.outputs.python_version }}-dependencies-${{ hashFiles('**/poetry.lock') }} | |
restore-keys: | | |
${{ runner.os }}-${{ steps.get_python_version.outputs.python_version }}-dependencies | |
# General note on this job: the main project uses poetry, but the project inside integration-tests/ | |
# uses pdm. That's because integration-tests/ is a generated client-- the output from running the | |
# generator on a test API spec-- and the "make a pdm project" option was used in that process. | |
- name: Install dependencies | |
run: | | |
pip install poetry | |
pip install pdm | |
python -m venv .venv | |
poetry install | |
- name: Cache Generated Client Dependencies | |
uses: actions/cache@v4 | |
with: | |
path: integration-tests/.venv | |
key: ${{ runner.os }}-${{ steps.get_python_version.outputs.python_version }}-integration-dependencies-${{ hashFiles('**/poetry.lock') }} | |
restore-keys: | | |
${{ runner.os }}-${{ steps.get_python_version.outputs.python_version }}-integration-dependencies | |
- name: Set httpx version | |
if: matrix.httpx_version != '' | |
run: | | |
cd integration-tests | |
pdm add httpx==${{ matrix.httpx_version }} | |
- name: Install Integration Dependencies | |
run: | | |
cd integration-tests | |
pdm install | |
- name: Run Tests | |
run: | | |
cd integration-tests | |
pdm run pytest | |
pdm run mypy . --strict |