-
Notifications
You must be signed in to change notification settings - Fork 31
182 lines (167 loc) · 6.59 KB
/
Copy pathci.yml
File metadata and controls
182 lines (167 loc) · 6.59 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
180
181
182
# CI for the template repo itself: renders the template and exercises the renders,
# checks the update path from the previous release, and validates the agent skill.
# (Released template versions are additionally gated on the downstream
# jlevy/simple-modern-uv-template repo's CI; see updating.md.)
name: CI
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
permissions:
contents: read
env:
# Pinned tool versions used to exercise the template. Keep the uv version in
# sync with template/.github/workflows/ci.yml when updating.
UV_VERSION: "0.11.17"
COPIER_SPEC: "copier@9.15.1"
# Default answers for test renders.
RENDER_ARGS: >-
--data package_name=smoke-test
--data "package_description=Render smoke test"
--data "package_author_name=Test Author"
--data package_author_email=test@example.com
--data package_github_org=testorg
jobs:
format-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: astral-sh/setup-uv@v8.1.0
with:
version: "0.11.17"
- name: Check doc formatting
run: make format-check
render-test:
strategy:
matrix:
include:
- variant: default
extra_args: ""
- variant: no-publish-proprietary
extra_args: "--data package_license=Proprietary --data publish_to_pypi=false"
runs-on: ubuntu-latest
env:
# Supply-chain cool-off for template dependency resolution, matching the
# template's own CI (see updating.md). Scoped to the render/update jobs:
# the format-check job runs only the Makefile's explicitly pinned formatter,
# which may legitimately be newer than the cool-off window.
UV_EXCLUDE_NEWER: "14 days"
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: astral-sh/setup-uv@v8.1.0
with:
version: "0.11.17"
enable-cache: true
python-version: "3.12"
- name: Render template (${{ matrix.variant }})
run: |
eval uvx "$COPIER_SPEC" copy --defaults --vcs-ref=$GITHUB_SHA \
$RENDER_ARGS ${{ matrix.extra_args }} "$GITHUB_WORKSPACE" /tmp/render
- name: Inspect variant-specific output
run: |
cd /tmp/render
if [ "${{ matrix.variant }}" = "default" ]; then
test -f .github/workflows/publish.yml
test -f docs/publishing.md
grep -q 'license = "MIT"' pyproject.toml
head -1 LICENSE | grep -q "MIT License"
# Only the commented-out form may appear in the default render:
! grep -qE '^\s*"Private :: Do Not Upload",' pyproject.toml
else
test ! -e .github/workflows/publish.yml
test ! -e docs/publishing.md
grep -q 'license = "LicenseRef-Proprietary"' pyproject.toml
grep -qE '^\s*"Private :: Do Not Upload",' pyproject.toml
fi
test -f AGENTS.md
test -f .copier-answers.yml
- name: Init git in render (dynamic versioning requires it)
run: |
cd /tmp/render
git init -q --initial-branch=main
git add -A
git -c user.email=ci@example.com -c user.name=CI commit -qm "Initial commit"
git tag v0.1.0
- name: Install, lint, test, build
run: |
cd /tmp/render
uv sync --all-extras
uv run python devtools/lint.py --check
uv run pytest
uv build
ls dist/ | grep -q "smoke_test-0.1.0-py3-none-any.whl"
update-path:
# D2 "answer-schema evolution" rule 4: a project rendered from the previous
# release must update cleanly to this commit. With --defaults the result must
# converge to a fresh render (no conflicts, no surprise file changes), and
# explicit --data overrides for newer questions must be honored.
runs-on: ubuntu-latest
env:
UV_EXCLUDE_NEWER: "14 days"
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: astral-sh/setup-uv@v8.1.0
with:
version: "0.11.17"
- name: Render from previous release tag
run: |
PREV_TAG=$(git describe --tags --abbrev=0 "$GITHUB_SHA")
echo "Updating from $PREV_TAG to $GITHUB_SHA"
eval uvx "$COPIER_SPEC" copy --defaults --vcs-ref="$PREV_TAG" \
$RENDER_ARGS "$GITHUB_WORKSPACE" /tmp/old
cd /tmp/old
git init -q --initial-branch=main
git add -A
git -c user.email=ci@example.com -c user.name=CI commit -qm "From $PREV_TAG"
- name: Update to candidate commit with defaults
run: |
cd /tmp/old
eval uvx "$COPIER_SPEC" update --defaults --skip-answered \
--vcs-ref=$GITHUB_SHA
# No conflicts:
REJ=$(find . -name '*.rej' | wc -l); test "$REJ" -eq 0
# Converges to a fresh render of the candidate (the answers file differs
# only by _commit/_src_path bookkeeping, so exclude it):
eval uvx "$COPIER_SPEC" copy --defaults --vcs-ref=$GITHUB_SHA \
$RENDER_ARGS "$GITHUB_WORKSPACE" /tmp/fresh
diff -r --exclude=.git --exclude=.copier-answers.yml /tmp/old /tmp/fresh
- name: Update honors --data overrides for newer questions
run: |
eval uvx "$COPIER_SPEC" copy --defaults \
--vcs-ref="$(git describe --tags --abbrev=0 "$GITHUB_SHA")" \
$RENDER_ARGS "$GITHUB_WORKSPACE" /tmp/old2
cd /tmp/old2
git init -q --initial-branch=main
git add -A
git -c user.email=ci@example.com -c user.name=CI commit -qm "old"
eval uvx "$COPIER_SPEC" update --defaults --skip-answered \
--vcs-ref=$GITHUB_SHA --data publish_to_pypi=false
test ! -e .github/workflows/publish.yml
grep -qE '^\s*"Private :: Do Not Upload",' pyproject.toml
skill-validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Validate skill structure and frontmatter
run: npx --yes skills-ref@latest validate skills/simple-modern-uv
- name: Check that relative links in skill docs resolve
run: |
cd skills/simple-modern-uv
FAIL=0
for f in SKILL.md references/*.md; do
dir=$(dirname "$f")
for link in $(grep -oE '\]\(([^)#]+)\)' "$f" | sed 's/](\(.*\))/\1/'); do
case "$link" in
http*|mailto:*) continue ;;
esac
if [ ! -e "$dir/$link" ]; then
echo "BROKEN: $f -> $link"; FAIL=1
fi
done
done
exit $FAIL