Repository navigation
157 lines (147 loc) · 6.57 KB
/
Copy pathtests.yml
File metadata and controls
157 lines (147 loc) · 6.57 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
name: tests
on:
push:
pull_request:
permissions:
contents: read
# One run per ref. A newer push supersedes an in-flight run rather than queueing
# behind it, so a burst of pushes costs one run's minutes instead of N runs'
# minutes. `github.ref` is refs/heads/<branch> for push and refs/pull/<n>/merge
# for pull_request, so PR runs group per-PR and never cancel each other.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
name: lint
# Pinned, not ubuntu-latest: GitHub has announced ubuntu-latest moves to
# 26.04 in November 2026, and an unpinned label turns a runner-image bump
# into an unexplained CI failure.
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: "3.11"
- run: python -m pip install --upgrade pip
- run: pip install -e ".[dev]"
# ruff was configured in pyproject.toml but never actually run by CI, so
# it had silently rotted. Running it here is what makes the config real.
- run: ruff check src tests
test:
name: test (py${{ matrix.python-version }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# 3.10 is the floor declared in pyproject.toml, so it is the version
# that must never break. 3.12/3.13 are here because that is where
# students actually are.
python-version: ["3.10", "3.11", "3.12", "3.13"]
os: ["ubuntu-24.04"]
include:
# macOS is a first-class target -- it is a desktop Tk app that ships
# to students -- and the sandbox behaves differently there, because
# RLIMIT_AS has a low hard ceiling. Both matter and neither is covered
# by a Linux-only matrix.
#
# Left as macos-latest on purpose: that label currently resolves to
# macOS 26 arm64, which is a very recent OS for a suite with live Tk
# tests. Pin it to macos-15 once someone has actually seen this job
# go green, so the pin records a known-good state rather than a guess.
- os: "macos-latest"
python-version: "3.12"
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: ${{ matrix.python-version }}
- run: python -m pip install --upgrade pip
- run: pip install -e ".[dev]"
- name: Show environment
run: python -VV
- run: pytest -q
editor:
name: editor (vendored, real browser)
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: "3.11"
- run: python -m pip install --upgrade pip
# No npm, no bundler, no Playwright: the editor is ES modules plus an
# import map, and the page reports its own result back over HTTP. The
# reason this job exists is that CodeMirror fails *silently* -- a bare
# specifier missing from the import map produces a dead editor with no
# console error, so nothing short of rendering it catches the regression.
#
# No apt-get install either. `chromium-browser` in Ubuntu's universe is
# the 1.2 KB transitional stub that pushes you to the chromium *snap*; it
# drops a shell wrapper at /usr/bin/chromium-browser and never a browser
# at /usr/bin/chromium, which is one of the two paths find_chrome()
# probes. The hosted image already ships a real one: install-google-chrome.sh
# in actions/runner-images puts Google Chrome at /usr/bin/google-chrome
# (CHROME_BIN) and symlinks Chromium to /usr/bin/chromium.
- name: Assert a browser is discoverable
# This is the step that stops a green tick from meaning nothing.
# check_editor.py returns exit 0 with "SKIP: no Chrome or Chromium
# found" when find_chrome() comes back empty, so a runner image change
# or a bad base would quietly turn this job into a no-op that reports
# success. Importing find_chrome() and calling it here means this
# assertion can never drift from the discovery logic it is guarding.
run: |
python - <<'PY'
import sys
sys.path.insert(0, "tools")
from check_editor import find_chrome
chrome = find_chrome()
if not chrome:
sys.exit(
"no Chrome or Chromium found; check_editor.py would print SKIP "
"and exit 0, making this job pass without checking anything"
)
print("browser:", chrome)
PY
- name: Verify the editor mounts and parses Python
run: python tools/check_editor.py
content:
name: content integrity
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: "3.11"
- run: python -m pip install --upgrade pip
- run: pip install -e ".[dev]"
# Every quiz that ships must validate against the schema. A broken quiz
# file is a student staring at a blank screen, and the validator already
# exists -- it was just never wired into CI.
- name: Validate bundled quizzes
run: |
python - <<'PY'
import json, sys
from pathlib import Path
from ducky.quiz import validate_quiz_dict
failures = 0
checked = 0
for path in sorted(Path("quizzes").glob("*.json")):
checked += 1
try:
data = json.loads(path.read_text(encoding="utf-8"))
except (OSError, json.JSONDecodeError) as exc:
print(f"UNREADABLE {path}: {exc}")
failures += 1
continue
ok, errors, warnings = validate_quiz_dict(data)
for warning in warnings:
print(f"warn {path}: {warning}")
if not ok:
failures += 1
print(f"INVALID {path}")
for error in errors:
print(f" {error}")
print(f"\nchecked {checked} quiz files, {failures} invalid")
sys.exit(1 if failures else 0)
PY