Skip to content

Commit a3da3ac

Browse files
committed
[CICD, DOCS] remove coverage-test, template inspection hook at pre-commit, update guides
1 parent 6224140 commit a3da3ac

File tree

7 files changed

+272
-111
lines changed

7 files changed

+272
-111
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Template PR Inspection
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'src/fastapi_fastkit/fastapi_project_template/**'
7+
types:
8+
- opened
9+
- synchronize
10+
11+
permissions:
12+
contents: read
13+
pull-requests: write
14+
15+
jobs:
16+
inspect-changed-templates:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0 # Fetch all history for git diff
24+
25+
- name: Set up Python
26+
uses: actions/setup-python@v4
27+
with:
28+
python-version: "3.12"
29+
30+
- name: Setup PDM
31+
uses: pdm-project/setup-pdm@v4
32+
33+
- name: Install dependencies
34+
run: pdm install -G dev
35+
36+
- name: Install UV package manager
37+
run: |
38+
curl -LsSf https://astral.sh/uv/install.sh | sh
39+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
40+
41+
- name: Verify UV installation
42+
run: |
43+
export PATH="$HOME/.cargo/bin:$PATH"
44+
uv --version
45+
which uv
46+
47+
- name: Set up Docker Compose
48+
run: |
49+
if ! command -v docker-compose &> /dev/null; then
50+
echo "Installing Docker Compose..."
51+
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
52+
sudo chmod +x /usr/local/bin/docker-compose
53+
fi
54+
55+
docker --version
56+
docker-compose --version
57+
58+
- name: Inspect changed templates
59+
run: |
60+
export PATH="$HOME/.cargo/bin:$PATH"
61+
pdm run python scripts/inspect-changed-templates.py
62+
63+
- name: Comment on PR (Success)
64+
if: success()
65+
uses: actions/github-script@v7
66+
with:
67+
script: |
68+
github.rest.issues.createComment({
69+
issue_number: context.issue.number,
70+
owner: context.repo.owner,
71+
repo: context.repo.repo,
72+
body: '✅ **Template Inspection Passed**\n\nAll changed templates have been validated successfully.'
73+
})
74+
75+
- name: Comment on PR (Failure)
76+
if: failure()
77+
uses: actions/github-script@v7
78+
with:
79+
script: |
80+
github.rest.issues.createComment({
81+
issue_number: context.issue.number,
82+
owner: context.repo.owner,
83+
repo: context.repo.repo,
84+
body: '❌ **Template Inspection Failed**\n\nPlease check the workflow logs for details on what needs to be fixed.\n\n[View Logs](' + context.payload.repository.html_url + '/actions/runs/' + context.runId + ')'
85+
})

.pre-commit-config.yaml

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ default_language_version:
44
python: python3.12
55
repos:
66
- repo: https://github.com/pre-commit/pre-commit-hooks
7-
rev: v3.2.0
7+
rev: v6.0.0
88
hooks:
99
- id: trailing-whitespace
1010
- id: end-of-file-fixer
@@ -15,29 +15,48 @@ repos:
1515
hooks:
1616
- id: format
1717
name: format
18-
entry: bash scripts/format.sh
19-
language: system
18+
entry: black --config pyproject.toml --check .
19+
language: python
20+
types: [python]
21+
additional_dependencies: ['black>=24.10.0']
22+
pass_filenames: false
23+
24+
- id: isort-check
25+
name: isort check
26+
entry: isort --sp pyproject.toml --check-only --diff .
27+
language: python
28+
types: [python]
29+
additional_dependencies: ['isort>=5.13.2']
2030
pass_filenames: false
2131

22-
- id: lint
23-
name: lint
24-
entry: bash scripts/lint.sh
25-
language: system
32+
- id: isort-fix
33+
name: isort fix
34+
entry: isort --sp pyproject.toml .
35+
language: python
36+
types: [python]
37+
additional_dependencies: ['isort>=5.13.2']
2638
pass_filenames: false
2739

28-
- id: coverage-test
29-
name: coverage test
30-
entry: bash scripts/coverage-report.sh
31-
language: system
40+
- id: black-fix
41+
name: black fix
42+
entry: black --config pyproject.toml .
43+
language: python
3244
types: [python]
45+
additional_dependencies: ['black>=24.10.0']
3346
pass_filenames: false
3447

35-
- id: inspect-templates
36-
name: inspect changed fastapi templates
37-
entry: python scripts/inspect-changed-templates.py
38-
language: system
48+
- id: mypy
49+
name: mypy
50+
entry: mypy --config-file pyproject.toml src
51+
language: python
52+
types: [python]
53+
additional_dependencies:
54+
- mypy>=1.12.0
55+
- rich>=13.9.2
56+
- click>=8.1.7
57+
- pyyaml>=6.0.0
58+
- types-PyYAML>=6.0.12
3959
pass_filenames: false
40-
stages: [commit]
4160

4261
ci:
4362
autofix_commit_msg: 🎨 [pre-commit.ci] Auto format from pre-commit.com hooks

CONTRIBUTING.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ Pre-commit hooks are automatically installed with `make dev-setup`. The hooks wi
210210
- Code formatting (black, isort)
211211
- Linting checks
212212
- Type checking (mypy)
213+
- Coverage test
213214

214215
If pre-commit finds issues, fix them and commit again:
215216

@@ -290,6 +291,16 @@ template-name/
290291

291292
FastAPI-fastkit includes **automated template testing** that provides comprehensive validation:
292293

294+
#### ✅ CI/CD Template Inspection
295+
296+
When you submit a PR that modifies template files, the **Template PR Inspection** workflow automatically runs:
297+
298+
- 🔍 **Automatic Trigger**: Runs when files in `src/fastapi_fastkit/fastapi_project_template/` are modified
299+
-**Validation**: Inspects changed templates using `inspect-changed-templates.py`
300+
- 💬 **PR Feedback**: Posts success/failure comments directly on your PR
301+
302+
Additionally, a **Weekly Template Inspection** runs every Wednesday to validate all templates.
303+
293304
#### ✅ Automatic Template Testing
294305

295306
**Zero Configuration Required:**

docs/en/contributing/code-guidelines.md

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -645,35 +645,42 @@ We use pre-commit hooks to enforce standards:
645645
```yaml
646646
# .pre-commit-config.yaml
647647
repos:
648-
- repo: https://github.com/psf/black
649-
rev: 23.1.0
648+
- repo: local
650649
hooks:
651-
- id: black
650+
- id: isort-check
651+
name: isort-check
652+
entry: isort --check-only --sp pyproject.toml .
653+
language: python
654+
additional_dependencies: [isort]
655+
pass_filenames: false
656+
always_run: true
657+
658+
- id: black-fix
659+
name: black-fix
660+
entry: black --config pyproject.toml .
661+
language: python
662+
additional_dependencies: [black]
663+
pass_filenames: false
664+
always_run: true
652665
653-
- repo: https://github.com/pycqa/isort
654-
rev: 5.12.0
655-
hooks:
656-
- id: isort
657-
658-
- repo: https://github.com/pycqa/flake8
659-
rev: 6.0.0
660-
hooks:
661-
- id: flake8
662-
663-
- repo: https://github.com/pre-commit/mirrors-mypy
664-
rev: v1.0.1
665-
hooks:
666666
- id: mypy
667+
name: mypy
668+
entry: mypy --config-file pyproject.toml src
669+
language: python
670+
additional_dependencies: [mypy]
671+
pass_filenames: false
672+
always_run: true
667673
```
668674
675+
> **Note:** Pre-commit hooks use isolated Python environments (`language: python`), ensuring compatibility with external Git tools like GitKraken and Sourcetree.
676+
669677
### IDE Configuration
670678
671679
Recommended VS Code settings:
672680
673681
```json
674682
{
675683
"python.linting.enabled": true,
676-
"python.linting.flake8Enabled": true,
677684
"python.linting.mypyEnabled": true,
678685
"python.formatting.provider": "black",
679686
"python.sortImports.path": "isort",

0 commit comments

Comments
 (0)