@antelopejs/dms 0.18.1 → 0.18.2
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/CHANGELOG.md +18 -0
- package/README.md +1 -1
- package/bin/control/commands-verify.mjs +5 -23
- package/bin/control/verify/decode.mjs +0 -15
- package/bin/control/verify/decode.test.mjs +1 -14
- package/bin/control/verify/verdict.mjs +9 -42
- package/bin/dms-control.mjs +0 -1
- package/package.json +1 -1
- package/bin/control/verify/publish.mjs +0 -186
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v0.18.2
|
|
4
|
+
|
|
5
|
+
[compare changes](https://github.com/AntelopeJS/dms/compare/v0.18.1...v0.18.2)
|
|
6
|
+
|
|
7
|
+
### 💅 Refactors
|
|
8
|
+
|
|
9
|
+
- **dms-control:** Remove publish, its evidence branch, comment and status ([#838](https://github.com/AntelopeJS/dms/pull/838))
|
|
10
|
+
|
|
11
|
+
### 📖 Documentation
|
|
12
|
+
|
|
13
|
+
- **readme:** Lead with the problem and add animated section banners ([#833](https://github.com/AntelopeJS/dms/pull/833))
|
|
14
|
+
- **readme:** Open on the Helio tour and explain the Connect flow ([#834](https://github.com/AntelopeJS/dms/pull/834))
|
|
15
|
+
- **getting-started:** Title the starter guide "Quickstart" ([#837](https://github.com/AntelopeJS/dms/pull/837))
|
|
16
|
+
|
|
17
|
+
### ❤️ Contributors
|
|
18
|
+
|
|
19
|
+
- Antony Rizzitelli ([@Upd4ting](http://github.com/Upd4ting))
|
|
20
|
+
|
|
3
21
|
## v0.18.1
|
|
4
22
|
|
|
5
23
|
[compare changes](https://github.com/AntelopeJS/dms/compare/v0.18.0...v0.18.1)
|
package/README.md
CHANGED
|
@@ -57,7 +57,7 @@ When the backend answers, start the dashboard in a second terminal, from the sam
|
|
|
57
57
|
pnpm frontend:dev # dashboard on http://localhost:3001
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
-
Open the address that the backend logs after `No owner exists yet`, and create the first administrator. The [Tutorial](https://dms.antelopejs.com/docs/getting-started/tutorial) builds on this project. To start your own project instead, see [
|
|
60
|
+
Open the address that the backend logs after `No owner exists yet`, and create the first administrator. The [Tutorial](https://dms.antelopejs.com/docs/getting-started/tutorial) builds on this project. To start your own project instead, see [Quickstart](https://dms.antelopejs.com/docs/getting-started/quickstart). A page is a class whose static fields are blocks:
|
|
61
61
|
|
|
62
62
|
```ts
|
|
63
63
|
import { PageController, RegisterPage, pagesCategory } from "@antelopejs/interface-dms/page";
|
|
@@ -11,12 +11,6 @@ import {
|
|
|
11
11
|
} from "./verify/formal.mjs";
|
|
12
12
|
import { readJudgement } from "./verify/judgement.mjs";
|
|
13
13
|
import { checkMap, planFor } from "./verify/map.mjs";
|
|
14
|
-
import {
|
|
15
|
-
postComment,
|
|
16
|
-
pushEvidence,
|
|
17
|
-
readStatus,
|
|
18
|
-
setStatus,
|
|
19
|
-
} from "./verify/publish.mjs";
|
|
20
14
|
import { journeysFile, loadSkill } from "./verify/skill.mjs";
|
|
21
15
|
import { renderVerdict } from "./verify/verdict.mjs";
|
|
22
16
|
|
|
@@ -146,15 +140,14 @@ async function commandFormal(dir, values) {
|
|
|
146
140
|
}
|
|
147
141
|
|
|
148
142
|
/**
|
|
149
|
-
* @param {string} command `verdict` or `publish`
|
|
150
143
|
* @param {string} dir The run root
|
|
151
144
|
* @param {Values} values The options of the command line
|
|
152
145
|
* @returns {Promise<number>} The exit code
|
|
153
146
|
*/
|
|
154
|
-
async function
|
|
147
|
+
async function commandVerdict(dir, values) {
|
|
155
148
|
const pr = Number(values.pr);
|
|
156
149
|
if (!Number.isInteger(pr) || pr <= 0) {
|
|
157
|
-
print(
|
|
150
|
+
print("verdict needs --pr <number>");
|
|
158
151
|
return 2;
|
|
159
152
|
}
|
|
160
153
|
const state = loadRun(dir);
|
|
@@ -167,22 +160,12 @@ async function commandJudge(command, dir, values) {
|
|
|
167
160
|
values.all,
|
|
168
161
|
);
|
|
169
162
|
print(verdict.markdown);
|
|
170
|
-
|
|
171
|
-
print(`evidence commit ${pushEvidence(skill, state, verdict)}`);
|
|
172
|
-
const comment = postComment(skill, verdict);
|
|
173
|
-
print(`comment ${comment}`);
|
|
174
|
-
const error = setStatus(skill, verdict, comment);
|
|
175
|
-
if (error)
|
|
176
|
-
print(`FAIL status verify on ${verdict.headSha} not set: ${error}`);
|
|
177
|
-
print(
|
|
178
|
-
`status verify on ${verdict.headSha}: ${readStatus(skill, verdict.headSha)}`,
|
|
179
|
-
);
|
|
180
|
-
return error || verdict.result === "FAIL" ? 1 : 0;
|
|
163
|
+
return verdict.result === "FAIL" ? 1 : 0;
|
|
181
164
|
}
|
|
182
165
|
|
|
183
166
|
/**
|
|
184
167
|
* Runs a command of the verification harness: `map`, `plan`, `journey`,
|
|
185
|
-
* `doors`, `formal
|
|
168
|
+
* `doors`, `formal` and `verdict`.
|
|
186
169
|
*
|
|
187
170
|
* @param {string} command The command
|
|
188
171
|
* @param {string[]} rest Its positional arguments
|
|
@@ -202,8 +185,7 @@ export function runVerifyCommand(command, rest, values) {
|
|
|
202
185
|
case "formal":
|
|
203
186
|
return commandFormal(rest[0], values);
|
|
204
187
|
case "verdict":
|
|
205
|
-
|
|
206
|
-
return commandJudge(command, rest[0], values);
|
|
188
|
+
return commandVerdict(rest[0], values);
|
|
207
189
|
default:
|
|
208
190
|
return Promise.resolve(undefined);
|
|
209
191
|
}
|
|
@@ -115,11 +115,6 @@ export const isRawJudgement = objectOf(
|
|
|
115
115
|
},
|
|
116
116
|
);
|
|
117
117
|
|
|
118
|
-
/** What `gh api repos/<repo>/commits/<sha>/statuses` answers, as far as the harness reads it. */
|
|
119
|
-
export const isCommitStatuses = arrayOf(
|
|
120
|
-
objectOf({ context: isString, state: isString }),
|
|
121
|
-
);
|
|
122
|
-
|
|
123
118
|
const isRegexOrNull = nullable(instanceOf(RegExp));
|
|
124
119
|
|
|
125
120
|
const isFormalCheck = objectOf(
|
|
@@ -206,16 +201,6 @@ export function decodeRawJudgement(stored, source) {
|
|
|
206
201
|
return decode(isRawJudgement, stored, source, "a verifier's judgement");
|
|
207
202
|
}
|
|
208
203
|
|
|
209
|
-
/**
|
|
210
|
-
* @param {unknown} answer What `gh api` printed, parsed
|
|
211
|
-
* @param {string} source The command
|
|
212
|
-
* @returns {{ context: string, state: string }[]} The statuses
|
|
213
|
-
* @throws When the value is not a list of statuses
|
|
214
|
-
*/
|
|
215
|
-
export function decodeCommitStatuses(answer, source) {
|
|
216
|
-
return decode(isCommitStatuses, answer, source, "a list of commit statuses");
|
|
217
|
-
}
|
|
218
|
-
|
|
219
204
|
/**
|
|
220
205
|
* The journey results a run recorded for a feature.
|
|
221
206
|
*
|
|
@@ -4,7 +4,7 @@ import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
|
4
4
|
import { tmpdir } from "node:os";
|
|
5
5
|
import { join } from "node:path";
|
|
6
6
|
import test from "node:test";
|
|
7
|
-
import {
|
|
7
|
+
import { readFeatureResults } from "./decode.mjs";
|
|
8
8
|
import { readFormalResult } from "./formal.mjs";
|
|
9
9
|
import { readJudgement } from "./judgement.mjs";
|
|
10
10
|
import { loadSkill } from "./skill.mjs";
|
|
@@ -116,19 +116,6 @@ await test("a journey result whose check does not say pass or fail is refused",
|
|
|
116
116
|
);
|
|
117
117
|
});
|
|
118
118
|
|
|
119
|
-
await test("a status list without a context and state is refused", () => {
|
|
120
|
-
const statuses = [{ context: "verify", state: "success", id: 1 }];
|
|
121
|
-
assert.deepEqual(decodeCommitStatuses(statuses, "gh"), statuses);
|
|
122
|
-
assert.throws(
|
|
123
|
-
() => decodeCommitStatuses({ message: "Not Found" }, "gh api statuses"),
|
|
124
|
-
/gh api statuses is malformed/,
|
|
125
|
-
);
|
|
126
|
-
assert.throws(
|
|
127
|
-
() => decodeCommitStatuses([{ context: "verify" }], "gh"),
|
|
128
|
-
/malformed: expected a list of commit statuses/,
|
|
129
|
-
);
|
|
130
|
-
});
|
|
131
|
-
|
|
132
119
|
const CONFIG = `export default {
|
|
133
120
|
playground: "playground",
|
|
134
121
|
prepare: [["pnpm", "install"]],
|
|
@@ -18,19 +18,6 @@ import {
|
|
|
18
18
|
import { planFor } from "./map.mjs";
|
|
19
19
|
import { journeysFile } from "./skill.mjs";
|
|
20
20
|
|
|
21
|
-
/**
|
|
22
|
-
* The GitHub `owner/repo` of the checkout's origin remote.
|
|
23
|
-
*
|
|
24
|
-
* @param {string} repo The checkout
|
|
25
|
-
* @returns {string} The repository
|
|
26
|
-
*/
|
|
27
|
-
export function originRepository(repo) {
|
|
28
|
-
const url = git(["remote", "get-url", "origin"], repo);
|
|
29
|
-
const match = /github\.com[:/](.+?)(?:\.git)?$/.exec(url);
|
|
30
|
-
if (!match) throw new Error(`origin ${url} is not a GitHub repository`);
|
|
31
|
-
return match[1];
|
|
32
|
-
}
|
|
33
|
-
|
|
34
21
|
/**
|
|
35
22
|
* @param {string} sha A commit
|
|
36
23
|
* @returns {string} Its first seven characters
|
|
@@ -61,10 +48,9 @@ function readResults(state, feature) {
|
|
|
61
48
|
* @param {import("./skill.mjs").Skill} skill The skill
|
|
62
49
|
* @param {import("../run-state.mjs").RunState} state The run
|
|
63
50
|
* @param {import("./types.mjs").Plan} plan The plan
|
|
64
|
-
* @param {(path: string) => string} link The evidence link of a path
|
|
65
51
|
* @returns {Promise<{ rows: string[], reasons: string[] }>} The table rows and why the verdict fails
|
|
66
52
|
*/
|
|
67
|
-
async function journeyRows(skill, state, plan
|
|
53
|
+
async function journeyRows(skill, state, plan) {
|
|
68
54
|
/** @type {string[]} */
|
|
69
55
|
const rows = [];
|
|
70
56
|
/** @type {string[]} */
|
|
@@ -91,7 +77,7 @@ async function journeyRows(skill, state, plan, link) {
|
|
|
91
77
|
const time =
|
|
92
78
|
result.ms === undefined ? "-" : `${formatSeconds(result.ms)} s`;
|
|
93
79
|
rows.push(
|
|
94
|
-
`| ${feature} | \`${result.journey}\`: ${result.entryPoint} | ${outcome}: ${result.title} | ${time} |
|
|
80
|
+
`| ${feature} | \`${result.journey}\`: ${result.entryPoint} | ${outcome}: ${result.title} | ${time} | \`${result.folder}\` |`,
|
|
95
81
|
);
|
|
96
82
|
}
|
|
97
83
|
}
|
|
@@ -151,10 +137,9 @@ function doorsSection(judgement) {
|
|
|
151
137
|
* @param {import("./skill.mjs").Skill} skill The skill
|
|
152
138
|
* @param {import("../run-state.mjs").RunState} state The run
|
|
153
139
|
* @param {import("./types.mjs").Plan} plan The plan
|
|
154
|
-
* @param {(path: string) => string} link The evidence link of a path
|
|
155
140
|
* @returns {{ reasons: string[], lines: string[] }} Why the formal checks fail the verdict, and their lines
|
|
156
141
|
*/
|
|
157
|
-
function formalSection(skill, state, plan
|
|
142
|
+
function formalSection(skill, state, plan) {
|
|
158
143
|
const reasons = [];
|
|
159
144
|
const lines = [];
|
|
160
145
|
const touched = touchedFormalChecks(skill, plan.changed).map(
|
|
@@ -187,7 +172,7 @@ function formalSection(skill, state, plan, link) {
|
|
|
187
172
|
? "covers the diff, gates the verdict"
|
|
188
173
|
: "does not cover the diff, informational";
|
|
189
174
|
lines.push(
|
|
190
|
-
`\`${check.name}\` (${role}): ${summary}.
|
|
175
|
+
`\`${check.name}\` (${role}): ${summary}. Evidence: \`${result.folder}\``,
|
|
191
176
|
);
|
|
192
177
|
}
|
|
193
178
|
return { reasons, lines };
|
|
@@ -212,20 +197,12 @@ function docsReasons(judgement, plan) {
|
|
|
212
197
|
/**
|
|
213
198
|
* @param {import("./skill.mjs").Skill} skill The skill
|
|
214
199
|
* @param {import("./types.mjs").VerdictCore} verdict The verdict
|
|
215
|
-
* @param {{ plan: import("./types.mjs").Plan, judgement: import("./types.mjs").Judgement, journeys: Awaited<ReturnType<typeof journeyRows>>, formal: ReturnType<typeof formalSection>, timing: import("../timing.mjs").TimingSummary, reasons: string[], attention: string[]
|
|
200
|
+
* @param {{ plan: import("./types.mjs").Plan, judgement: import("./types.mjs").Judgement, journeys: Awaited<ReturnType<typeof journeyRows>>, formal: ReturnType<typeof formalSection>, timing: import("../timing.mjs").TimingSummary, reasons: string[], attention: string[] }} parts What the verdict is rendered from
|
|
216
201
|
* @returns {string} The verdict as Markdown
|
|
217
202
|
*/
|
|
218
203
|
function markdown(skill, verdict, parts) {
|
|
219
|
-
const {
|
|
220
|
-
|
|
221
|
-
judgement,
|
|
222
|
-
journeys,
|
|
223
|
-
formal,
|
|
224
|
-
timing,
|
|
225
|
-
reasons,
|
|
226
|
-
attention,
|
|
227
|
-
link,
|
|
228
|
-
} = parts;
|
|
204
|
+
const { plan, judgement, journeys, formal, timing, reasons, attention } =
|
|
205
|
+
parts;
|
|
229
206
|
const touched = plan.touched.map(
|
|
230
207
|
(entry) =>
|
|
231
208
|
`\`${entry.feature}\` (diff: ${entry.files.map((file) => `\`${file}\``).join(", ")})`,
|
|
@@ -287,8 +264,6 @@ function markdown(skill, verdict, parts) {
|
|
|
287
264
|
"### Attention",
|
|
288
265
|
...bullets(attention, "Nothing."),
|
|
289
266
|
"",
|
|
290
|
-
`Evidence: \`verify-evidence\` branch, [\`pr-${verdict.pr}/${plan.headSha}/\`](${link("")})`,
|
|
291
|
-
"",
|
|
292
267
|
].join("\n");
|
|
293
268
|
}
|
|
294
269
|
|
|
@@ -311,21 +286,14 @@ export async function renderVerdict(skill, state, pr, judgement, all = false) {
|
|
|
311
286
|
["log", "-1", "--format=%H", "--", relative(skill.repo, skill.dir)],
|
|
312
287
|
skill.repo,
|
|
313
288
|
) || plan.headSha;
|
|
314
|
-
const repository = originRepository(skill.repo);
|
|
315
|
-
/**
|
|
316
|
-
* @param {string} path A path under the run's evidence
|
|
317
|
-
* @returns {string} Its link on the evidence branch
|
|
318
|
-
*/
|
|
319
|
-
const link = (path) =>
|
|
320
|
-
`https://github.com/${repository}/tree/verify-evidence/pr-${pr}/${plan.headSha}/${path}`;
|
|
321
289
|
const reasons = [];
|
|
322
290
|
if (plan.headSha !== state.headSha) {
|
|
323
291
|
reasons.push(
|
|
324
292
|
`the run was created at ${short(state.headSha ?? "unknown")} but HEAD is ${short(plan.headSha)}`,
|
|
325
293
|
);
|
|
326
294
|
}
|
|
327
|
-
const journeys = await journeyRows(skill, state, plan
|
|
328
|
-
const formal = formalSection(skill, state, plan
|
|
295
|
+
const journeys = await journeyRows(skill, state, plan);
|
|
296
|
+
const formal = formalSection(skill, state, plan);
|
|
329
297
|
reasons.push(
|
|
330
298
|
...journeys.reasons,
|
|
331
299
|
...plan.unmapped.map((file) => `unmapped surface ${file}`),
|
|
@@ -345,7 +313,6 @@ export async function renderVerdict(skill, state, pr, judgement, all = false) {
|
|
|
345
313
|
timing: summarize(readTimings(state.evidence)),
|
|
346
314
|
reasons,
|
|
347
315
|
attention,
|
|
348
|
-
link,
|
|
349
316
|
});
|
|
350
317
|
writeFileSync(join(state.evidence, "verdict.md"), text);
|
|
351
318
|
writeFileSync(
|
package/bin/dms-control.mjs
CHANGED
|
@@ -39,7 +39,6 @@ Verify a change (the .agents/skills/verify-* folder of the checkout, or --skill
|
|
|
39
39
|
formal <run> [--all] run the formal checks that cover the diff (or every one)
|
|
40
40
|
verdict <run> --pr <n> [--all] render evidence/verdict.md from the results and evidence/judgement.json
|
|
41
41
|
(--all requires every feature, for a release)
|
|
42
|
-
publish <run> --pr <n> [--all] push the evidence, comment the verdict, set the verify status
|
|
43
42
|
`;
|
|
44
43
|
|
|
45
44
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antelopejs/dms",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.2",
|
|
4
4
|
"description": "AntelopeJS DMS. Plug in your PostgreSQL, MongoDB or RethinkDB database and your coding agent builds a back office and analytics dashboard as typed TypeScript. Real-time updates on the data the DMS manages.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"antelopejs",
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import { execFileSync, spawnSync } from "node:child_process";
|
|
2
|
-
import { cpSync, mkdirSync, mkdtempSync, rmSync } from "node:fs";
|
|
3
|
-
import { tmpdir } from "node:os";
|
|
4
|
-
import { join } from "node:path";
|
|
5
|
-
import { git } from "../git.mjs";
|
|
6
|
-
import { decodeCommitStatuses } from "./decode.mjs";
|
|
7
|
-
import { originRepository } from "./verdict.mjs";
|
|
8
|
-
|
|
9
|
-
const EVIDENCE_BRANCH = "verify-evidence";
|
|
10
|
-
const SCRATCH_BRANCH = "verify-evidence-scratch";
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @param {string} repo The checkout
|
|
14
|
-
* @returns {boolean} Whether origin holds the evidence branch
|
|
15
|
-
*/
|
|
16
|
-
function remoteBranchExists(repo) {
|
|
17
|
-
return git(["ls-remote", "--heads", "origin", EVIDENCE_BRANCH], repo) !== "";
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Commits the run's evidence under `pr-<n>/<sha>/` of the orphan
|
|
22
|
-
* `verify-evidence` branch and pushes it, from a temporary worktree so the
|
|
23
|
-
* checkout under review is never touched.
|
|
24
|
-
*
|
|
25
|
-
* @param {import("./skill.mjs").Skill} skill The skill
|
|
26
|
-
* @param {import("../run-state.mjs").RunState} state The run
|
|
27
|
-
* @param {{ pr: number, headSha: string, result: string }} verdict The verdict
|
|
28
|
-
* @returns {string} The pushed evidence commit
|
|
29
|
-
*/
|
|
30
|
-
export function pushEvidence(skill, state, verdict) {
|
|
31
|
-
const repo = skill.repo;
|
|
32
|
-
const worktree = mkdtempSync(join(tmpdir(), "verify-evidence-"));
|
|
33
|
-
try {
|
|
34
|
-
if (remoteBranchExists(repo)) {
|
|
35
|
-
git(
|
|
36
|
-
[
|
|
37
|
-
"fetch",
|
|
38
|
-
"--quiet",
|
|
39
|
-
"origin",
|
|
40
|
-
`${EVIDENCE_BRANCH}:refs/remotes/origin/${EVIDENCE_BRANCH}`,
|
|
41
|
-
],
|
|
42
|
-
repo,
|
|
43
|
-
);
|
|
44
|
-
git(
|
|
45
|
-
[
|
|
46
|
-
"worktree",
|
|
47
|
-
"add",
|
|
48
|
-
"--quiet",
|
|
49
|
-
"--detach",
|
|
50
|
-
worktree,
|
|
51
|
-
`origin/${EVIDENCE_BRANCH}`,
|
|
52
|
-
],
|
|
53
|
-
repo,
|
|
54
|
-
);
|
|
55
|
-
} else {
|
|
56
|
-
git(
|
|
57
|
-
[
|
|
58
|
-
"worktree",
|
|
59
|
-
"add",
|
|
60
|
-
"--quiet",
|
|
61
|
-
"--orphan",
|
|
62
|
-
"-B",
|
|
63
|
-
SCRATCH_BRANCH,
|
|
64
|
-
worktree,
|
|
65
|
-
],
|
|
66
|
-
repo,
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
const target = join(worktree, `pr-${verdict.pr}`, verdict.headSha);
|
|
70
|
-
rmSync(target, { recursive: true, force: true });
|
|
71
|
-
mkdirSync(target, { recursive: true });
|
|
72
|
-
cpSync(state.evidence, target, { recursive: true });
|
|
73
|
-
git(["add", "--all", "."], worktree);
|
|
74
|
-
const message = `verify: evidence for #${verdict.pr} at ${verdict.headSha.slice(0, 7)} (${verdict.result})`;
|
|
75
|
-
git(
|
|
76
|
-
[
|
|
77
|
-
"-c",
|
|
78
|
-
"commit.gpgsign=false",
|
|
79
|
-
"commit",
|
|
80
|
-
"--quiet",
|
|
81
|
-
"--allow-empty",
|
|
82
|
-
"--no-verify",
|
|
83
|
-
"-m",
|
|
84
|
-
message,
|
|
85
|
-
],
|
|
86
|
-
worktree,
|
|
87
|
-
);
|
|
88
|
-
git(
|
|
89
|
-
[
|
|
90
|
-
"push",
|
|
91
|
-
"--quiet",
|
|
92
|
-
"--no-verify",
|
|
93
|
-
"origin",
|
|
94
|
-
`HEAD:refs/heads/${EVIDENCE_BRANCH}`,
|
|
95
|
-
],
|
|
96
|
-
worktree,
|
|
97
|
-
);
|
|
98
|
-
return git(["rev-parse", "HEAD"], worktree);
|
|
99
|
-
} finally {
|
|
100
|
-
git(["worktree", "remove", "--force", worktree], repo);
|
|
101
|
-
if (git(["branch", "--list", SCRATCH_BRANCH], repo) !== "") {
|
|
102
|
-
git(["branch", "--quiet", "-D", SCRATCH_BRANCH], repo);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Posts the verdict as a PR comment.
|
|
109
|
-
*
|
|
110
|
-
* @param {import("./skill.mjs").Skill} skill The skill
|
|
111
|
-
* @param {{ pr: number, markdown: string }} verdict The verdict
|
|
112
|
-
* @returns {string} The comment URL gh prints
|
|
113
|
-
*/
|
|
114
|
-
export function postComment(skill, verdict) {
|
|
115
|
-
return execFileSync(
|
|
116
|
-
"gh",
|
|
117
|
-
[
|
|
118
|
-
"pr",
|
|
119
|
-
"comment",
|
|
120
|
-
String(verdict.pr),
|
|
121
|
-
"--repo",
|
|
122
|
-
originRepository(skill.repo),
|
|
123
|
-
"--body",
|
|
124
|
-
verdict.markdown,
|
|
125
|
-
],
|
|
126
|
-
{ cwd: skill.repo, encoding: "utf8" },
|
|
127
|
-
).trim();
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Sets the `verify` commit status on the head SHA the verdict judged:
|
|
132
|
-
* `success` for PASS and PASS+NOTES, `failure` for FAIL.
|
|
133
|
-
*
|
|
134
|
-
* @param {import("./skill.mjs").Skill} skill The skill
|
|
135
|
-
* @param {{ headSha: string, result: string }} verdict The verdict
|
|
136
|
-
* @param {string} targetUrl The comment URL
|
|
137
|
-
* @returns {string | null} GitHub's error when the status could not be set
|
|
138
|
-
*/
|
|
139
|
-
export function setStatus(skill, verdict, targetUrl) {
|
|
140
|
-
const state = verdict.result === "FAIL" ? "failure" : "success";
|
|
141
|
-
const result = spawnSync(
|
|
142
|
-
"gh",
|
|
143
|
-
[
|
|
144
|
-
"api",
|
|
145
|
-
"--silent",
|
|
146
|
-
`repos/${originRepository(skill.repo)}/statuses/${verdict.headSha}`,
|
|
147
|
-
"-f",
|
|
148
|
-
`state=${state}`,
|
|
149
|
-
"-f",
|
|
150
|
-
"context=verify",
|
|
151
|
-
"-f",
|
|
152
|
-
`description=${skill.name}: ${verdict.result}`,
|
|
153
|
-
"-f",
|
|
154
|
-
`target_url=${targetUrl}`,
|
|
155
|
-
],
|
|
156
|
-
{ cwd: skill.repo, encoding: "utf8" },
|
|
157
|
-
);
|
|
158
|
-
return result.status === 0
|
|
159
|
-
? null
|
|
160
|
-
: `${result.stderr}${result.stdout}`.trim() || `gh exited ${result.status}`;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* Reads back the `verify` status GitHub holds for a SHA, so the write is
|
|
165
|
-
* checked through a second command.
|
|
166
|
-
*
|
|
167
|
-
* @param {import("./skill.mjs").Skill} skill The skill
|
|
168
|
-
* @param {string} sha The commit
|
|
169
|
-
* @returns {string} The status state, or `absent`
|
|
170
|
-
*/
|
|
171
|
-
export function readStatus(skill, sha) {
|
|
172
|
-
const answer = execFileSync(
|
|
173
|
-
"gh",
|
|
174
|
-
["api", `repos/${originRepository(skill.repo)}/commits/${sha}/statuses`],
|
|
175
|
-
{
|
|
176
|
-
cwd: skill.repo,
|
|
177
|
-
encoding: "utf8",
|
|
178
|
-
},
|
|
179
|
-
);
|
|
180
|
-
/** @type {unknown} */
|
|
181
|
-
const stored = JSON.parse(answer);
|
|
182
|
-
const statuses = decodeCommitStatuses(stored, "gh api statuses");
|
|
183
|
-
return (
|
|
184
|
-
statuses.find((status) => status.context === "verify")?.state ?? "absent"
|
|
185
|
-
);
|
|
186
|
-
}
|