checkwright 0.18.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/payload/gate-sdk/README.md +1 -0
- package/payload/gate-sdk/SPEC.md +288 -13
- package/payload/gate-sdk/bin/upgrade-smoke.sh +35 -15
- package/payload/gate-sdk/checks/check-action-gh-repo.sh +321 -0
- package/payload/gate-sdk/gate-tests/check-action-gh-repo/bad/args +3 -0
- package/payload/gate-sdk/gate-tests/check-action-gh-repo/bad/expect.txt +1 -0
- package/payload/gate-sdk/gate-tests/check-action-gh-repo/bad/tree/workflows/publish.yml +78 -0
- package/payload/gate-sdk/gate-tests/check-action-gh-repo/good/args +4 -0
- package/payload/gate-sdk/gate-tests/check-action-gh-repo/good/expect.txt +1 -0
- package/payload/gate-sdk/gate-tests/check-action-gh-repo/good/tree/action.yml +11 -0
- package/payload/gate-sdk/gate-tests/check-action-gh-repo/good/tree/not-actions.yml +10 -0
- package/payload/gate-sdk/gate-tests/check-action-gh-repo/good/tree/workflows/arms.yml +93 -0
- package/payload/gate-sdk/gate-tests/check-action-gh-repo/good/tree/workflows/root-env.yml +18 -0
- package/payload/gate-sdk/gate-tests/check-action-gh-repo/good/tree/workflows/valves.yml +39 -0
- package/payload/gate-sdk/gate-tests/lib-declaration.test.sh +112 -0
- package/payload/gate-sdk/lib/declaration.sh +59 -0
- package/payload/lifecycle-kit/templates/stages/build.md +15 -0
- package/payload/site-kit/README.md +12 -5
- package/payload/site-kit/SPEC.md +183 -19
- package/payload/site-kit/templates/site-health.yml +128 -6
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Direct unit test of gate-sdk/lib/declaration.sh — the two container arms and
|
|
3
|
+
# the resolve/refuse trichotomy (gate-sdk/SPEC.md §lib/declaration.sh).
|
|
4
|
+
#
|
|
5
|
+
# Why a direct test: the record arm has no caller fixture to ride. Its only
|
|
6
|
+
# caller is bin/upgrade-smoke.sh's untagged branch, and the smoke is a bin tool
|
|
7
|
+
# whose contract forgoes a good/bad pair — so a corpus fixture would leave the
|
|
8
|
+
# arm the standing pre-release assertion depends on entirely unexercised. The
|
|
9
|
+
# markdown arm's callers do carry fixtures; its status-2 and empty-section arms
|
|
10
|
+
# are still checked here, being unreachable from a well-formed corpus.
|
|
11
|
+
#
|
|
12
|
+
# Run by run-gate-tests.sh (any <tests-dir>/*.test.sh; must exit 0).
|
|
13
|
+
set -uo pipefail
|
|
14
|
+
source "$(dirname "${BASH_SOURCE[0]}")/../../gate-sdk/lib/test-hermetic.sh"
|
|
15
|
+
|
|
16
|
+
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" # gate-sdk/
|
|
17
|
+
# shellcheck source=../lib/declaration.sh
|
|
18
|
+
source "$DIR/lib/declaration.sh"
|
|
19
|
+
|
|
20
|
+
fails=0
|
|
21
|
+
tmp="$(mktemp -d)"
|
|
22
|
+
trap 'rm -rf "$tmp"' EXIT
|
|
23
|
+
|
|
24
|
+
note() { printf '%s\n' "$2" > "$tmp/$1.md"; printf '%s\n' "$tmp/$1.md"; }
|
|
25
|
+
|
|
26
|
+
# $1=label $2=want-status $3=want-stdout $4...=the call
|
|
27
|
+
expect() {
|
|
28
|
+
local label="$1" want_st="$2" want_out="$3"; shift 3
|
|
29
|
+
local out st
|
|
30
|
+
out="$("$@")"; st=$?
|
|
31
|
+
if [[ "$st" -ne "$want_st" ]]; then
|
|
32
|
+
echo " FAIL [$label]: want status $want_st, got $st -- $out"; fails=$((fails + 1)); return
|
|
33
|
+
fi
|
|
34
|
+
if [[ "$out" != "$want_out" ]]; then
|
|
35
|
+
echo " FAIL [$label]: want stdout '$want_out', got '$out'"; fails=$((fails + 1))
|
|
36
|
+
fi
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
# --- the markdown arm ------------------------------------------------------
|
|
40
|
+
|
|
41
|
+
f="$(note canonical '## Tightened gates
|
|
42
|
+
|
|
43
|
+
- `check-alpha` — tightened.
|
|
44
|
+
- `check-beta` — landed new.
|
|
45
|
+
|
|
46
|
+
## Renamed knobs
|
|
47
|
+
|
|
48
|
+
None.')"
|
|
49
|
+
expect "markdown/token-list" 0 'check-alpha
|
|
50
|
+
check-beta' decl_section_tokens "$f" "Tightened gates"
|
|
51
|
+
expect "markdown/container-keeps-bullets-only" 0 '- `check-alpha` — tightened.
|
|
52
|
+
- `check-beta` — landed new.' decl_section_bullets "$f" "Tightened gates"
|
|
53
|
+
|
|
54
|
+
f="$(note none '## Tightened gates
|
|
55
|
+
|
|
56
|
+
None. A trailing clause ruling out a near-miss rides the explicit empty set.
|
|
57
|
+
|
|
58
|
+
## Renamed knobs
|
|
59
|
+
|
|
60
|
+
None.')"
|
|
61
|
+
expect "markdown/explicit-none" 0 '' decl_section_tokens "$f" "Tightened gates"
|
|
62
|
+
|
|
63
|
+
# The two spellings the corpus actually carried: bolded, and bold-and-backticked.
|
|
64
|
+
# Neither may be silently stripped to a token — that is the whole defect.
|
|
65
|
+
f="$(note bolded '## Tightened gates
|
|
66
|
+
|
|
67
|
+
- **check-alpha** — bolded.
|
|
68
|
+
- **`check-beta`** — bold-and-backticked.')"
|
|
69
|
+
expect "markdown/bolded-refused" 1 '- **check-alpha** — bolded.
|
|
70
|
+
- **`check-beta`** — bold-and-backticked.' decl_section_tokens "$f" "Tightened gates"
|
|
71
|
+
|
|
72
|
+
# A non-`None` section holding no bullet at all is the silent-empty case: it
|
|
73
|
+
# refuses with nothing to print, rather than resolving to an empty declared set.
|
|
74
|
+
f="$(note prose-only '## Tightened gates
|
|
75
|
+
|
|
76
|
+
Several gates moved this release.')"
|
|
77
|
+
expect "markdown/prose-only-refused" 1 '' decl_section_tokens "$f" "Tightened gates"
|
|
78
|
+
|
|
79
|
+
f="$(note absent '## Renamed knobs
|
|
80
|
+
|
|
81
|
+
None.')"
|
|
82
|
+
expect "markdown/section-absent" 2 '' decl_section_tokens "$f" "Tightened gates"
|
|
83
|
+
|
|
84
|
+
# `None` is read off the section's first non-blank line, so a later line opening
|
|
85
|
+
# with the word does not turn a real declaration into an empty set.
|
|
86
|
+
f="$(note none-later '## Tightened gates
|
|
87
|
+
|
|
88
|
+
- `check-alpha` — tightened.
|
|
89
|
+
|
|
90
|
+
None of the above affects a vendored tree that shadows it.')"
|
|
91
|
+
expect "markdown/none-only-at-head" 0 'check-alpha' decl_section_tokens "$f" "Tightened gates"
|
|
92
|
+
|
|
93
|
+
# --- the record arm --------------------------------------------------------
|
|
94
|
+
|
|
95
|
+
printf '# contract: x.md §y\ncheck-alpha\ncheck-beta\n' > "$tmp/decl.txt"
|
|
96
|
+
expect "record/data-lines" 0 'check-alpha
|
|
97
|
+
check-beta' decl_record_tokens "$tmp/decl.txt"
|
|
98
|
+
|
|
99
|
+
printf '# contract: x.md §y\n' > "$tmp/header-only.txt"
|
|
100
|
+
expect "record/header-only-is-empty-set" 0 '' decl_record_tokens "$tmp/header-only.txt"
|
|
101
|
+
|
|
102
|
+
expect "record/missing-file-is-empty-set" 0 '' decl_record_tokens "$tmp/nonexistent.txt"
|
|
103
|
+
|
|
104
|
+
printf '# contract: x.md §y\n- `check-alpha` — markup\n' > "$tmp/marked-up.txt"
|
|
105
|
+
expect "record/markup-refused" 1 '- `check-alpha` — markup' decl_record_tokens "$tmp/marked-up.txt"
|
|
106
|
+
|
|
107
|
+
if [[ "$fails" -gt 0 ]]; then
|
|
108
|
+
echo "lib-declaration.test: $fails assertion(s) failed"
|
|
109
|
+
exit 1
|
|
110
|
+
fi
|
|
111
|
+
echo "lib-declaration.test: ok (markdown arm resolves a token list and an explicit None, refuses the bolded and bold-and-backticked spellings and a bulletless non-None section, reports an absent section; None is read at the section head only; record arm resolves data lines, treats a header-only and a missing file as the empty set, and refuses a marked-up line)"
|
|
112
|
+
exit 0
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# spec: gate-sdk/SPEC.md §lib/declaration.sh — the tightened-gates declaration grammar: two container arms over one token predicate, reporting the resolve/refuse trichotomy on the statuses named there. Sourced, never executed.
|
|
3
|
+
|
|
4
|
+
DECL_TOKEN_RE='^[A-Za-z][A-Za-z0-9-]*$'
|
|
5
|
+
|
|
6
|
+
decl_section_bullets() {
|
|
7
|
+
awk -v sec="$2" '
|
|
8
|
+
/^##[[:space:]]/ { insec = ($0 ~ "^##[[:space:]]+" sec "[[:space:]]*$"); if (insec) found = 1; next }
|
|
9
|
+
insec && /^[[:space:]]*[-*][[:space:]]+/ { print }
|
|
10
|
+
END { exit(found ? 0 : 1) }
|
|
11
|
+
' "$1"
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
decl_section_is_none() {
|
|
15
|
+
awk -v sec="$2" '
|
|
16
|
+
/^##[[:space:]]/ { insec = ($0 ~ "^##[[:space:]]+" sec "[[:space:]]*$"); if (insec) found = 1; next }
|
|
17
|
+
insec && !seen && /[^[:space:]]/ { seen = 1; none = ($0 ~ /^[[:space:]]*[Nn]one([^A-Za-z0-9]|$)/) }
|
|
18
|
+
END { exit(found && none ? 0 : 1) }
|
|
19
|
+
' "$1"
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
decl_section_tokens() {
|
|
23
|
+
local file="$1" sec="$2" bullets st line tok n=0 bad=()
|
|
24
|
+
bullets="$(decl_section_bullets "$file" "$sec")"; st=$?
|
|
25
|
+
[[ "$st" -eq 0 ]] || return 2
|
|
26
|
+
decl_section_is_none "$file" "$sec" && return 0
|
|
27
|
+
while IFS= read -r line; do
|
|
28
|
+
[[ "$line" =~ [^[:space:]] ]] || continue
|
|
29
|
+
tok=""
|
|
30
|
+
[[ "$line" =~ ^[[:space:]]*[-*][[:space:]]+\`([^\`]*)\` ]] && tok="${BASH_REMATCH[1]}"
|
|
31
|
+
if [[ -n "$tok" && "$tok" =~ $DECL_TOKEN_RE ]]; then
|
|
32
|
+
printf '%s\n' "$tok"; n=$((n + 1))
|
|
33
|
+
else
|
|
34
|
+
bad+=("$line")
|
|
35
|
+
fi
|
|
36
|
+
done <<<"$bullets"
|
|
37
|
+
[[ ${#bad[@]} -eq 0 && "$n" -gt 0 ]] && return 0
|
|
38
|
+
[[ ${#bad[@]} -gt 0 ]] && printf '%s\n' "${bad[@]}"
|
|
39
|
+
return 1
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
decl_record_tokens() {
|
|
43
|
+
local file="$1" line bad=()
|
|
44
|
+
[[ -f "$file" ]] || return 0
|
|
45
|
+
while IFS= read -r line; do
|
|
46
|
+
[[ "$line" == '#'* ]] && continue
|
|
47
|
+
[[ "$line" =~ [^[:space:]] ]] || continue
|
|
48
|
+
if [[ "$line" =~ $DECL_TOKEN_RE ]]; then
|
|
49
|
+
printf '%s\n' "$line"
|
|
50
|
+
else
|
|
51
|
+
bad+=("$line")
|
|
52
|
+
fi
|
|
53
|
+
done < "$file"
|
|
54
|
+
if [[ ${#bad[@]} -gt 0 ]]; then
|
|
55
|
+
printf '%s\n' "${bad[@]}"
|
|
56
|
+
return 1
|
|
57
|
+
fi
|
|
58
|
+
return 0
|
|
59
|
+
}
|
|
@@ -69,6 +69,21 @@ widening asserted behavior, user-facing semantics) stops and surfaces to the
|
|
|
69
69
|
user — never pick a "conservative alternative" silently. A *cross-component
|
|
70
70
|
causal gap* is not a TODO: stop, resolve it this session, update the spec.
|
|
71
71
|
|
|
72
|
+
**Declare a gate you land or tighten, in the unit that lands it.** A unit that
|
|
73
|
+
lands a new gate or makes an existing one stricter appends that gate's bare name
|
|
74
|
+
to the tightened-gates declaration surface,
|
|
75
|
+
`<workflow-dir>/tightened-gates.txt` (gate-sdk/SPEC.md §upgrade-smoke), in the
|
|
76
|
+
same commit. Build is the only stage that knows what it tightened at the moment
|
|
77
|
+
it tightens it, so the declaration is written from knowledge rather than
|
|
78
|
+
reconstructed later from a red — and an assertion that discovers its own
|
|
79
|
+
allowed-red set from the gate it was supposed to check is its own trigger. The
|
|
80
|
+
surface accumulates across the iterations batched into one release; the release
|
|
81
|
+
step composes the note's Tightened-gates section from it and drains it at the
|
|
82
|
+
tag, so nothing here loads the release runbook. Only gates a consumer's vendored
|
|
83
|
+
tree can actually run are declared: a gate living solely in your own gates
|
|
84
|
+
directory never reaches a vendored tree and is not part of any release's
|
|
85
|
+
allowed-red set.
|
|
86
|
+
|
|
72
87
|
**Run the system; don't reason about it** — when a running system is
|
|
73
88
|
reachable, reproduce first, read second. Recorded evidence rots: a static
|
|
74
89
|
trace in a task body is a dated hypothesis to re-verify, not a premise. A
|
|
@@ -20,9 +20,10 @@ absent; the dependency joins a consumer's toolchain only when the gate is
|
|
|
20
20
|
registered.
|
|
21
21
|
|
|
22
22
|
The template — `templates/site-health.yml` — is a scheduled probe of the live
|
|
23
|
-
site (apex/www/http HTTPS, redirects, certificate expiry
|
|
24
|
-
*deployment*, not a tree, so it ships as a workflow a
|
|
25
|
-
gate:
|
|
23
|
+
site (apex/www/http HTTPS, redirects, certificate expiry, and release-body note
|
|
24
|
+
pointers). It verifies a *deployment*, not a tree, so it ships as a workflow a
|
|
25
|
+
consumer copies, never a gate: the line is where the asserted object lives, and
|
|
26
|
+
none of what it asserts is in any checkout. See [SPEC.md](SPEC.md#the-monitor-boundary)
|
|
26
27
|
for why that boundary is load-bearing.
|
|
27
28
|
|
|
28
29
|
## Install
|
|
@@ -51,8 +52,14 @@ Vendor the kit beside [gate-sdk](../gate-sdk/) (required), then:
|
|
|
51
52
|
unset the gate holds on defaults and finds nothing.
|
|
52
53
|
|
|
53
54
|
4. Optional live monitor — copy `templates/site-health.yml` verbatim into
|
|
54
|
-
`.github/workflows/`, set
|
|
55
|
-
|
|
55
|
+
`.github/workflows/`, then set two groups of step env or delete the arm each
|
|
56
|
+
belongs to: `ALT_DOMAIN` (drop the alternate-host probe if you serve no
|
|
57
|
+
redirect alias), and `RELEASE_NOTE_GLOB` / `RELEASE_NOTE_TAG_KEY` /
|
|
58
|
+
`RELEASE_NOTE_URL_PATH` (drop the release-body arm if you publish no release
|
|
59
|
+
notes). It opens/updates/closes a `site-health` issue on its own schedule.
|
|
60
|
+
The release-body arm needs the template's `contents: read` permission — it is
|
|
61
|
+
an allowlist, not an addition — and `RELEASE_NOTE_URL_PATH` is the value worth
|
|
62
|
+
checking twice: site-kit/SPEC.md §templates/site-health.yml names the trap.
|
|
56
63
|
|
|
57
64
|
## Test
|
|
58
65
|
|
package/payload/site-kit/SPEC.md
CHANGED
|
@@ -10,17 +10,29 @@ the other.
|
|
|
10
10
|
|
|
11
11
|
## The monitor boundary
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
**The line is where the asserted object lives.** A gate asserts over the tree: a
|
|
14
|
+
checkout plus bash is all it needs, which is what makes it deterministic,
|
|
15
|
+
hermetic, and safe to block a merge with. Deployment truth is in no checkout —
|
|
16
|
+
the live host's responses, its certificate, and the bodies of the Releases it
|
|
17
|
+
publishes are state no commit contains — so no gate can assert it, and enforcing
|
|
18
|
+
it through a pre-commit or CI gate would break both the low-false-positive
|
|
19
|
+
contract and the CI backstop's checkout-plus-bash hermeticity
|
|
20
|
+
(gate-sdk/SPEC.md §Enforcement tiers).
|
|
21
|
+
|
|
22
|
+
Object location governs rather than *whether a commit caused the failure*, and
|
|
23
|
+
the difference is load-bearing. Some host-side failures are caused by nothing any
|
|
24
|
+
commit did — DNS, a Pages incident, a stalled certificate renewal. Others are
|
|
25
|
+
caused by a session skipping a step, which is commit-shaped in spirit and still
|
|
26
|
+
ungateable, because the artifact it damaged sits on the host rather than in the
|
|
27
|
+
tree. A criterion built on cause admits the first kind and stumbles on the
|
|
28
|
+
second; a criterion built on where the object lives covers both, and stays true
|
|
29
|
+
of every probe arm instead of only the arms whose causes it happens to list.
|
|
30
|
+
|
|
31
|
+
So the deployment probe is *monitoring*, not a gate: it ships as
|
|
32
|
+
`templates/site-health.yml`, a scheduled workflow a consumer copies, and signals
|
|
33
|
+
through an issue and a red run of its own, never a blocked merge. The
|
|
34
|
+
tree-honesty half — that the repo never *cites* a stale host — is a real gate,
|
|
35
|
+
because that is a property of the tree.
|
|
24
36
|
|
|
25
37
|
## Layout and configuration
|
|
26
38
|
|
|
@@ -54,6 +66,13 @@ told to load but cannot find. Knobs:
|
|
|
54
66
|
- `SITE_KIT_CONFIG_FILE` — the loader override; when set it must resolve, else
|
|
55
67
|
the gate exits 2 rather than silently run on defaults.
|
|
56
68
|
|
|
69
|
+
`templates/site-health.yml` is governed by none of these. Its knobs — `ALT_DOMAIN`
|
|
70
|
+
and the three `RELEASE_NOTE_*` below — are **step-level workflow env** set in the
|
|
71
|
+
copied file itself, not `SITE_KIT_*` knobs, and `lib/site.sh` never loads them.
|
|
72
|
+
The template is copied and edited rather than sourced, so reaching into the gate
|
|
73
|
+
config loader would couple a monitor to the gates dir and hard-code a vendored
|
|
74
|
+
kit path into a workflow whose whole distribution model is verbatim copy.
|
|
75
|
+
|
|
57
76
|
## check-docs-cname-parity
|
|
58
77
|
|
|
59
78
|
Invariant: no tracked file cites a `SITE_KIT_ALIASES` host in a `://` URL,
|
|
@@ -161,9 +180,9 @@ line naming the dependency (ruby plus the kramdown-parser-gfm gem, or a
|
|
|
161
180
|
`SITE_KIT_RENDERER` override) — a gate that cannot run its oracle refuses, never
|
|
162
181
|
a false clean. That dependency joins the *consumer's* toolchain only when the
|
|
163
182
|
consumer registers this gate; it stays outside env-probe's probe-set floor, and
|
|
164
|
-
`docs/install.md`'s Requirements prose states the tier
|
|
165
|
-
|
|
166
|
-
|
|
183
|
+
`docs/install.md`'s Requirements prose states the tier. A consumer with no
|
|
184
|
+
published docs site simply omits the gate by the registry-not-array convention
|
|
185
|
+
and never installs the dependency.
|
|
167
186
|
|
|
168
187
|
The false-positive floor is the assertion's hard boundary, deliberately set. The
|
|
169
188
|
backtick symptom rests on a property of well-formed markdown: every backtick
|
|
@@ -247,16 +266,161 @@ The scheduled live-site probe, copied verbatim into a consumer's
|
|
|
247
266
|
`.github/workflows/`. It reads the apex host from the CNAME file (the same
|
|
248
267
|
source the gate trusts), then checks: the apex answers 200 over HTTPS, `www`
|
|
249
268
|
and `http` redirect to the canonical origin, an optional `ALT_DOMAIN` redirect
|
|
250
|
-
keeps its path,
|
|
269
|
+
keeps its path, the certificate is at least a fortnight from expiry, and every
|
|
270
|
+
published release note is pointed at by a resolving URL in its Release body. A
|
|
251
271
|
failure opens or updates a single `site-health` issue and reds the run;
|
|
252
272
|
recovery closes it. The `ALT_DOMAIN` value is a bare hostname, never a `://`
|
|
253
273
|
literal, so it does not itself trip the parity gate. A `# enforce:` marker rides
|
|
254
274
|
the template so that, once copied, an enforcement map projects it as a monitor.
|
|
255
275
|
|
|
256
|
-
The
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
276
|
+
The workflow's `permissions:` block is an **allowlist, not an addition** — every
|
|
277
|
+
scope it omits is `none` — so reading the tag list and the Release bodies needs
|
|
278
|
+
`contents: read` declared beside `issues: write`, and the probe step needs its own
|
|
279
|
+
`GH_TOKEN`. On a public repository the declaration is redundant and the arm
|
|
280
|
+
appears to work without it; at a private-repo consumer it is the difference
|
|
281
|
+
between the arm working and the arm 404ing on every note, because GitHub masks an
|
|
282
|
+
unauthorized read as an absent resource — the failure arrives looking like "no
|
|
283
|
+
such Release" rather than "not permitted". No gate parses a `permissions:` block
|
|
284
|
+
(workflow-security linting is an explicit non-goal, gate-sdk/SPEC.md
|
|
285
|
+
§check-action-run-shell), so this one is held by review rather than by an oracle.
|
|
286
|
+
|
|
287
|
+
**The release-body arm.** For every tracked release note whose front-matter tag
|
|
288
|
+
key names a tag that exists on the remote, the arm asserts two properties over
|
|
289
|
+
that tag's Release:
|
|
290
|
+
|
|
291
|
+
- **Presence** — a Release exists for the tag, and its body *contains* the note's
|
|
292
|
+
canonical URL, derived **scheme-qualified** as `https://` plus the apex host
|
|
293
|
+
from the CNAME file plus the path from `RELEASE_NOTE_URL_PATH`. This is what
|
|
294
|
+
catches a body that was never filled in.
|
|
295
|
+
- **Resolution** — every apex-hosted URL *as literally written in the body*
|
|
296
|
+
answers 200. This is what catches a body whose pointer is present but dead.
|
|
297
|
+
|
|
298
|
+
**The two run over two different strings, and collapsing them re-opens the defect
|
|
299
|
+
the other closes.** A body carrying a trailing-slash URL *contains* the
|
|
300
|
+
slash-less form as a substring, so a presence-only check passes a pointer that
|
|
301
|
+
404s; and a probe that derived the URL itself and then resolved *that* would
|
|
302
|
+
confirm only its own arithmetic while the body stayed wrong. Presence runs over
|
|
303
|
+
the URL the arm derives; resolution over the URLs the body actually carries.
|
|
304
|
+
|
|
305
|
+
Presence is deliberately loose in one direction and strict in the other.
|
|
306
|
+
*Containment, never equality*: a body may write a suffixed or otherwise decorated
|
|
307
|
+
variant of the URL, so a token-equality test reds a corpus that is in fact
|
|
308
|
+
correct — and the looseness that permits it is exactly what lets the
|
|
309
|
+
trailing-slash form through, which is why resolution exists rather than a
|
|
310
|
+
stricter presence. *Scheme-qualified*: a markdown link whose visible label
|
|
311
|
+
repeats the URL scheme-less satisfies a scheme-less presence test while the link
|
|
312
|
+
*target* goes unchecked, and a wrong-but-resolving target then passes both
|
|
313
|
+
assertions with nothing red.
|
|
314
|
+
|
|
315
|
+
URL extraction is **scheme-anchored over the whole body text**, never
|
|
316
|
+
markdown-link-aware — only the scheme reliably separates a link target from a
|
|
317
|
+
visible label — and a trailing **run** of punctuation is stripped from an
|
|
318
|
+
extracted URL before it is resolved. The punctuation that occurs in practice is
|
|
319
|
+
markdown-structural rather than sentential: a `)` closing a link target, or `)**`
|
|
320
|
+
closing one inside bold. A stripping set written for the period captures those
|
|
321
|
+
closers into the URL and reds a healthy corpus, so the set carries the markdown
|
|
322
|
+
closers alongside sentence punctuation (the template owns the set), and strips a
|
|
323
|
+
run rather than a single character — or `)**` merely becomes `)*`.
|
|
324
|
+
The extracted set is **not** narrowed to note URLs: the assertion is over
|
|
325
|
+
apex-hosted URLs, so a body's other apex links are covered deliberately.
|
|
326
|
+
|
|
327
|
+
The tag list comes from the **API, paginated**, never from `git tag`.
|
|
328
|
+
`actions/checkout` defaults to `fetch-depth: 1` and fetches no tags, so a
|
|
329
|
+
`git tag`-driven arm finds zero released notes and reports green forever. Two
|
|
330
|
+
properties of the call are load-bearing: `gh api --paginate` discharges the
|
|
331
|
+
paging with no manual page loop, and because it *concatenates* the pages' arrays,
|
|
332
|
+
`--jq 'length'` returns the last page's length rather than the total — so the
|
|
333
|
+
count is taken by streaming the elements, and the pagination is forward-looking
|
|
334
|
+
insurance no run will ever confirm until a consumer passes its first page. The
|
|
335
|
+
tag list is not replaceable by a per-note Release-by-tag lookup: a 404 there
|
|
336
|
+
cannot distinguish a tag that was never pushed (a legitimate skip for a note
|
|
337
|
+
whose release is deferred) from a tag whose Release is missing (a real finding),
|
|
338
|
+
and conflating them either reds every deferred note or hides a missing Release.
|
|
339
|
+
|
|
340
|
+
**The arm's three knobs** are step-level workflow env on the probe step, set in
|
|
341
|
+
the copied file the way `ALT_DOMAIN` already is (§Layout and configuration):
|
|
342
|
+
|
|
343
|
+
- `RELEASE_NOTE_GLOB` — the tracked path glob enumerating release-note files.
|
|
344
|
+
- `RELEASE_NOTE_TAG_KEY` — the front-matter key whose value is the tag a note
|
|
345
|
+
belongs to. Load-bearing rather than decorative: a posts directory holds posts
|
|
346
|
+
that are not release notes, and this key is what separates them. It is read
|
|
347
|
+
**anchored inside the opening front-matter fence**, so the same key spelled in
|
|
348
|
+
a note's body is not mistaken for the note's own tag.
|
|
349
|
+
- `RELEASE_NOTE_URL_PATH` — the site path a note is published at, written with a
|
|
350
|
+
`{slug}` token the arm substitutes with the note filename minus its extension.
|
|
351
|
+
It holds the **path only**; the host is never repeated here, because the CNAME
|
|
352
|
+
file stays the single source for it and a host rename must stay a one-file
|
|
353
|
+
edit. This is the knob with no cross-check anywhere — nothing outside the site
|
|
354
|
+
generator derives a note's served URL — so it is the one a consumer can set
|
|
355
|
+
wrongly and see nothing red. The concrete trap: a generator that emits
|
|
356
|
+
`/posts/<slug>.html` while the host *also* serves the extensionless form makes
|
|
357
|
+
the suffixed value look the more literally correct of the two, and it reds
|
|
358
|
+
every body written to the bare form.
|
|
359
|
+
|
|
360
|
+
**The zero-cases, ruled exhaustively.** Every count the arm ranges over can be
|
|
361
|
+
zero, and each zero is either a finding or a legitimate pass; an unruled one is
|
|
362
|
+
how the arm becomes a green that means nothing.
|
|
363
|
+
|
|
364
|
+
- **The glob matches no notes** — a **finding**. A misconfigured
|
|
365
|
+
`RELEASE_NOTE_GLOB` is itself the defect, which is what makes "set these knobs
|
|
366
|
+
or delete the arm" an instruction rather than advice.
|
|
367
|
+
- **The tag-list call fails** — a **finding**, asserted on the call's own exit
|
|
368
|
+
status with the API's error text (which carries the HTTP code) in the message,
|
|
369
|
+
never inferred from the count that follows. The probe step runs under `set +e`,
|
|
370
|
+
so a failed invocation yields an empty tag list and a zero exit; every note then
|
|
371
|
+
reads "not yet released" and the arm reports a clean run forever. On the
|
|
372
|
+
per-Release lookup a failure reads like "no such Release"; on the tag-list call
|
|
373
|
+
the same failure reads like "green".
|
|
374
|
+
- **The per-Release lookup fails for a tag that exists** — a **finding**. The tag
|
|
375
|
+
list has already established that the tag is real, so this is the
|
|
376
|
+
missing-Release case rather than the deferred-release one.
|
|
377
|
+
- **The glob matches notes and none carries the tag key** — **not** a finding,
|
|
378
|
+
stated so it is not added by symmetry with the first case. A consumer whose
|
|
379
|
+
notes genuinely precede its first release is in this state legitimately. It is
|
|
380
|
+
nonetheless the likelier of the two knob misconfigurations, precisely because
|
|
381
|
+
the glob's failure is loud and the key's is silent.
|
|
382
|
+
- **Zero *released* notes** — not a finding, for the same reason.
|
|
383
|
+
|
|
384
|
+
**The census line makes those states readable; the rulings above are what make a
|
|
385
|
+
vacuous pass impossible.** On every run the arm prints a census of what it ranged
|
|
386
|
+
over — notes found, of those carrying the tag key, of those released against the
|
|
387
|
+
remote tag count, and of those checked. No count in it is another by
|
|
388
|
+
construction: the gap between *found* and *keyed* separates a typo'd
|
|
389
|
+
`RELEASE_NOTE_TAG_KEY` from a corpus that simply mixes notes with ordinary posts,
|
|
390
|
+
the gap between *keyed* and *released* is the legitimate pre-release state, and
|
|
391
|
+
the gap between *released* and *checked* is a Release the arm could not read.
|
|
392
|
+
Collapsing *found* into *keyed* would render the first two of those states
|
|
393
|
+
identically, which is what reporting them apart buys. This is the same shape as
|
|
394
|
+
gate-sdk's vacuous-pass
|
|
395
|
+
tripwire (§run-gates): a *reading* available to whoever opens the run log, not an
|
|
396
|
+
assertion, and on a green run nobody opens it. It earns its place as the
|
|
397
|
+
diagnostic naming which state a reader is in; it is not itself what stands
|
|
398
|
+
between this arm and a vacuous pass.
|
|
399
|
+
|
|
400
|
+
**Stated coverage limit.** The arm is driven from the tree's notes, so it is total
|
|
401
|
+
over note→Release and silent on the reverse: a Release carrying no note anywhere
|
|
402
|
+
in the tree reds nowhere. The deliverable is the note's pointer, and the
|
|
403
|
+
population that has ever gone wrong is the pointer's.
|
|
404
|
+
|
|
405
|
+
**Cost per run.** The paginated tag list, one Release lookup per released note,
|
|
406
|
+
and one resolution request per distinct apex URL in each body — linear in release
|
|
407
|
+
count, on a daily schedule, well inside the authenticated rate limit.
|
|
408
|
+
Deliberately uncapped and unknobbed: a "newest N only" bound would stop probing
|
|
409
|
+
exactly the old releases where this class of defect has actually been found.
|
|
410
|
+
|
|
411
|
+
The kit's `smoke/install.sh` installs the template verbatim into the scratch tree
|
|
412
|
+
as governed surface. **What that buys is narrower than the install suggests, and
|
|
413
|
+
is stated here rather than inferred from it.** The scratch battery is the union of
|
|
414
|
+
what each kit's `smoke/install.sh` registers, and of those gates only
|
|
415
|
+
`check-tree-terms` and `check-docs-cname-parity` read the installed workflow at
|
|
416
|
+
all — one for tree terms, the other for configured host aliases in `://` form.
|
|
417
|
+
None of the gates that lint a workflow's *Actions shape* — its `run:` bodies, its
|
|
418
|
+
action pins, its `gh` repository context — is registered in any kit's smoke
|
|
419
|
+
`gates.list`, so none of them runs over the installed file. The smoke therefore
|
|
420
|
+
catches a template that leaks a term or a host alias, and nothing else about it; a
|
|
421
|
+
regression in the workflow's bash or its pinning surfaces at a consumer, not here.
|
|
422
|
+
Closing that is a change to smoke wiring rather than to this template, and is
|
|
423
|
+
carried as deferred work in the consumer's queue.
|
|
260
424
|
|
|
261
425
|
## Out of scope
|
|
262
426
|
|
|
@@ -7,10 +7,12 @@
|
|
|
7
7
|
# a site-health issue and reds this run, never a merge. Recovery self-clears (a
|
|
8
8
|
# green run closes the open issue). No README badge, by the standing ruling.
|
|
9
9
|
#
|
|
10
|
-
# Copy verbatim into .github/workflows
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
10
|
+
# Copy verbatim into .github/workflows/, then set two groups of env below or
|
|
11
|
+
# delete the arm each belongs to: ALT_DOMAIN (drop probe #4 if you serve no
|
|
12
|
+
# redirect alias), and the three RELEASE_NOTE_* knobs (drop probe #6 if you
|
|
13
|
+
# publish no release notes). The apex host is read from the CNAME file — no
|
|
14
|
+
# second place to keep it.
|
|
15
|
+
# enforce: class=monitor live docs-site deployment — apex/www/http HTTPS, redirects, cert expiry, and release-body note pointers
|
|
14
16
|
name: site-health
|
|
15
17
|
|
|
16
18
|
on:
|
|
@@ -23,10 +25,13 @@ on:
|
|
|
23
25
|
type: boolean
|
|
24
26
|
default: false
|
|
25
27
|
|
|
26
|
-
#
|
|
27
|
-
# open/update/close path
|
|
28
|
+
# A permissions: block is an allowlist, not an addition — every scope it omits is
|
|
29
|
+
# none. issues:write carries the open/update/close path; contents:read is what
|
|
30
|
+
# lets the probe read the tag list and the Release bodies. Without it those reads
|
|
31
|
+
# 404, which reads like "no such Release" rather than "not permitted".
|
|
28
32
|
permissions:
|
|
29
33
|
issues: write
|
|
34
|
+
contents: read
|
|
30
35
|
|
|
31
36
|
jobs:
|
|
32
37
|
probe:
|
|
@@ -44,7 +49,20 @@ jobs:
|
|
|
44
49
|
# the probe builds the URL from this at run time. Set to your redirect
|
|
45
50
|
# alias, or delete this env and probe #4 below if you have none.
|
|
46
51
|
ALT_DOMAIN: alt.example.com
|
|
52
|
+
# Release-note pointer arm (#6) — set all three, or delete them along
|
|
53
|
+
# with probe #6 below. Step-level workflow env, not the kit's SITE_KIT_*
|
|
54
|
+
# knobs: this file is copied and edited, never sourced, so it must not
|
|
55
|
+
# reach into a vendored gates dir. The host is deliberately absent —
|
|
56
|
+
# the CNAME file stays its single source, so a rename is one edit.
|
|
57
|
+
RELEASE_NOTE_GLOB: 'docs/posts/*.md'
|
|
58
|
+
RELEASE_NOTE_TAG_KEY: 'release'
|
|
59
|
+
# Path only; {slug} is the note filename minus its extension. Check the
|
|
60
|
+
# form your host actually serves — a generator that emits
|
|
61
|
+
# /posts/<slug>.html often serves the extensionless form too, and the
|
|
62
|
+
# value must match what your release bodies are written to carry.
|
|
63
|
+
RELEASE_NOTE_URL_PATH: '/posts/{slug}'
|
|
47
64
|
FORCE_FAIL: ${{ inputs.force_fail }}
|
|
65
|
+
GH_TOKEN: ${{ github.token }}
|
|
48
66
|
run: |
|
|
49
67
|
# A probe expects individual checks to fail; -e would abort the battery
|
|
50
68
|
# on the first red, so disable it and collect failures explicitly.
|
|
@@ -103,6 +121,110 @@ jobs:
|
|
|
103
121
|
fi
|
|
104
122
|
fi
|
|
105
123
|
|
|
124
|
+
# 6. every tracked release note naming an existing tag has a Release
|
|
125
|
+
# whose body points at that note, and every apex URL that body
|
|
126
|
+
# carries resolves. The two assertions run over two different
|
|
127
|
+
# strings — presence over the URL derived here, resolution over the
|
|
128
|
+
# URLs the body actually carries — and collapsing them re-opens the
|
|
129
|
+
# defects this arm exists for (site-kit/SPEC.md §templates/site-health.yml).
|
|
130
|
+
# Delete this whole block along with the RELEASE_NOTE_* env above if
|
|
131
|
+
# you publish no release notes.
|
|
132
|
+
notes=()
|
|
133
|
+
shopt -s nullglob
|
|
134
|
+
for f in $RELEASE_NOTE_GLOB; do
|
|
135
|
+
notes+=("$f")
|
|
136
|
+
done
|
|
137
|
+
shopt -u nullglob
|
|
138
|
+
if [ "${#notes[@]}" -eq 0 ]; then
|
|
139
|
+
failures+=("release-note glob matched nothing: '$RELEASE_NOTE_GLOB' — set the RELEASE_NOTE_* env above, or delete this arm")
|
|
140
|
+
fi
|
|
141
|
+
|
|
142
|
+
# The tag list comes from the API, never `git tag`: checkout fetches no
|
|
143
|
+
# tags at depth 1, so a git-driven arm finds zero released notes and
|
|
144
|
+
# reads green forever. --paginate concatenates the pages' arrays, so
|
|
145
|
+
# count by streaming the names — --jq 'length' returns the last page's
|
|
146
|
+
# count, which understates exactly once pagination starts to matter.
|
|
147
|
+
tag_err="$(mktemp)"
|
|
148
|
+
tags="$(gh api --paginate 'repos/{owner}/{repo}/tags' --jq '.[].name' 2>"$tag_err")"
|
|
149
|
+
tag_rc=$?
|
|
150
|
+
if [ "$tag_rc" -ne 0 ]; then
|
|
151
|
+
# Asserted on the call's own exit status, never inferred from the
|
|
152
|
+
# count below: this step runs under `set +e`, so a failed call yields
|
|
153
|
+
# an empty tag list and a zero exit, every note then reads "not yet
|
|
154
|
+
# released", and the arm reports a clean run forever.
|
|
155
|
+
failures+=("could not read the tag list (gh exit $tag_rc): $(tr '\n' ' ' < "$tag_err")")
|
|
156
|
+
tags=""
|
|
157
|
+
fi
|
|
158
|
+
rm -f "$tag_err"
|
|
159
|
+
n_tags="$(grep -c . <<<"$tags")"
|
|
160
|
+
|
|
161
|
+
n_found="${#notes[@]}"; n_keyed=0; n_released=0; n_checked=0
|
|
162
|
+
for f in "${notes[@]:-}"; do
|
|
163
|
+
[ -n "$f" ] || continue
|
|
164
|
+
# Anchored inside the opening front-matter fence. A bare ^key: match
|
|
165
|
+
# also hits the body.
|
|
166
|
+
tag="$(awk -v key="$RELEASE_NOTE_TAG_KEY" '
|
|
167
|
+
/^---[[:space:]]*$/ { fm++; next }
|
|
168
|
+
fm == 1 && index($0, key ":") == 1 {
|
|
169
|
+
v = substr($0, length(key) + 2); sub(/^[[:space:]]+/, "", v); print v; exit
|
|
170
|
+
}' "$f")"
|
|
171
|
+
# A post carrying no tag key is not a release note. Silent by ruling:
|
|
172
|
+
# the census line below is how that case stays readable.
|
|
173
|
+
[ -n "$tag" ] || continue
|
|
174
|
+
n_keyed=$(( n_keyed + 1 ))
|
|
175
|
+
# A note whose tag is not on the remote is a legitimate skip — its
|
|
176
|
+
# release is deferred. This is why the tag list is not replaceable by
|
|
177
|
+
# the per-tag lookup below: a 404 there cannot tell that apart from a
|
|
178
|
+
# tag whose Release is genuinely missing.
|
|
179
|
+
grep -Fxq -- "$tag" <<<"$tags" || continue
|
|
180
|
+
n_released=$(( n_released + 1 ))
|
|
181
|
+
|
|
182
|
+
slug="${f##*/}"; slug="${slug%.*}"
|
|
183
|
+
want="https://$apex${RELEASE_NOTE_URL_PATH//\{slug\}/$slug}"
|
|
184
|
+
|
|
185
|
+
rel_err="$(mktemp)"
|
|
186
|
+
body="$(gh api "repos/{owner}/{repo}/releases/tags/$tag" --jq '.body // ""' 2>"$rel_err")"
|
|
187
|
+
rel_rc=$?
|
|
188
|
+
if [ "$rel_rc" -ne 0 ]; then
|
|
189
|
+
failures+=("$tag: no readable Release for a tag that exists (gh exit $rel_rc): $(tr '\n' ' ' < "$rel_err")")
|
|
190
|
+
rm -f "$rel_err"
|
|
191
|
+
continue
|
|
192
|
+
fi
|
|
193
|
+
rm -f "$rel_err"
|
|
194
|
+
n_checked=$(( n_checked + 1 ))
|
|
195
|
+
|
|
196
|
+
# Presence: containment, never equality — an older body may write a
|
|
197
|
+
# suffixed variant of its URL. Scheme-qualified, because a markdown
|
|
198
|
+
# link's visible label often repeats the URL scheme-less and would
|
|
199
|
+
# satisfy a scheme-less match while the link target went unchecked.
|
|
200
|
+
case "$body" in
|
|
201
|
+
*"$want"*) ;;
|
|
202
|
+
*) failures+=("$tag: Release body does not carry the note URL $want") ;;
|
|
203
|
+
esac
|
|
204
|
+
|
|
205
|
+
# Resolution: every apex URL as literally written in the body — this
|
|
206
|
+
# is what catches a trailing-slash URL that presence's containment
|
|
207
|
+
# lets through. Scheme-anchored so a label is never mistaken for a
|
|
208
|
+
# target. The trailing punctuation that occurs in practice is
|
|
209
|
+
# markdown-structural, `)` closing a link target and `)**` closing
|
|
210
|
+
# one inside bold, so the set covers `)` and `*` and strips a run.
|
|
211
|
+
# Deliberately not filtered to note URLs: a body's other apex links
|
|
212
|
+
# are covered too.
|
|
213
|
+
while read -r u; do
|
|
214
|
+
[ -n "$u" ] || continue
|
|
215
|
+
case "$u" in
|
|
216
|
+
"https://$apex"|"https://$apex/"*|"http://$apex"|"http://$apex/"*) ;;
|
|
217
|
+
*) continue ;;
|
|
218
|
+
esac
|
|
219
|
+
code="$(curl -sS -m 20 -o /dev/null -w '%{http_code}' "$u")"
|
|
220
|
+
[ "$code" = 200 ] || failures+=("$tag: Release body URL $u did not answer 200 (got '$code')")
|
|
221
|
+
done < <(grep -oE 'https?://[^[:space:]<>"]+' <<<"$body" | sed -E 's/[).,;:!?*]+$//' | sort -u)
|
|
222
|
+
done
|
|
223
|
+
|
|
224
|
+
# Which zero-case a reader is in. A diagnostic, not an assertion — the
|
|
225
|
+
# rulings above are what make a vacuous pass impossible.
|
|
226
|
+
echo "release-body: $n_found note(s) found, $n_keyed keyed '$RELEASE_NOTE_TAG_KEY:', $n_released released of $n_tags remote tag(s), $n_checked checked"
|
|
227
|
+
|
|
106
228
|
# DoD hook: a workflow_dispatch with force_fail=true exercises the issue
|
|
107
229
|
# path on demand without waiting for a real outage.
|
|
108
230
|
if [ "$FORCE_FAIL" = true ]; then
|