Skip to content

Commit 781785f

Browse files
feat: update github action and replace poetry to uv
1 parent 9c7a4a9 commit 781785f

File tree

11 files changed

+257
-107
lines changed

11 files changed

+257
-107
lines changed

.github/workflows/lint.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ jobs:
2525
python-version: "3.12"
2626

2727
- name: Install uv
28-
run: |
29-
curl -LsSf https://astral.sh/uv/install.sh | sh
30-
uv --version
28+
uses: astral-sh/setup-uv@v5
29+
with:
30+
version: ">=0.4.0"
3131

3232
- name: Install dependencies
3333
run: uv sync --extras dev

.github/workflows/release_build.yaml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ on:
88
jobs:
99
release-build:
1010
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write # 用于创建 GitHub Release
1113
steps:
1214
- uses: actions/checkout@v4
1315

@@ -25,9 +27,9 @@ jobs:
2527
python-version: "3.12"
2628

2729
- name: Install uv
28-
run: |
29-
curl -LsSf https://astral.sh/uv/install.sh | sh
30-
uv --version
30+
uses: astral-sh/setup-uv@v5
31+
with:
32+
version: ">=0.4.0"
3133

3234
- name: Install dependencies
3335
run: uv sync --extras dev
@@ -40,17 +42,13 @@ jobs:
4042
4143
- name: Publish to PyPI
4244
env:
43-
TWINE_USERNAME: __token__
44-
TWINE_PASSWORD: ${{ env.PYPI_TOKEN }}
45-
run: |
46-
pip install twine
47-
twine upload dist/*
45+
UV_PUBLISH_TOKEN: ${{ env.PYPI_TOKEN }}
46+
run: uv publish --retry 3
4847

4948
- name: Release
5049
uses: softprops/action-gh-release@v2
5150
with:
5251
files: |
53-
dist/**/*.exe
5452
dist/*.tar.gz
5553
dist/*.whl
5654
generate_release_notes: true

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
/build/
66
/coverage.xml
77
/.zip/
8-
/venv/
8+
/venv/
9+
/dist/

__pycache__/noxfile.cpython-312.pyc

1.27 KB
Binary file not shown.

hello.py

Lines changed: 0 additions & 6 deletions
This file was deleted.

noxfile.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
- Unit testing with coverage reporting
66
- Package building
77
- Project cleaning
8+
- Baseline creation for linting rules
89
910
Typical usage example:
1011
nox -s lint # Run linting
1112
nox -s test # Run tests
1213
nox -s build # Build package
1314
nox -s clean # Clean project
15+
nox -s baseline # Create a new baseline for linting rules
1416
"""
1517
import nox
1618
import shutil
@@ -140,3 +142,47 @@ def clean(session: nox.Session) -> None: # pylint: disable=unused-argument
140142
elif path.is_dir():
141143
shutil.rmtree(path)
142144
print(f"Removed directory: {path}")
145+
146+
147+
@nox.session(reuse_venv=True)
148+
def baseline(session: nox.Session) -> None:
149+
"""Create a new baseline for linting rules.
150+
151+
This command will:
152+
1. Add # noqa comments to all existing violations
153+
2. Update the pyproject.toml with new extend-ignore rules
154+
3. Show a summary of changes made
155+
156+
Args:
157+
session: Nox session object for running commands
158+
"""
159+
# Install dependencies
160+
session.install("ruff", "tomlkit")
161+
install_with_uv(session, editable=True)
162+
163+
# Get current violations
164+
result = session.run(
165+
"ruff",
166+
"check",
167+
".",
168+
"--verbose",
169+
"--output-format=json",
170+
silent=True,
171+
success_codes=[0, 1]
172+
)
173+
174+
if result:
175+
# Add noqa comments to existing violations
176+
session.run(
177+
"ruff",
178+
"check",
179+
".",
180+
"--add-noqa",
181+
"--verbose",
182+
success_codes=[0, 1]
183+
)
184+
185+
print("\nBaseline created! The following files were modified:")
186+
session.run("git", "diff", "--name-only", external=True)
187+
else:
188+
print("No violations found. No baseline needed.")

pyproject.toml

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,35 @@
1-
[tool.poetry]
1+
[project]
22
name = "repo-scaffold"
33
version = "0.3.0"
44
description = "shawn deng repo temple project"
5-
authors = ["shawndeng <[email protected]>"]
5+
authors = [
6+
{name = "shawndeng", email = "[email protected]"}
7+
]
68
license = "MIT"
79
readme = "README.md"
10+
requires-python = ">=3.12"
11+
dependencies = [
12+
"cookiecutter>=2.6.0",
13+
"click>=8.1.8",
14+
"ruff>=0.9.6",
15+
]
816

9-
[tool.poetry.dependencies]
10-
python = "^3.12"
11-
cookiecutter = "^2.6.0"
12-
click = "^8.1.8"
13-
ruff = "^0.9.6"
14-
15-
[tool.poetry.group.dev.dependencies]
16-
ruff = "^0.8.4"
17-
nox = "^2024.10.9"
18-
pytest = "^8.3.4"
19-
pytest-mock = "^3.14.0"
20-
pytest-cov = "^6.0.0"
21-
commitizen = "^4.1.0"
17+
[project.optional-dependencies]
18+
dev = [
19+
"ruff>=0.8.4",
20+
"nox>=2024.10.9",
21+
"pytest>=8.3.4",
22+
"pytest-mock>=3.14.0",
23+
"pytest-cov>=6.0.0",
24+
"commitizen>=4.1.0",
25+
]
2226

23-
[tool.poetry.scripts]
27+
[project.scripts]
2428
repo-scaffold = "repo_scaffold.cli:cli"
2529

2630
[build-system]
27-
requires = ["poetry-core"]
28-
build-backend = "poetry.core.masonry.api"
31+
requires = ["hatchling"]
32+
build-backend = "hatchling.build"
2933

3034
[tool.ruff]
3135
line-length = 120
@@ -48,6 +52,11 @@ ignore = [
4852
"D401" # imperative mood
4953
]
5054

55+
extend-ignore = [
56+
"D100", # Missing docstring in public module
57+
"D104", # Missing docstring in public package
58+
]
59+
5160
[tool.ruff.lint.isort]
5261
force-single-line = true
5362
lines-after-imports = 2
@@ -59,6 +68,6 @@ convention = "google"
5968
name = "cz_conventional_commits"
6069
tag_format = "$version"
6170
version_scheme = "semver2"
62-
version_provider = "poetry"
71+
version_provider = "pep621"
6372
update_changelog_on_bump = true
6473
major_version_zero = true

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,16 @@ jobs:
2424
with:
2525
python-version: "3.12"
2626

27-
- uses: abatilo/actions-poetry@v2
27+
- name: Install uv
28+
uses: astral-sh/setup-uv@v5
2829
with:
29-
poetry-version: "latest"
30+
version: ">=0.4.0"
3031

31-
- name: install depends
32-
run: |
33-
pip install nox
34-
poetry install
32+
- name: Install dependencies
33+
run: uv sync --extras dev
3534

3635
- name: Run lint checks
37-
run: poetry run nox -s lint
36+
run: uvx nox -s lint
3837

3938
- name: Run tests
40-
run: poetry run nox -s test
39+
run: uvx nox -s test

template-python/{{cookiecutter.project_slug}}/.github/workflows/release_build.yaml

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ on:
88
jobs:
99
release-build:
1010
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write # 用于创建 GitHub Release
1113
steps:
1214
- uses: actions/checkout@v4
1315

@@ -24,29 +26,29 @@ jobs:
2426
with:
2527
python-version: "3.12"
2628

27-
- uses: abatilo/actions-poetry@v2
29+
- name: Install uv
30+
uses: astral-sh/setup-uv@v5
2831
with:
29-
poetry-version: "latest"
32+
version: ">=0.4.0"
3033

31-
- name: Install nox
32-
run: pip install nox
34+
- name: Install dependencies
35+
run: uv sync --extras dev
3336

34-
- name: build and publish
37+
- name: Build and test
3538
run: |
36-
poetry config pypi-token.pypi {% raw %}${{ env.PYPI_TOKEN }}{% endraw %}
37-
poetry install
38-
poetry run nox -s lint
39-
poetry run nox -s test
40-
{% if cookiecutter.include_cli == 'y' -%}
41-
poetry run nox -s build_exe
42-
{% endif -%}
43-
poetry publish
39+
uvx nox -s lint
40+
uvx nox -s test
41+
uvx nox -s build
42+
43+
- name: Publish to PyPI
44+
env:
45+
UV_PUBLISH_TOKEN: {% raw %}${{ env.PYPI_TOKEN }}{% endraw %}
46+
run: uv publish --retry 3
4447

4548
- name: Release
4649
uses: softprops/action-gh-release@v2
4750
with:
4851
files: |
49-
dist/**/*.exe
5052
dist/*.tar.gz
5153
dist/*.whl
5254
generate_release_notes: true

0 commit comments

Comments
 (0)