@jeiemgi/cckit 0.7.1 → 0.9.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/.claude-plugin/plugin.json +1 -1
- package/AGENTS.md +15 -4
- package/README.md +25 -3
- package/bin/cckit +91 -8
- package/cckit.config.json +1 -1
- package/kit.config.schema.json +43 -2
- package/package.json +1 -1
- package/scripts/autopilot-test.sh +68 -0
- package/scripts/autopilot.sh +16 -10
- package/scripts/check.sh +14 -1
- package/scripts/copilot-loop-test.sh +3 -0
- package/scripts/guard-raw-git-ops-test.sh +73 -0
- package/scripts/init.sh +68 -8
- package/scripts/lib/agent-profile-test.sh +151 -0
- package/scripts/lib/agent-profile.sh +195 -0
- package/scripts/lib/agent-resolve-test.sh +156 -0
- package/scripts/lib/agent-resolve.sh +177 -0
- package/scripts/lib/branch-owner-test.sh +99 -0
- package/scripts/lib/branch-owner.sh +194 -0
- package/scripts/lib/captain-test.sh +86 -0
- package/scripts/lib/captain.sh +142 -7
- package/scripts/lib/contribute-root-test.sh +40 -0
- package/scripts/lib/contribute-root.sh +22 -0
- package/scripts/lib/effort-metrics.sh +14 -1
- package/scripts/lib/effort-ops-test.sh +54 -2
- package/scripts/lib/effort-ops.sh +243 -23
- package/scripts/lib/effort-parity-test.sh +5 -3
- package/scripts/lib/effort-slug.sh +16 -2
- package/scripts/lib/effort.sh +49 -15
- package/scripts/lib/gh-project.sh +14 -0
- package/scripts/lib/gh-rest-test.sh +301 -0
- package/scripts/lib/gh-rest.sh +289 -0
- package/scripts/lib/hook-refresh-test.sh +65 -0
- package/scripts/lib/hook-refresh.sh +62 -0
- package/scripts/lib/kit-config.sh +6 -0
- package/scripts/lib/kit-gc-test.sh +178 -1
- package/scripts/lib/kit-gc.sh +251 -55
- package/scripts/lib/kit-task-ops-test.sh +15 -0
- package/scripts/lib/kit-task-ops.sh +231 -58
- package/scripts/lib/kto-task-close-test.sh +83 -0
- package/scripts/lib/kto-task-pr-merge-test.sh +129 -0
- package/scripts/lib/kto-task-pr-test.sh +59 -0
- package/scripts/lib/orchestration-runtime-test.sh +142 -0
- package/scripts/lib/orchestration-runtime.sh +171 -0
- package/scripts/lib/review-stage-test.sh +241 -0
- package/scripts/lib/review-stage.sh +259 -0
- package/scripts/lib/stage-receipt-test.sh +252 -0
- package/scripts/lib/stage-receipt.sh +442 -0
- package/scripts/lib/test-env-test.sh +25 -0
- package/scripts/lib/test-env.sh +33 -0
- package/scripts/lib/worker-brief-test.sh +120 -0
- package/scripts/lib/worker-brief.sh +185 -0
- package/scripts/lib/worktree-issue.sh +14 -0
- package/scripts/lib/worktree-ports-test.sh +146 -0
- package/scripts/lib/worktree-start.sh +153 -8
- package/scripts/lib/zsh-safety-test.sh +67 -0
- package/scripts/orchestrate.sh +124 -22
- package/scripts/portable-test.sh +22 -1
- package/scripts/review-lint-baseline.txt +28 -0
- package/scripts/review-lint-test.sh +271 -0
- package/scripts/review-lint.sh +259 -0
- package/scripts/review-rules.conf +55 -0
- package/scripts/setup-labels.sh +21 -1
- package/scripts/skill-frontmatter-baseline.txt +24 -0
- package/scripts/skill-frontmatter-lint-test.sh +156 -0
- package/scripts/skill-frontmatter-lint.sh +182 -0
- package/scripts/task-sync.sh +8 -0
- package/scripts/test.sh +10 -1
- package/skills/kit-autopilot/SKILL.md +13 -1
- package/skills/kit-cleanup/SKILL.md +5 -3
- package/skills/kit-contribute/SKILL.md +6 -5
- package/skills/kit-effort-close/SKILL.md +8 -3
- package/skills/kit-effort-pr/SKILL.md +16 -95
- package/skills/kit-gc/SKILL.md +15 -10
- package/skills/kit-security-sweep/SKILL.md +4 -6
- package/skills/kit-ship/SKILL.md +1 -1
- package/skills/kit-task-pr/SKILL.md +2 -0
- package/templates/hooks/guard-raw-git-ops.sh.tmpl +193 -0
- package/templates/rules/branch-naming.md +6 -0
- package/templates/rules/effort-model.md +3 -0
- package/templates/rules/naming-and-ids.md +4 -1
- package/templates/settings/settings.json.tmpl +4 -2
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# stage-receipt-test.sh — one durable receipt per stage attempt (#322).
|
|
3
|
+
# errors: strict — a test runner: rc 1 on any failed assertion
|
|
4
|
+
# shellcheck shell=bash
|
|
5
|
+
set -u
|
|
6
|
+
|
|
7
|
+
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
8
|
+
command -v jq >/dev/null 2>&1 || { echo "stage-receipt-test: jq absent — skipping"; exit 0; }
|
|
9
|
+
|
|
10
|
+
# Every receipt lands in a scratch dir, never the real .cckit/.
|
|
11
|
+
KIT_STATE_DIR="$(mktemp -d)/state"; export KIT_STATE_DIR
|
|
12
|
+
|
|
13
|
+
# The GitHub mirror (#333) is ON by default, and `gh` is authenticated on a developer machine — an
|
|
14
|
+
# unguarded `sr_cli` case here would post real comments to the real repo from the test suite. Off
|
|
15
|
+
# for every case above; the mirror's own cases below stub `gh` and turn it back on explicitly.
|
|
16
|
+
CCKIT_RECEIPT_REMOTE=0; export CCKIT_RECEIPT_REMOTE
|
|
17
|
+
# shellcheck source=/dev/null
|
|
18
|
+
source "$ROOT/scripts/lib/stage-receipt.sh"
|
|
19
|
+
|
|
20
|
+
fail=0
|
|
21
|
+
t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
|
|
22
|
+
yes() { case "$2" in *"$3"*) echo "ok: $1" ;; *) echo "FAIL: $1 -> missing '$3' in [$2]"; fail=1 ;; esac; }
|
|
23
|
+
|
|
24
|
+
REPORT="$(cat <<'EOF'
|
|
25
|
+
Here is what I did, at some length, which is not part of the receipt.
|
|
26
|
+
|
|
27
|
+
outcome: pr-open
|
|
28
|
+
url: https://github.com/jeiemgi/cckit/pull/999
|
|
29
|
+
gate: pass
|
|
30
|
+
blocker: none
|
|
31
|
+
next stage: review
|
|
32
|
+
EOF
|
|
33
|
+
)"
|
|
34
|
+
|
|
35
|
+
# ── parsing E318.5's contract ──────────────────────────────────────────────────────────────────
|
|
36
|
+
p="$(printf '%s\n' "$REPORT" | sr_parse)"
|
|
37
|
+
t "outcome is parsed" "$(printf '%s' "$p" | cut -f1)" "pr-open"
|
|
38
|
+
t "url is parsed" "$(printf '%s' "$p" | cut -f2)" "https://github.com/jeiemgi/cckit/pull/999"
|
|
39
|
+
t "gate is parsed" "$(printf '%s' "$p" | cut -f3)" "pass"
|
|
40
|
+
t "blocker is parsed" "$(printf '%s' "$p" | cut -f4)" "none"
|
|
41
|
+
t "next stage is parsed" "$(printf '%s' "$p" | cut -f5)" "review"
|
|
42
|
+
# The worker's prose around the receipt must not become part of it.
|
|
43
|
+
t "surrounding prose is not captured" "$(printf '%s' "$p" | cut -f2)" "https://github.com/jeiemgi/cckit/pull/999"
|
|
44
|
+
# A worker that corrects itself means the correction; taking the first would record the retraction.
|
|
45
|
+
t "the LAST occurrence of a field wins" \
|
|
46
|
+
"$(printf 'outcome: blocked\noutcome: merged\n' | sr_parse | cut -f1)" "merged"
|
|
47
|
+
t "next_stage with an underscore also parses" \
|
|
48
|
+
"$(printf 'next_stage: docs\n' | sr_parse | cut -f5)" "docs"
|
|
49
|
+
|
|
50
|
+
# ── odd values are NAMED, not silently accepted ────────────────────────────────────────────────
|
|
51
|
+
t "a contract-shaped receipt has no invalid fields" "$(sr_invalid_fields pr-open pass review)" ""
|
|
52
|
+
t "an invented outcome is named" "$(sr_invalid_fields shipped pass review)" "outcome"
|
|
53
|
+
t "an invented gate is named" "$(sr_invalid_fields pr-open green review)" "gate"
|
|
54
|
+
t "an invented next stage is named" "$(sr_invalid_fields pr-open pass deploy)" "next_stage"
|
|
55
|
+
# `gate: fail — the failing check` keeps its detail; the failing check is the useful part.
|
|
56
|
+
t "gate detail after a fail is allowed" "$(sr_invalid_fields blocked "fail — shellcheck" none)" ""
|
|
57
|
+
sr_validate pr-open pass review 2>/dev/null; t "sr_validate passes a clean receipt" "$?" "0"
|
|
58
|
+
sr_validate shipped pass review 2>/dev/null; t "sr_validate is the hard-check form" "$?" "2"
|
|
59
|
+
yes "the hard check names the vocabulary" "$(sr_validate shipped pass review 2>&1)" "merged pr-open closed-no-op blocked"
|
|
60
|
+
|
|
61
|
+
# ── writing ────────────────────────────────────────────────────────────────────────────────────
|
|
62
|
+
t "the first attempt is 1" "$(sr_next_attempt 321 build)" "1"
|
|
63
|
+
out="$(printf '%s\n' "$REPORT" | sr_record 321 build 1 cheap low agents.default acceptEdits)"
|
|
64
|
+
t "the receipt is written where sr_path says" "$out" "$(sr_path 321 build 1)"
|
|
65
|
+
j="$(sr_read 321 build 1)"
|
|
66
|
+
t "the issue is recorded as a number" "$(printf '%s' "$j" | jq -r '.issue')" "321"
|
|
67
|
+
t "the five contract fields survive" \
|
|
68
|
+
"$(printf '%s' "$j" | jq -r '[.outcome,.gate,.blocker,.next_stage] | join("|")')" "pr-open|pass|none|review"
|
|
69
|
+
# #326: a run's effective agent and policy must be auditable after the fact.
|
|
70
|
+
t "the resolved profile is recorded" \
|
|
71
|
+
"$(printf '%s' "$j" | jq -r '[.profile,.tier,.profile_source,.permissions] | join("|")')" \
|
|
72
|
+
"cheap|low|agents.default|acceptEdits"
|
|
73
|
+
|
|
74
|
+
# ── idempotence: a retry must not double the record ────────────────────────────────────────────
|
|
75
|
+
printf '%s\n' "$REPORT" | sr_record 321 build 1 cheap low agents.default acceptEdits >/dev/null
|
|
76
|
+
t "re-recording one attempt leaves one file" \
|
|
77
|
+
"$(find "$(sr_dir)" -name '321-build-*.json' | wc -l | tr -d ' ')" "1"
|
|
78
|
+
t "a rewritten attempt keeps its content" "$(sr_read 321 build 1 | jq -r '.outcome')" "pr-open"
|
|
79
|
+
|
|
80
|
+
# A genuinely new try takes the next number, and neither attempt is lost.
|
|
81
|
+
t "the next attempt is 2" "$(sr_next_attempt 321 build)" "2"
|
|
82
|
+
printf 'outcome: blocked\nurl: -\ngate: fail — shellcheck\nblocker: needs a decision\nnext stage: none\n' \
|
|
83
|
+
| sr_record 321 build 2 cheap low agents.default acceptEdits >/dev/null
|
|
84
|
+
t "both attempts are on disk" \
|
|
85
|
+
"$(find "$(sr_dir)" -name '321-build-*.json' | wc -l | tr -d ' ')" "2"
|
|
86
|
+
t "attempt 1 is untouched by attempt 2" "$(sr_read 321 build 1 | jq -r '.outcome')" "pr-open"
|
|
87
|
+
t "sr_latest returns the newest attempt" "$(sr_latest 321 build | jq -r '.outcome')" "blocked"
|
|
88
|
+
t "a fail keeps which check failed" "$(sr_read 321 build 2 | jq -r '.gate')" "fail — shellcheck"
|
|
89
|
+
|
|
90
|
+
# ── an odd value is RECORDED and flagged, never discarded ──────────────────────────────────────
|
|
91
|
+
# Refusing would make "agent crashed" and "agent finished but said it oddly" look identical, and
|
|
92
|
+
# only the first needs the stage re-run. Keeping the value is what lets a wave keep moving.
|
|
93
|
+
printf 'outcome: shipped\nurl: https://x/1\ngate: pass\nblocker: none\nnext stage: review\n' \
|
|
94
|
+
| sr_record 321 review 1 cheap low agents.default '' >/dev/null 2>&1
|
|
95
|
+
t "an odd receipt is still written" "$?" "0"
|
|
96
|
+
t "the odd value is kept verbatim" "$(sr_read 321 review 1 | jq -r '.outcome')" "shipped"
|
|
97
|
+
t "the offending field is named" "$(sr_read 321 review 1 | jq -r '.invalid | join(",")')" "outcome"
|
|
98
|
+
t "a clean receipt flags nothing" "$(sr_read 321 build 1 | jq -r '.invalid | length')" "0"
|
|
99
|
+
yes "sr_list surfaces the flag so a wave scan cannot miss it" "$(sr_list 321)" "invalid: outcome"
|
|
100
|
+
|
|
101
|
+
# The ONE hard refusal: a report with no outcome line is not an odd receipt, it is no receipt.
|
|
102
|
+
printf 'I could not figure this out.\n' | sr_record 321 docs 1 cheap low agents.default '' >/dev/null 2>&1
|
|
103
|
+
t "a report with no outcome line is refused" "$?" "2"
|
|
104
|
+
t "the refused report left no file" "$([ -f "$(sr_path 321 docs 1)" ] && echo yes || echo no)" "no"
|
|
105
|
+
|
|
106
|
+
# ── listing ────────────────────────────────────────────────────────────────────────────────────
|
|
107
|
+
t "sr_list rows one receipt each" "$(sr_list 321 | wc -l | tr -d ' ')" "3"
|
|
108
|
+
yes "sr_list names the outcome" "$(sr_list 321)" "pr-open"
|
|
109
|
+
t "sr_list of an unknown issue is empty" "$(sr_list 999 | wc -l | tr -d ' ')" "0"
|
|
110
|
+
t "sr_read of a missing receipt is rc 1" "$(sr_read 321 docs 1 >/dev/null 2>&1; echo $?)" "1"
|
|
111
|
+
t "sr_latest with no receipts is rc 1" "$(sr_latest 321 docs >/dev/null 2>&1; echo $?)" "1"
|
|
112
|
+
|
|
113
|
+
# ── the `cckit receipt` verb ───────────────────────────────────────────────────────────────────
|
|
114
|
+
# The WORKER records its own receipt: cckit never reads pane output, because #326 requires that
|
|
115
|
+
# pane history (off by default, may hold secrets) is never a dependency.
|
|
116
|
+
sr_cli 500 --stage build --profile cheap --tier low --source agents.default --permissions plan \
|
|
117
|
+
<<'EOF' >/dev/null
|
|
118
|
+
outcome: pr-open
|
|
119
|
+
url: https://github.com/x/y/pull/1
|
|
120
|
+
gate: pass
|
|
121
|
+
blocker: none
|
|
122
|
+
next stage: review
|
|
123
|
+
EOF
|
|
124
|
+
t "the verb allocates the first attempt" "$(sr_read 500 build 1 | jq -r '.attempt')" "1"
|
|
125
|
+
t "the verb records the flags it was given" \
|
|
126
|
+
"$(sr_read 500 build 1 | jq -r '[.profile,.tier,.profile_source,.permissions] | join("|")')" \
|
|
127
|
+
"cheap|low|agents.default|plan"
|
|
128
|
+
|
|
129
|
+
# Retry after an unknown result: the SAME five fields must not become a second attempt.
|
|
130
|
+
sr_cli 500 --stage build <<'EOF' >/dev/null
|
|
131
|
+
outcome: pr-open
|
|
132
|
+
url: https://github.com/x/y/pull/1
|
|
133
|
+
gate: pass
|
|
134
|
+
blocker: none
|
|
135
|
+
next stage: review
|
|
136
|
+
EOF
|
|
137
|
+
t "an identical re-run rewrites its own attempt" \
|
|
138
|
+
"$(find "$(sr_dir)" -name '500-build-*.json' | wc -l | tr -d ' ')" "1"
|
|
139
|
+
|
|
140
|
+
# A re-run that says something DIFFERENT is a real second try and keeps both records.
|
|
141
|
+
sr_cli 500 --stage build <<'EOF' >/dev/null
|
|
142
|
+
outcome: merged
|
|
143
|
+
url: https://github.com/x/y/pull/1
|
|
144
|
+
gate: pass
|
|
145
|
+
blocker: none
|
|
146
|
+
next stage: none
|
|
147
|
+
EOF
|
|
148
|
+
t "a changed re-run takes the next attempt" \
|
|
149
|
+
"$(find "$(sr_dir)" -name '500-build-*.json' | wc -l | tr -d ' ')" "2"
|
|
150
|
+
t "the earlier attempt still says what it said" "$(sr_read 500 build 1 | jq -r '.outcome')" "pr-open"
|
|
151
|
+
t "show with no attempt gives the latest" "$(sr_cli show 500 build | jq -r '.outcome')" "merged"
|
|
152
|
+
t "show with an attempt gives that one" "$(sr_cli show 500 build 1 | jq -r '.outcome')" "pr-open"
|
|
153
|
+
|
|
154
|
+
sr_cli 500 --stage deploy </dev/null >/dev/null 2>&1; t "an unknown stage is refused" "$?" "2"
|
|
155
|
+
sr_cli 500 </dev/null >/dev/null 2>&1; t "a missing --stage is refused" "$?" "2"
|
|
156
|
+
sr_cli abc --stage build </dev/null >/dev/null 2>&1; t "a non-numeric issue is refused" "$?" "2"
|
|
157
|
+
sr_cli 500 --stage build --nope x </dev/null >/dev/null 2>&1; t "an unknown flag is refused" "$?" "2"
|
|
158
|
+
yes "the verb help names the stages" "$(sr_cli --help 2>&1)" "build review design docs none"
|
|
159
|
+
|
|
160
|
+
# ── the receipts dir is shared, not per-worktree ───────────────────────────────────────────────
|
|
161
|
+
# kit_state_dir anchors a relative override to the repo's shared root, so standing somewhere else
|
|
162
|
+
# must resolve to the SAME directory — a receipt a worker writes in its isolation worktree has to
|
|
163
|
+
# be readable by the captain.
|
|
164
|
+
here="$(sr_dir)"
|
|
165
|
+
there="$(cd /tmp && KIT_STATE_DIR="$KIT_STATE_DIR" bash -c "source '$ROOT/scripts/lib/stage-receipt.sh'; sr_dir")"
|
|
166
|
+
t "sr_dir is the same from another directory" "$there" "$here"
|
|
167
|
+
|
|
168
|
+
# ── the GitHub mirror (#333) ───────────────────────────────────────────────────────────────────
|
|
169
|
+
# `gh` is stubbed on PATH: it logs every invocation and serves a canned comment list, so the upsert
|
|
170
|
+
# is exercised end to end with no network and no real repo touched.
|
|
171
|
+
ghtmp="$(mktemp -d)"; mkdir -p "$ghtmp/bin"
|
|
172
|
+
export GH_LOG="$ghtmp/gh.log"; export GH_COMMENTS="$ghtmp/comments.txt"
|
|
173
|
+
: > "$GH_LOG"; : > "$GH_COMMENTS"
|
|
174
|
+
cat > "$ghtmp/bin/gh" <<'SH'
|
|
175
|
+
#!/usr/bin/env bash
|
|
176
|
+
echo "$*" >> "$GH_LOG"
|
|
177
|
+
case "$*" in
|
|
178
|
+
*"issues/"*"/comments"*) cat "$GH_COMMENTS" ;; # the listing (--jq is applied by the real gh)
|
|
179
|
+
*) : ;;
|
|
180
|
+
esac
|
|
181
|
+
exit "${GH_RC:-0}"
|
|
182
|
+
SH
|
|
183
|
+
chmod +x "$ghtmp/bin/gh"
|
|
184
|
+
OLDPATH="$PATH"; PATH="$ghtmp/bin:$PATH"; export PATH
|
|
185
|
+
|
|
186
|
+
# ── pure: the marker is the identity, and it is per ATTEMPT ────────────────────────────────────
|
|
187
|
+
t "the marker keys on issue, stage and attempt" \
|
|
188
|
+
"$(_sr_marker 42 build 2)" "<!-- cckit:receipt key=42-build-2 -->"
|
|
189
|
+
yes "a different attempt is a different marker" "$(_sr_marker 42 build 3)" "42-build-3"
|
|
190
|
+
|
|
191
|
+
# ── pure: matching finds only this receipt's own comment ───────────────────────────────────────
|
|
192
|
+
listing="$(printf '%s\t%s\n%s\t%s\n' \
|
|
193
|
+
111 '"<!-- cckit:receipt key=42-build-1 --> other"' \
|
|
194
|
+
222 '"<!-- cckit:receipt key=42-build-2 --> mine"')"
|
|
195
|
+
t "the matching attempt's comment id" "$(printf '%s\n' "$listing" | _sr_mirror_match_id "$(_sr_marker 42 build 2)")" "222"
|
|
196
|
+
printf '%s\n' "$listing" | _sr_mirror_match_id "$(_sr_marker 42 build 9)" >/dev/null 2>&1
|
|
197
|
+
t "no match returns rc 1" "$?" "1"
|
|
198
|
+
|
|
199
|
+
# The receipt the mirror cases post. Written with the mirror off so this setup step posts nothing.
|
|
200
|
+
printf '%s\n' "$REPORT" | CCKIT_RECEIPT_REMOTE=0 sr_cli 42 --stage build --attempt 1 >/dev/null 2>&1
|
|
201
|
+
|
|
202
|
+
# ── a first mirror CREATES ─────────────────────────────────────────────────────────────────────
|
|
203
|
+
CCKIT_RECEIPT_REMOTE=1 sr_mirror 42 build 1 >/dev/null 2>&1
|
|
204
|
+
t "a first mirror creates" "$SR_MIRROR_LAST_RESULT" "created"
|
|
205
|
+
yes "and it commented on the issue" "$(cat "$GH_LOG")" "issue comment 42"
|
|
206
|
+
|
|
207
|
+
# ── the same attempt again EDITS the one comment, it does not append a second ──────────────────
|
|
208
|
+
printf '%s\t%s\n' 777 '"<!-- cckit:receipt key=42-build-1 --> already here"' > "$GH_COMMENTS"
|
|
209
|
+
: > "$GH_LOG"
|
|
210
|
+
CCKIT_RECEIPT_REMOTE=1 sr_mirror 42 build 1 >/dev/null 2>&1
|
|
211
|
+
t "a second identical run edits" "$SR_MIRROR_LAST_RESULT" "updated"
|
|
212
|
+
yes "and it PATCHed the existing comment" "$(cat "$GH_LOG")" "issues/comments/777"
|
|
213
|
+
t "it did not also create one" "$(grep -c 'issue comment' "$GH_LOG" || true)" "0"
|
|
214
|
+
|
|
215
|
+
# ── a FAILED lookup must not post: a blind post is how a duplicate appears ─────────────────────
|
|
216
|
+
: > "$GH_LOG"
|
|
217
|
+
GH_RC=1 CCKIT_RECEIPT_REMOTE=1 sr_mirror 42 build 1 >/dev/null 2>&1
|
|
218
|
+
t "a failed lookup does not post" "$SR_MIRROR_LAST_RESULT" "lookup-failed"
|
|
219
|
+
t "and nothing was created" "$(grep -c 'issue comment' "$GH_LOG" || true)" "0"
|
|
220
|
+
|
|
221
|
+
# ── an unreachable GitHub still leaves the local file, and exits 0 ─────────────────────────────
|
|
222
|
+
GH_RC=1 CCKIT_RECEIPT_REMOTE=1 sr_mirror 42 build 1 >/dev/null 2>&1
|
|
223
|
+
t "an unreachable GitHub exits 0" "$?" "0"
|
|
224
|
+
t "and the local receipt is still there" "$([ -f "$(sr_path 42 build 1)" ] && echo yes)" "yes"
|
|
225
|
+
|
|
226
|
+
# ── --no-remote writes the file and posts nothing ──────────────────────────────────────────────
|
|
227
|
+
: > "$GH_LOG"
|
|
228
|
+
out="$(printf '%s\n' "$REPORT" | CCKIT_RECEIPT_REMOTE=1 sr_cli 43 --stage build --attempt 1 --no-remote 2>/dev/null)"
|
|
229
|
+
t "--no-remote still writes the receipt" "$([ -f "$out" ] && echo yes)" "yes"
|
|
230
|
+
t "--no-remote posts nothing" "$(wc -l < "$GH_LOG" | tr -d ' ')" "0"
|
|
231
|
+
# SR_MIRROR_LAST_RESULT is checked on sr_mirror directly, not through sr_cli: a command
|
|
232
|
+
# substitution runs in a subshell, so a variable the callee sets never reaches this shell.
|
|
233
|
+
|
|
234
|
+
# ── CCKIT_RECEIPT_REMOTE=0 is the same switch, as an env var ───────────────────────────────────
|
|
235
|
+
: > "$GH_LOG"
|
|
236
|
+
CCKIT_RECEIPT_REMOTE=0 sr_mirror 42 build 1 >/dev/null 2>&1
|
|
237
|
+
t "the env var turns the mirror off" "$SR_MIRROR_LAST_RESULT" "no-remote"
|
|
238
|
+
t "and posts nothing" "$(wc -l < "$GH_LOG" | tr -d ' ')" "0"
|
|
239
|
+
|
|
240
|
+
# ── the body carries the receipt verbatim ──────────────────────────────────────────────────────
|
|
241
|
+
body="$(_sr_mirror_body 42 build 1 "$(sr_path 42 build 1)")"
|
|
242
|
+
yes "the body carries its marker" "$body" "<!-- cckit:receipt key=42-build-1 -->"
|
|
243
|
+
yes "the body names the stage" "$body" 'stage `build`'
|
|
244
|
+
yes "the body embeds the JSON" "$body" '"outcome": "pr-open"'
|
|
245
|
+
|
|
246
|
+
PATH="$OLDPATH"; export PATH
|
|
247
|
+
rm -rf "$ghtmp"
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
rm -rf "$(dirname "$KIT_STATE_DIR")"
|
|
251
|
+
[ "$fail" -eq 0 ] && echo "ALL OK" || echo "stage receipt: FAILURES"
|
|
252
|
+
exit "$fail"
|