main 98594d0

strict.mjs RawHistoryFolder

1// SPDX-License-Identifier: MIT
2//
3// Generates testdata/strict.json: for each file in testdata/cases/*.yml, the
4// errors that @actions/workflow-parser 0.3.61 (MIT, GitHub,
5// actions/languageservices) reports when it parses the file with parseAction
6// (schema "action-root-strict") and converts it with convertActionTemplate
7// (which validates the pre-if and post-if conditions and the step conditions).
8// strict_test.go replays the answers against ParseStrict.
9//
10//   action/gen/regen.sh
11
12import { pathToFileURL } from "node:url";
13import path from "node:path";
14import fs from "node:fs";
15
16const dist = path.resolve(process.argv[2] ?? new URL("../../gen/node_modules/@actions/workflow-parser/dist", import.meta.url).pathname);
17const imp = p => import(pathToFileURL(path.join(dist, p)).href);
18const { parseAction } = await imp("actions/action-parser.js");
19const { convertActionTemplate } = await imp("actions/action-template.js");
20const { NoOperationTraceWriter } = await imp("templates/trace-writer.js");
21
22const dir = new URL("../testdata/cases/", import.meta.url);
23const out = {};
24for (const f of fs.readdirSync(dir).sort()) {
25  if (!f.endsWith(".yml")) continue;
26  const content = fs.readFileSync(new URL(f, dir), "utf8");
27  const r = parseAction({ name: f, content }, new NoOperationTraceWriter());
28  const res = { errors: [] };
29  if (r.value) {
30    // Default error policy: the conversion only runs on a document without
31    // schema errors, and adds its own (pre-if, post-if, step conditions).
32    const t = convertActionTemplate(r.context, r.value);
33    res.name = t.name; res.description = t.description; res.author = t.author;
34    res.inputs = (t.inputs || []).map(i => ({ id: i.id, required: i.required, deprecationMessage: i.deprecationMessage, default: i.default === undefined ? undefined : String(i.default) }));
35    res.outputs = (t.outputs || []).map(o => ({ id: o.id, value: o.value === undefined ? undefined : String(o.value) }));
36    res.runs = { using: t.runs?.using, main: t.runs?.main, image: t.runs?.image, preIf: t.runs?.preIf, postIf: t.runs?.postIf, steps: (t.runs?.steps || []).length };
37  }
38  res.errors = r.context.errors.getErrors().map(e => e.message);
39  out[f] = res;
40}
41console.log(JSON.stringify(out, null, 1));

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 3

↑↓ moveenter openesc close