name: Run Checks on: push: branches: [ "main" ] pull_request: branches: [ "main" ] 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.6.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('**/pdm.lock') }} restore-keys: | ${{ runner.os }}-${{ steps.get_python_version.outputs.python_version }}-dependencies - name: Install PDM run: pip install pdm - name: Install Dependencies run: pdm install - name: Check formatting run: pdm run ruff format . --check - name: Run mypy run: pdm mypy --show-error-codes - name: Lint run: pdm run ruff check . - name: Run pytest without coverage if: matrix.os != 'ubuntu-latest' run: pdm test - name: Run pytest with coverage if: matrix.os == 'ubuntu-latest' run: pdm test_with_coverage - run: mv .coverage .coverage.${{ matrix.python }} if: matrix.os == 'ubuntu-latest' - name: Store coverage report uses: actions/upload-artifact@v4.6.2 if: matrix.os == 'ubuntu-latest' with: name: coverage-${{ matrix.python }} path: .coverage.${{ matrix.python }} if-no-files-found: error include-hidden-files: true test_min_deps: strategy: matrix: 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.6.0 with: python-version: "3.9" - 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 }}-min-dependencies-${{ hashFiles('**/pdm.lock') }} restore-keys: | ${{ runner.os }}-${{ steps.get_python_version.outputs.python_version }}-min-dependencies - name: Install PDM run: pip install pdm - name: Install minimum dependencies run: pdm install -L pdm.minimal.lock - name: Run mypy run: pdm mypy --show-error-codes - name: Run unit tests only # snapshots are expected to fail run: pdm unit_test 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.3.0 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.6.2 with: name: html-report path: htmlcov if: ${{ failure() }} integration: name: Integration Tests runs-on: ubuntu-latest strategy: matrix: lockfile: - "pdm.lock" - "pdm.minimal.lock" services: openapi-test-server: image: ghcr.io/openapi-generators/openapi-test-server:0.2.1 ports: - "3000:3000" steps: - uses: actions/checkout@v4.2.2 - name: Set up Python uses: actions/setup-python@v5.6.0 with: python-version: "3.9" - name: Get Python Version id: get_python_version run: echo "python_version=$(python --version)" >> $GITHUB_OUTPUT - 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('integration-tests/pdm*.lock') }} restore-keys: | ${{ runner.os }}-${{ steps.get_python_version.outputs.python_version }}-integration-dependencies - name: Install Integration Dependencies run: | cd integration-tests pip install pdm pdm install -L ${{ matrix.lockfile }} - name: Run Tests run: | cd integration-tests pdm run pytest pdm run mypy . --strict