eng: fix up project configuration - BNCH-112051 #131
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: 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/[email protected] | |
- name: Set up Python | |
uses: actions/[email protected] | |
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/[email protected] | |
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/[email protected] | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12" | |
- name: Download coverage reports | |
uses: actions/[email protected] | |
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/[email protected] | |
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/[email protected] | |
- name: Set up Python | |
uses: actions/[email protected] | |
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 | |
- name: Install dependencies | |
run: | | |
pip install poetry | |
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 | |
poetry add httpx==${{ matrix.httpx_version }} | |
- name: Install Integration Dependencies | |
run: | | |
cd integration-tests | |
poetry install | |
- name: Run Tests | |
run: | | |
cd integration-tests | |
poetry run pytest | |
poetry run mypy . --strict |