-
Notifications
You must be signed in to change notification settings - Fork 2
179 lines (144 loc) · 4.78 KB
/
template-ci.yml
File metadata and controls
179 lines (144 loc) · 4.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
name: Template CI
on:
pull_request:
branches: [main, develop]
push:
branches: [main, develop]
jobs:
template-validation:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Install dependencies
run: pip install cookiecutter pyyaml
- name: Validate cookiecutter.json
run: python3 scripts/validate_cookiecutter.py
- name: Check template directory exists
run: test -d "{{cookiecutter.project_slug}}" || exit 1
- name: Generate project from template
run: cookiecutter . --no-input
- name: Generate project with custom values
run: |
rm -rf custom-test-project
cookiecutter . --no-input \
full_name="CI Test" \
email="ci@test.com" \
github_username="ci-test" \
project_name="Custom Test Project" \
project_short_description="CI test project" \
minimum_coverage="95" \
license="MIT" \
version="0.1.0"
- name: Validate generated pyproject.toml
run: python3 scripts/validate_projects.py
- name: Validate YAML frontmatter
run: python3 scripts/validate_yaml.py
- name: Check for unsubstituted variables
run: python3 scripts/check_variables.py
- name: Verify required files
run: python3 scripts/check_files.py
generated-project-tests:
runs-on: ubuntu-latest
timeout-minutes: 30
needs: template-validation
strategy:
matrix:
include:
- project: python-project-example
- project: custom-test-project
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Generate default project
if: matrix.project == 'python-project-example'
run: cookiecutter . --no-input
- name: Generate custom project
if: matrix.project == 'custom-test-project'
run: |
cookiecutter . --no-input \
full_name="CI Test" \
email="ci@test.com" \
github_username="ci-test" \
project_name="Custom Test Project" \
project_short_description="CI test project" \
minimum_coverage="95" \
license="MIT" \
version="0.1.0"
- name: Install UV
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
- name: Install dependencies
working-directory: ./${{ matrix.project }}
run: uv venv && uv pip install -e '.[dev]'
- name: Run linter
working-directory: ./${{ matrix.project }}
run: uv run ruff check .
- name: Run type checker
working-directory: ./${{ matrix.project }}
run: uv run pyright .
- name: Run tests
working-directory: ./${{ matrix.project }}
run: uv run pytest tests/ -v
- name: Build documentation
working-directory: ./${{ matrix.project }}
run: uv run mkdocs build
docker-build:
runs-on: ubuntu-latest
timeout-minutes: 30
needs: template-validation
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Generate project
run: cookiecutter . --no-input
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker test image
uses: docker/build-push-action@v5
with:
context: ./python-project-example
target: test
load: true
tags: python-project-template:test
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Run Docker tests
run: docker run python-project-template:test pytest tests/ -v
- name: Build Docker production image
uses: docker/build-push-action@v5
with:
context: ./python-project-example
target: prod
load: true
tags: python-project-template:prod
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Verify production image
run: docker run python-project-template:prod --help || true
template-release-test:
runs-on: ubuntu-latest
timeout-minutes: 30
if: github.event_name == 'pull_request'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Test template meta agents exist
run: |
test -d .opencode
test -f .opencode/agents/template-manager.md
test -f .opencode/skills/template-test/SKILL.md
test -f .opencode/skills/template-release/SKILL.md
test -f AGENTS.md
test -f scripts/template_test.sh
test -x scripts/template_test.sh