Skip to content

Commit f7c3aa6

Browse files
colyerdengShawnDen-coder
authored andcommitted
feat: update docs build script and tempplate lint action
1 parent e37404f commit f7c3aa6

File tree

12 files changed

+53
-64
lines changed

12 files changed

+53
-64
lines changed

docs/gen_home_pages.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
"""Generate the home pages."""
2+
import mkdocs_gen_files
3+
import os
4+
5+
# Read README.md from project root
6+
readme_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "README.md")
7+
8+
# Read the content of README.md
9+
with open(readme_path, 'r', encoding='utf-8') as f:
10+
content = f.read()
11+
12+
# Write the content to index.md in the docs directory
13+
with mkdocs_gen_files.open("index.md", "w") as f:
14+
f.write(content)

docs/gen_ref_pages.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""Generate the code reference pages."""
22

33
from pathlib import Path
4-
54
import mkdocs_gen_files
65

76
nav = mkdocs_gen_files.Nav()

docs/index.md

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

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ plugins:
1616
- gen-files:
1717
scripts:
1818
- docs/gen_ref_pages.py
19+
- docs/gen_home_pages.py
1920
- literate-nav:
2021
nav_file: SUMMARY.md
2122
- mkdocstrings:

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ docs = [
3232
"mkdocs-gen-files>=0.5.0",
3333
"mkdocs-literate-nav>=0.6.1",
3434
"pymdown-extensions>=10.7",
35-
"pymdown-extensions>=10.7",
3635
]
3736

3837
[project.scripts]

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

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,7 @@ permissions:
1313
pull-requests: write # 用于在 PR 中添加评论
1414

1515
jobs:
16-
setup:
17-
uses: ./.github/workflows/setup.yaml
18-
with:
19-
install-deps: dev
20-
python-version: "{{cookiecutter.max_python_version}}" # 使用最新版本
21-
secrets:
22-
OP_SERVICE_ACCOUNT_TOKEN: {% raw %}${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}{% endraw %}
23-
PERSONAL_ACCESS_TOKEN: {% raw %}${{ secrets.PERSONAL_ACCESS_TOKEN }}{% endraw %}
24-
25-
lint:
26-
needs: setup
16+
check:
2717
runs-on: ubuntu-latest
2818
steps:
2919
- name: Checkout code
@@ -37,12 +27,15 @@ jobs:
3727
- name: Install uv
3828
uses: astral-sh/setup-uv@v5
3929

30+
- name: Install dependencies
31+
run: uv sync --extra=dev
32+
4033
- name: Run lint checks
4134
id: lint
42-
run: uv tool run nox -s lint
35+
run: uvx nox -s lint
4336
continue-on-error: true
4437

45-
- name: Comment on PR
38+
- name: Comment on PR (Lint)
4639
if: github.event_name == 'pull_request' && steps.lint.outcome == 'failure'
4740
uses: actions/github-script@v7
4841
with:
@@ -62,27 +55,20 @@ jobs:
6255
if: steps.lint.outcome == 'failure'
6356
run: exit 1
6457

65-
test-all:
66-
needs: setup
67-
runs-on: ubuntu-latest
68-
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-
80-
- name: Run tests on all Python versions
58+
- name: Run tests
8159
id: test
82-
run: uv tool run nox -s test_all
60+
run: uvx nox -s test_all
8361
continue-on-error: true
8462

85-
- name: Comment on PR
63+
- name: Upload coverage reports
64+
if: success()
65+
uses: codecov/codecov-action@v4
66+
with:
67+
token: ${{ secrets.CODECOV_TOKEN }}
68+
file: ./coverage.xml
69+
flags: unittests
70+
71+
- name: Comment on PR (Tests)
8672
if: github.event_name == 'pull_request' && steps.test.outcome == 'failure'
8773
uses: actions/github-script@v7
8874
with:
@@ -101,3 +87,4 @@ jobs:
10187
- name: Check test result
10288
if: steps.test.outcome == 'failure'
10389
run: exit 1
90+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
"""Generate the home pages."""
2+
import mkdocs_gen_files
3+
import os
4+
5+
# Read README.md from project root
6+
readme_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "README.md")
7+
8+
# Read the content of README.md
9+
with open(readme_path, 'r', encoding='utf-8') as f:
10+
content = f.read()
11+
12+
# Write the content to index.md in the docs directory
13+
with mkdocs_gen_files.open("index.md", "w") as f:
14+
f.write(content)

repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/docs/gen_ref_pages.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""Generate the code reference pages."""
22

33
from pathlib import Path
4-
54
import mkdocs_gen_files
65

76
nav = mkdocs_gen_files.Nav()

repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/docs/index.md

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

repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ plugins:
1616
- gen-files:
1717
scripts:
1818
- docs/gen_ref_pages.py
19+
- docs/gen_home_pages.py
1920
- literate-nav:
2021
nav_file: SUMMARY.md
2122
- mkdocstrings:

0 commit comments

Comments
 (0)