@@ -11,116 +11,195 @@ jobs:
1111 test :
1212 strategy :
1313 matrix :
14- python : [ "3.8 ", "3.9 ", "3.10 ", "3.11 " ]
14+ python : [ "3.9 ", "3.10 ", "3.11 ", "3.12", "3.13 " ]
1515 os : [ ubuntu-latest, macos-latest, windows-latest ]
1616 runs-on : ${{ matrix.os }}
1717 steps :
18- - uses : actions/checkout@v3
18+ - uses : actions/checkout@v4.2.2
1919 - name : Set up Python
20- uses : actions/setup-python@v4
20+ uses : actions/setup-python@v5.3.0
2121 with :
2222 python-version : ${{ matrix.python }}
2323
2424 - name : Get Python Version
2525 id : get_python_version
2626 run : echo "python_version=$(python --version)" >> $GITHUB_OUTPUT
27+ shell : bash
2728
2829 - name : Cache dependencies
29- uses : actions/cache@v3
30+ uses : actions/cache@v4
3031 with :
3132 path : .venv
32- key : ${{ runner.os }}-${{ steps.get_python_version.outputs.python_version }}-dependencies-${{ hashFiles('**/poetry .lock') }}
33+ key : ${{ runner.os }}-${{ steps.get_python_version.outputs.python_version }}-dependencies-${{ hashFiles('**/pdm .lock') }}
3334 restore-keys : |
3435 ${{ runner.os }}-${{ steps.get_python_version.outputs.python_version }}-dependencies
35- - name : Install Poetry
36- run : pip install poetry
36+ - name : Install PDM
37+ run : pip install pdm
3738
38- - name : Create Virtual Environment
39- run : python -m venv .venv
39+ - name : Install Dependencies
40+ run : pdm install
4041
41- - name : Upgrade pip
42- run : poetry run python -m pip install --upgrade pip
42+ - name : Check formatting
43+ run : pdm run ruff format . --check
4344
44- - name : Install Dependencies
45- run : poetry install
45+ - name : Run mypy
46+ run : pdm mypy --show-error-codes
4647
47- - name : Run Black
48- run : poetry run black . -- check
48+ - name : Lint
49+ run : pdm run ruff check .
4950
50- - name : Run isort
51- run : poetry run isort . --check
51+ - name : Run pytest without coverage
52+ if : matrix.os != 'ubuntu-latest'
53+ run : pdm test
5254
53- - name : Run safety
54- run : poetry export -f requirements.txt | poetry run safety check --bare --stdin
55+ - name : Run pytest with coverage
56+ if : matrix.os == 'ubuntu-latest'
57+ run : pdm test_with_coverage
5558
56- - name : Run mypy
57- run : poetry run mypy --show-error-codes openapi_python_client
59+ - run : mv .coverage .coverage.${{ matrix.python }}
60+ if : matrix.os == 'ubuntu-latest'
5861
59- - name : Run pylint
60- run : poetry run pylint openapi_python_client
62+ - name : Store coverage report
63+ 64+ if : matrix.os == 'ubuntu-latest'
65+ with :
66+ name : coverage-${{ matrix.python }}
67+ path : .coverage.${{ matrix.python }}
68+ if-no-files-found : error
69+ include-hidden-files : true
6170
62- - name : Run pytest
63- run : poetry run pytest --cov=openapi_python_client --cov-report=term-missing tests end_to_end_tests/test_end_to_end.py --basetemp=tests/tmp
64- env :
65- TASKIPY : true
71+ test_min_deps :
72+ strategy :
73+ matrix :
74+ os : [ ubuntu-latest, macos-latest, windows-latest ]
75+ runs-on : ${{ matrix.os }}
76+ steps :
77+ 78+ - name : Set up Python
79+ 80+ with :
81+ python-version : " 3.9"
6682
67- - name : Generate coverage report
83+ - name : Get Python Version
84+ id : get_python_version
85+ run : echo "python_version=$(python --version)" >> $GITHUB_OUTPUT
6886 shell : bash
69- run : poetry run coverage xml
7087
71- - uses : codecov/codecov-action@v3
88+ - name : Cache dependencies
89+ uses : actions/cache@v4
90+ with :
91+ path : .venv
92+ key : ${{ runner.os }}-${{ steps.get_python_version.outputs.python_version }}-min-dependencies-${{ hashFiles('**/pdm.lock') }}
93+ restore-keys : |
94+ ${{ runner.os }}-${{ steps.get_python_version.outputs.python_version }}-min-dependencies
95+ - name : Install PDM
96+ run : pip install pdm
97+
98+ - name : Install minimum dependencies
99+ run : pdm install -L pdm.minimal.lock
100+
101+ - name : Run mypy
102+ run : pdm mypy --show-error-codes
103+
104+ - name : Lint
105+ run : pdm run ruff check .
106+
107+ - name : Run unit tests only # snapshots are expected to fail
108+ run : pdm unit_test
109+
110+ coverage :
111+ name : Combine & check coverage
112+ needs : test
113+ runs-on : ubuntu-latest
114+ steps :
115+ 116+ - uses : actions/setup-python@v5
72117 with :
73- files : ./coverage.xml
118+ python-version : " 3.12"
119+ - name : Download coverage reports
120+ 121+ with :
122+ merge-multiple : true
123+
124+ - name : Create Virtual Environment
125+ run : python -m venv .venv
126+
127+ - name : Combine coverage & fail if it's <100%.
128+ run : |
129+ # Install coverage
130+ .venv/bin/pip install --upgrade coverage[toml]
131+
132+ # Find all of the downloaded coverage reports and combine them
133+ .venv/bin/python -m coverage combine
134+
135+ # Create html report
136+ .venv/bin/python -m coverage html --skip-covered --skip-empty
137+
138+ # Report in Markdown and write to summary.
139+ .venv/bin/python -m coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
140+
141+ # Report again and fail if under 100%.
142+ .venv/bin/python -m coverage report --fail-under=100
143+
144+ - name : Upload HTML report if check failed.
145+ 146+ with :
147+ name : html-report
148+ path : htmlcov
149+ if : ${{ failure() }}
74150
75151 integration :
76152 name : Integration Tests
77153 runs-on : ubuntu-latest
154+ strategy :
155+ matrix :
156+ httpx_version :
157+ - " 0.20.0"
158+ - " "
78159 services :
79160 openapi-test-server :
80161 image : ghcr.io/openapi-generators/openapi-test-server:0.0.1
81162 ports :
82163 - " 3000:3000"
83164 steps :
84- - uses : actions/checkout@v3
165+ - uses : actions/checkout@v4.2.2
85166 - name : Set up Python
86- uses : actions/setup-python@v4
167+ uses : actions/setup-python@v5.3.0
87168 with :
88- python-version : " 3.10 "
169+ python-version : " 3.9 "
89170 - name : Get Python Version
90171 id : get_python_version
91172 run : echo "python_version=$(python --version)" >> $GITHUB_OUTPUT
92173 - name : Cache dependencies
93- uses : actions/cache@v3
174+ uses : actions/cache@v4
94175 with :
95176 path : .venv
96- key : ${{ runner.os }}-${{ steps.get_python_version.outputs.python_version }}-dependencies-${{ hashFiles('**/poetry .lock') }}
177+ key : ${{ runner.os }}-${{ steps.get_python_version.outputs.python_version }}-dependencies-${{ hashFiles('**/pdm .lock') }}
97178 restore-keys : |
98179 ${{ runner.os }}-${{ steps.get_python_version.outputs.python_version }}-dependencies
99180 - name : Install dependencies
100181 run : |
101- pip install poetry
182+ pip install pdm
102183 python -m venv .venv
103- poetry run python -m pip install --upgrade pip
104- poetry install
105- - name : Regenerate Integration Client
106- run : |
107- poetry run openapi-python-client update --url http://localhost:3000/openapi.json --config integration-tests-config.yaml
108- - name : Check for any file changes
109- run : python .github/check_for_changes.py
184+ pdm install
110185 - name : Cache Generated Client Dependencies
111- uses : actions/cache@v3
186+ uses : actions/cache@v4
112187 with :
113188 path : integration-tests/.venv
114- key : ${{ runner.os }}-${{ steps.get_python_version.outputs.python_version }}-integration-dependencies-${{ hashFiles('**/poetry .lock') }}
189+ key : ${{ runner.os }}-${{ steps.get_python_version.outputs.python_version }}-integration-dependencies-${{ hashFiles('**/pdm .lock') }}
115190 restore-keys : |
116191 ${{ runner.os }}-${{ steps.get_python_version.outputs.python_version }}-integration-dependencies
192+ - name : Set httpx version
193+ if : matrix.httpx_version != ''
194+ run : |
195+ cd integration-tests
196+ pdm add httpx==${{ matrix.httpx_version }}
117197 - name : Install Integration Dependencies
118198 run : |
119199 cd integration-tests
120- python -m venv .venv
121- poetry run python -m pip install --upgrade pip
122- poetry install
200+ pdm install
123201 - name : Run Tests
124202 run : |
125203 cd integration-tests
126- poetry run pytest
204+ pdm run pytest
205+ pdm run mypy . --strict
0 commit comments