Skip to content

Commit c668507

Browse files
authored
[NEW] Python Generator v2.5.1
Uv migration - Release v2.5.1
2 parents d85a3c5 + 6133b7e commit c668507

File tree

128 files changed

+5555
-1179
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+5555
-1179
lines changed

.github/labeler.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,13 @@ docker:
9999
- '.dockerignore'
100100

101101
### POETRY ###
102-
poetry:
102+
pyproject:
103103
- any:
104104
- changed-files:
105105
- any-glob-to-any-file:
106106
- 'pyproject.toml'
107107
- 'poetry.lock'
108+
- 'uv.lock'
108109

109110
### TOX ###
110111
tox:

.github/workflows/ci.yml

Lines changed: 245 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,245 @@
1+
# CI Pipeline
2+
3+
# For Test Suite this pipeline aims for speed
4+
# so for feature branches test is in edit mode
5+
# for 'high' branches (ie dev) runs sdist/wheel tests
6+
7+
name: CI Pipeline
8+
# primarily serves as quick feedback on every push
9+
# on feature-branches, should be as quick as possible
10+
# runs only tests, type check, docs build dynamically based on changes
11+
12+
on:
13+
push:
14+
branches:
15+
- '*'
16+
# except main, dev, release, branches
17+
- '!main'
18+
- '!dev'
19+
- '!release'
20+
- '!try-ci'
21+
22+
jobs:
23+
24+
### FASTER JOBS ###
25+
26+
# INSTALL PACKAGE in Edit mode and run Test Suite against it
27+
code: ## Unless override, default trigger 'always'
28+
uses: ./.github/workflows/test-python.yml
29+
with:
30+
default_trigger: true
31+
override: '${{ vars.OV_TEST_UNIT }}'
32+
installation_mode: 'edit'
33+
python_version: '3.10'
34+
platform: 'ubuntu-latest'
35+
36+
# Build PACKAGE SDist and run Test Suite against it
37+
sdist: ## Unless override, default trigger 'always'
38+
uses: ./.github/workflows/test-python.yml
39+
with:
40+
default_trigger: false
41+
override: '${{ vars.OV_SDIST }}'
42+
installation_mode: 'sdist'
43+
python_version: '3.10'
44+
platform: 'ubuntu-latest'
45+
46+
# BUILD PACKAGE Wheel and run Tests Suite against it
47+
wheel: ## Unless override, default trigger 'always'
48+
uses: ./.github/workflows/test-python.yml
49+
with:
50+
default_trigger: true
51+
override: '${{ vars.OV_WHEEL }}'
52+
installation_mode: 'wheel'
53+
upload_distro: true
54+
python_version: '3.10'
55+
platform: 'ubuntu-latest'
56+
57+
# BUILD ALL WHEELS and run Test Suite against them
58+
## Unless override, default trigger 'always'
59+
all_wheels:
60+
if: vars.OV_ALL_WHEELS != 'false' # Unless override, default trigger 'always'
61+
runs-on: ubuntu-latest
62+
env:
63+
module_name: cookiecutter_python
64+
# assuming project "declares" 1 python module (in the package)
65+
# assuming a pure-python package is being built (otherwise needs platform-specific path)!
66+
WHEEL_FILE: 'cookiecutter_python-*.whl'
67+
steps:
68+
- name: Set up Python 3.10
69+
uses: actions/setup-python@v5
70+
with:
71+
python-version: '3.10'
72+
73+
- name: Install the latest version of uv
74+
uses: astral-sh/setup-uv@v5
75+
with:
76+
version: "latest"
77+
78+
- uses: actions/checkout@v4
79+
80+
## Build Wheel Distribution ##
81+
- name: 'Build Wheel Distribution for Package and its Dependencies'
82+
run: 'pip wheel --wheel-dir dist .'
83+
84+
# --find-links dist --use-feature=fast-deps --use-feature=2020-resolver
85+
86+
# run: uv build --wheel --all-packages --out-dir dist
87+
88+
- run: mkdir module_wheel/
89+
- run: mv dist/${{ env.WHEEL_FILE }} module_wheel/
90+
91+
- run: uv venv
92+
93+
- run: uv pip install --no-deps dist/*.whl
94+
# - run: uv pip install --no-deps $(ls dist/*.whl)
95+
# - run: find dist -name "*.whl" -print0 | xargs -0 uv pip install --no-deps
96+
97+
# here we need to manually extract the wheel file path, asserting there is only 1
98+
- name: Extract Module Wheel file path
99+
id: module_wheel_path
100+
run: echo "module_wheel_path=$(ls module_wheel/*.whl)" >> $GITHUB_OUTPUT
101+
102+
- name: Install module wheel and download test extras from pypi
103+
run: uv pip install "${{ steps.module_wheel_path.outputs.module_wheel_path }}[test]"
104+
105+
# TODO: use pinned test deps, instead of "rolling" the test deps as done above
106+
107+
# Install Prod Wheels
108+
# - name: 'Install "Prod Wheels and leverage "extras" to install test deps'
109+
# run: uv pip install --no-deps "dist/*.whl[test]"
110+
111+
# Run tests
112+
- name: 'Run tests'
113+
run: uv run pytest -ra -n auto
114+
115+
# STATIC CODE ANALYSIS: mypy, ruff, isort, black, bandit, mccabe, prospector, etc
116+
## Unless override, default trigger is (only) on PR to dev
117+
sca:
118+
# Unless override, default trigger is (only) on PR to dev
119+
if: always() || vars.OV_SCA == 'true' || (vars.OV_SCA != 'false' && github.event_name == 'pull_request' && github.base_ref == 'dev')
120+
uses: ./.github/workflows/sca-job.yml
121+
with:
122+
python_version: '3.10'
123+
allow_failure: ${{ github.event_name != 'pull_request' || github.base_ref != 'dev' }}
124+
force_styles: ${{ github.event_name == 'pull_request' && github.base_ref == 'dev' }}
125+
bandit: '{"h": 1, "m": 2, "l": 4}' # Automated Acceptance Criteria for Bandit
126+
127+
# RUN INTEGRATION TESTS: slower due to automated installations involved via pip
128+
## Unless override, default trigger is (only) on PR to dev
129+
test_integration:
130+
if: always() || vars.OV_TEST_INTEGRATION == 'true' || (vars.OV_SCA != 'false' && github.event_name == 'pull_request' && github.base_ref == 'dev')
131+
runs-on: ubuntu-latest
132+
steps:
133+
- uses: actions/checkout@v4
134+
- name: Set up Python 3.10
135+
uses: actions/setup-python@v5
136+
with:
137+
python-version: '3.10'
138+
139+
# Install uv to manage pinned versions
140+
- name: Install the latest version of uv
141+
uses: astral-sh/setup-uv@v5
142+
with:
143+
version: "latest"
144+
145+
# Export "pinned" (exact) dependencies' versions in requirements.txt format
146+
- name: 'Export pinned Prod + Test dependencies'
147+
run: uv export --no-emit-project --no-dev --extra test --frozen --format requirements-txt -o requirements.txt
148+
149+
- run: uv venv
150+
151+
# Install dependencies in virtualenv
152+
- name: 'Install "Prod + Test" dependencies'
153+
run: uv pip install -r requirements.txt
154+
155+
# here the .venv is built with the exact dependencies
156+
157+
# Install Package (without dependencies)
158+
- name: 'Install Package without dependencies'
159+
run: uv pip install --no-deps -e .
160+
161+
# Run Integration tests
162+
- name: 'Run Integration tests'
163+
run: |
164+
# leverage uv to install other runtime test dependencies in the system site-packages!
165+
166+
uv pip install 'tox<4.0' # integration tests dependency
167+
168+
# Isolate flaky tests
169+
uv run pytest -ra -vvs --run-slow -k via_build_module
170+
uv run pytest -ra -vvs --run-slow -k test_build_creates_artifacts
171+
172+
# Run eveything once again for sanity
173+
uv run pytest -ra -n auto --run-requires_uv --run-slow --run-network_bound -vvs -k 'test_cli or build_backend_sdist or test_build_creates_artifacts or test_lint_passes'
174+
175+
# CROSS PLATFORM TESTING: 15s on Ubuntu, 25 on mac, 35 on windows
176+
## Unless override, default trigger is (only) on PR to dev
177+
sample_matrix_test:
178+
if: vars.OV_MATRIX_TEST == 'true' || (vars.OV_MATRIX_TEST != 'false' && github.event_name == 'pull_request' && github.base_ref == 'dev')
179+
runs-on: ${{ matrix.platform }}
180+
# trigger if event is pr to dev
181+
strategy:
182+
fail-fast: false
183+
matrix:
184+
platform: [ubuntu-latest, macos-latest, windows-latest]
185+
# platform: [windows-latest]
186+
python-version: ['3.10']
187+
steps:
188+
- name: Set up Python ${{ matrix.python-version }}
189+
uses: actions/setup-python@v5
190+
with:
191+
python-version: ${{ matrix.python-version }}
192+
193+
- name: Install uv
194+
if: matrix.platform != 'windows-latest'
195+
run: curl -LsSf https://astral.sh/uv/install.sh | sh
196+
197+
- name: Install the latest version of uv
198+
if: matrix.platform == 'windows-latest'
199+
uses: astral-sh/setup-uv@v5
200+
with:
201+
version: "latest"
202+
203+
- uses: actions/checkout@v4
204+
205+
# Build Package Wheel
206+
- run: uv build --wheel --out-dir dist
207+
208+
# Install exact Prod + Test dependencies
209+
- name: 'Export pinned Prod + Test dependencies'
210+
run: uv export --no-emit-project --no-dev --extra test --frozen --format requirements-txt -o requirements.txt
211+
212+
- name: Install dependencies
213+
run: |
214+
uv venv
215+
uv pip install --no-deps -r requirements.txt
216+
217+
# Install the Package Wheel
218+
- name: Install our Package Wheel
219+
shell: bash
220+
run: uv pip install --no-deps dist/*.whl
221+
222+
# Run tests
223+
- name: Run tests
224+
shell: bash
225+
env:
226+
# log deletion post hook fails on windows, due to permission error! (other process is using the file, so removing is denied)
227+
# windows spawn multiple processes, so log deletion is not possible, even when running 1 Single Unit Test
228+
BUG_LOG_DEL_WIN: 'permission_error' # required on Windows Job
229+
PY_WHEEL: 1 # required on Windows Job
230+
run: |
231+
if [[ "${{ matrix.platform }}" == "windows-latest" ]]; then
232+
echo "[INFO] Activating virtual environment for Windows"
233+
. .venv/Scripts/activate
234+
else
235+
# Linux and MacOS
236+
echo "[INFO] Activating virtual environment for Linux/MacOS"
237+
. .venv/bin/activate
238+
fi
239+
pytest -ra --run-requires_uv --run-network_bound -vvs -k 'context_with_expected_values[gold_standard]'
240+
241+
## PYDEPS
242+
243+
## TYPE CHECK
244+
245+
## DOCS

0 commit comments

Comments
 (0)