Skip to content

Commit 394d82b

Browse files
fix: use cookiecutter max_python_version in GitHub Actions workflows
1 parent 404d59f commit 394d82b

File tree

4 files changed

+34
-12
lines changed

4 files changed

+34
-12
lines changed

.github/workflows/lint.yaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,12 @@ jobs:
3434
with:
3535
python-version: "3.12"
3636

37+
- name: Install uv
38+
uses: astral-sh/setup-uv@v5
39+
3740
- name: Run lint checks
3841
id: lint
39-
run: uvx nox -s lint
42+
run: uv tool run nox -s lint
4043
continue-on-error: true
4144

4245
- name: Comment on PR
@@ -71,9 +74,12 @@ jobs:
7174
with:
7275
python-version: "3.12"
7376

77+
- name: Install uv
78+
uses: astral-sh/setup-uv@v5
79+
7480
- name: Run tests on all Python versions
7581
id: test
76-
run: uvx nox -s test_all
82+
run: uv tool run nox -s test_all
7783
continue-on-error: true
7884

7985
- name: Upload coverage reports

noxfile.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,11 @@
2323
from pathlib import Path
2424

2525
# 支持的 Python 版本范围
26-
MIN_PYTHON = "3.10"
26+
MIN_PYTHON = "3.12"
2727
MAX_PYTHON = "3.12"
2828

2929
# 生成版本列表
30-
PYTHON_VERSIONS = [
31-
f"3.{minor}"
32-
for minor in range(int(MIN_PYTHON.split(".")[-1]), int(MAX_PYTHON.split(".")[-1]) + 1)
33-
]
30+
PYTHON_VERSIONS = [MIN_PYTHON]
3431

3532

3633
def install_with_uv(session: nox.Session, extras: list[str] | None = None) -> None:

repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/.github/workflows/lint.yaml

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,20 @@ jobs:
2626
needs: setup
2727
runs-on: ubuntu-latest
2828
steps:
29-
- name: Check Python version
30-
run: python --version
29+
- name: Checkout code
30+
uses: actions/checkout@v4
31+
32+
- name: Setup Python
33+
uses: actions/setup-python@v5
34+
with:
35+
python-version: "{{cookiecutter.max_python_version}}"
36+
37+
- name: Install uv
38+
uses: astral-sh/setup-uv@v5
3139

3240
- name: Run lint checks
3341
id: lint
34-
run: uvx nox -s lint
42+
run: uv tool run nox -s lint
3543
continue-on-error: true
3644

3745
- name: Comment on PR
@@ -58,9 +66,20 @@ jobs:
5866
needs: setup
5967
runs-on: ubuntu-latest
6068
steps:
69+
- name: Checkout code
70+
uses: actions/checkout@v4
71+
72+
- name: Setup Python
73+
uses: actions/setup-python@v5
74+
with:
75+
python-version: "{{cookiecutter.max_python_version}}"
76+
77+
- name: Install uv
78+
uses: astral-sh/setup-uv@v5
79+
6180
- name: Run tests on all Python versions
6281
id: test
63-
run: uvx nox -s test_all
82+
run: uv tool run nox -s test_all
6483
continue-on-error: true
6584

6685
- name: Upload coverage reports

repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/.github/workflows/setup.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
python-version:
77
required: false
88
type: string
9-
default: "{{cookiecutter.max_python_version}}"
9+
default: "{{cookiecutter.max_python_version}}" # 使用用户选择的最高 Python 版本
1010
install-deps:
1111
required: false
1212
type: string

0 commit comments

Comments
 (0)