|
1 | 1 | name: Test |
2 | 2 |
|
| 3 | +permissions: |
| 4 | + contents: read |
| 5 | + |
3 | 6 | on: |
4 | 7 | push: |
5 | 8 | branches: |
6 | 9 | - main |
7 | 10 | pull_request: |
8 | 11 | types: [opened, synchronize, reopened] |
9 | 12 |
|
| 13 | + |
| 14 | +env: |
| 15 | + UV_VERSION: 0.7.5 |
| 16 | + |
10 | 17 | jobs: |
11 | | - tox: |
| 18 | + lint: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + strategy: |
| 21 | + matrix: |
| 22 | + linter: |
| 23 | + - mypy |
| 24 | + - ruff |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v4 |
| 27 | + - name: Install uv |
| 28 | + uses: astral-sh/setup-uv@v6 |
| 29 | + with: |
| 30 | + version: "${{ env.UV_VERSION }}" |
| 31 | + enable-cache: true |
| 32 | + - name: Set up Python 3.12 |
| 33 | + uses: actions/setup-python@v5 |
| 34 | + with: |
| 35 | + python-version: '3.12' |
| 36 | + - name: Install the project |
| 37 | + run: uv sync --locked --all-extras --all-groups |
| 38 | + - name: Run ruff lint check |
| 39 | + if: matrix.linter == 'ruff' |
| 40 | + run: uv run ruff check openapi_pydantic tests |
| 41 | + - name: Run ruff format check |
| 42 | + if: matrix.linter == 'ruff' |
| 43 | + run: uv run ruff format --check openapi_pydantic tests |
| 44 | + - name: Run Mypy Check |
| 45 | + if: matrix.linter == 'mypy' |
| 46 | + run: uv run mypy openapi_pydantic tests |
| 47 | + |
| 48 | + test: |
12 | 49 | runs-on: ubuntu-latest |
| 50 | + permissions: |
| 51 | + contents: write |
13 | 52 | strategy: |
14 | 53 | matrix: |
15 | | - python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] |
| 54 | + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13'] |
| 55 | + pydantic-version: ['pydantic-v1', 'pydantic-v2'] |
| 56 | + fail-fast: false |
16 | 57 | steps: |
17 | 58 | - uses: actions/checkout@v4 |
| 59 | + - name: Install uv |
| 60 | + uses: astral-sh/setup-uv@v5 |
| 61 | + with: |
| 62 | + version: "${{ env.UV_VERSION }}" |
| 63 | + enable-cache: true |
18 | 64 | - name: Set up Python ${{ matrix.python-version }} |
19 | 65 | uses: actions/setup-python@v5 |
20 | 66 | with: |
21 | 67 | python-version: ${{ matrix.python-version }} |
22 | | - - name: Install dependencies |
23 | | - run: | |
24 | | - python -m pip install --upgrade pip |
25 | | - python -m pip install tox tox-gh-actions |
26 | | - - name: Install Poetry |
27 | | - uses: snok/install-poetry@v1 |
| 68 | + - name: Install the project |
| 69 | + run: uv sync --locked --all-extras --group test |
| 70 | + - name: Install Pydantic v1 |
| 71 | + if: matrix.pydantic-version == 'pydantic-v1' |
| 72 | + run: uv add "pydantic>=1.10.0,<2.0.0" --upgrade-package pydantic |
| 73 | + - name: Install Pydantic v2 |
| 74 | + if: matrix.pydantic-version == 'pydantic-v2' |
| 75 | + run: uv add "pydantic>=2.0.2,<3.0.0" --upgrade-package pydantic |
| 76 | + - run: mkdir coverage |
| 77 | + - name: Test |
| 78 | + run: uv run coverage run -m pytest -vv tests |
| 79 | + env: |
| 80 | + COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }} |
| 81 | + CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }} |
| 82 | + - name: Store coverage files |
| 83 | + uses: actions/upload-artifact@v4 |
28 | 84 | with: |
29 | | - version: 1.8.3 |
30 | | - virtualenvs-create: true |
31 | | - virtualenvs-in-project: true |
32 | | - - name: Run tox test suite |
33 | | - run: tox |
| 85 | + name: coverage-${{ matrix.python-version }}-${{ matrix.pydantic-version }} |
| 86 | + path: coverage |
| 87 | + include-hidden-files: true |
| 88 | + |
| 89 | + |
| 90 | + coverage: |
| 91 | + needs: [test] |
| 92 | + runs-on: ubuntu-latest |
| 93 | + permissions: |
| 94 | + contents: write |
| 95 | + steps: |
| 96 | + - uses: actions/checkout@v4 |
| 97 | + - uses: actions/setup-python@v5 |
| 98 | + with: |
| 99 | + python-version: '3.12' |
| 100 | + - name: Install uv |
| 101 | + uses: astral-sh/setup-uv@v5 |
| 102 | + with: |
| 103 | + version: "${{ env.UV_VERSION }}" |
| 104 | + enable-cache: true |
| 105 | + - name: Install Dependencies |
| 106 | + run: uv sync --locked --all-extras --group test |
| 107 | + - name: Get coverage files |
| 108 | + uses: actions/download-artifact@v4 |
| 109 | + with: |
| 110 | + pattern: coverage-* |
| 111 | + path: coverage |
| 112 | + merge-multiple: true |
| 113 | + - run: ls -la coverage |
| 114 | + - run: uv run coverage combine coverage |
| 115 | + - run: uv run coverage report |
| 116 | + - run: uv run coverage html --title "Coverage for ${{ github.sha }}" |
| 117 | + - name: Store coverage HTML |
| 118 | + uses: actions/upload-artifact@v4 |
| 119 | + with: |
| 120 | + name: coverage-html |
| 121 | + path: htmlcov |
| 122 | + include-hidden-files: true |
0 commit comments