-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (68 loc) · 2.61 KB
/
Copy pathci.yml
File metadata and controls
77 lines (68 loc) · 2.61 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
name: CI
on:
push:
branches: [master]
pull_request:
permissions:
contents: read
jobs:
# The only thing that can be wrong with a template is what it generates, so the
# check is the generated project's own gate: render with the defaults, then run
# exactly what a new library's CI would run.
render:
name: Render the template and run the generated gate
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: astral-sh/setup-uv@v7
- name: Render with copier
run: |
uvx --with jinja2-time copier copy --defaults --trust --vcs-ref HEAD \
--data project_name=demo-lib \
--data project_slug=demo-lib \
--data package_name=demo_lib \
--data project_description="Demo library rendered from the template" \
--data author_name="Bedrock Python" \
--data author_email="maintainers@example.com" \
. "${RUNNER_TEMP}/demo-lib"
- name: The generated project passes its own gate
working-directory: ${{ runner.temp }}/demo-lib
run: |
uv sync --group dev --all-extras
make check
make test-unit
uv build
# A rule that is selected and then ignored looks exactly like a rule that
# works: the gate above stays green either way. Hand the generated project
# the mistakes the selected rules exist to catch and make it say so, and an
# assert in tests/ that has to stay accepted.
- name: The generated config runs the rules it selects
working-directory: ${{ runner.temp }}/demo-lib
run: |
cat > demo_lib/probe.py <<'PY'
import datetime
def stamp(offset):
return datetime.datetime.now() + offset
PY
cat > tests/unit/test_probe.py <<'PY'
def test__assert__still_reads_as_a_test() -> None:
assert True
PY
report=$(uv run ruff check --output-format concise demo_lib/probe.py || true)
echo "$report"
for rule in DTZ005 ANN201 ANN001; do
case "$report" in
*"$rule"*) ;;
*) echo "::error::$rule never fired -- the config selects the rule and then ignores it"; exit 1 ;;
esac
done
uv run ruff check tests/unit/test_probe.py
rm demo_lib/probe.py tests/unit/test_probe.py
all-checks-passed:
name: All checks passed
if: always()
needs: [render]
runs-on: ubuntu-latest
steps:
- name: Every job above succeeded
run: echo '${{ toJSON(needs) }}' | jq -e 'all(.[]; .result == "success")'