IF Commons GitHub

ci/step

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0002-libraries-ci-findings FR-004

The step wrapper (commons 0038-build-policy FR-013): bun commons/libraries/src/ci/step.ts --id ID --job JOB --module NAME --tool TOOL --timeout MINUTES --out DIR -- COMMAND... runs one command, keeps what it printed, prints it as it was printed, reads it into findings with the parser of the tool, writes the file of the step (DIR/ID.json, a build-findings/1 file of one step) and exits 0 whatever the command's own status was. A command that cannot be started, that fails and prints nothing a parser reads, or that is stopped by the time limit is a finding of the tool (tool-error, no-output, timeout) and never a red step. The only status that is not 0 is 2, for a wrapper called wrongly (the red cause wrapper-misused, FR-002).

It imports no package, only files of this folder and node: modules, so that it runs in a cell of the matrix before the cell's packages are installed. The time limit stops the command's whole process group, so that a command that started others does not outlive it.

bun commons/libraries/src/ci/step.ts --id verify --job verify --module core --tool exit-status --timeout 15 --out "$RUNNER_TEMP/findings" -- bash -c "bun run verify"

Source: commons/libraries/src/ci/step.ts

4 of 6 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

Requesttypeno test imports it
type Request = { readonly id: string; readonly job: string; readonly module: string; readonly tool: Tool; readonly timeoutMinutes: number; readonly out: string; readonly command: readonly string[] };

What the wrapper was asked to do, or the sentence that says it was called wrongly.

parseRequestfunction
function parseRequest(argv: readonly string[]): { readonly kind: "ok"; readonly request: Request; } | { readonly kind: "err"; readonly error: string; }

The request an argument list makes (the words before -- are options, the words after it the command), or what is wrong with it.

Imported by 8 tests of the run (8 passed, 0 failed): the library's results

Rantypeno test imports it
type Ran = { readonly output: string; readonly exitStatus: number | null; readonly timedOut: boolean; readonly startError?: string; readonly durationMs: number };

What running the command came to.

runCommandfunction
function runCommand(command: readonly string[], timeoutMinutes: number, echo?: (chunk: string) => void): Promise<Ran>

Runs the command with the time limit, printing what it prints as it prints it and keeping up to 20 MiB of it.

Imported by 8 tests of the run (8 passed, 0 failed): the library's results

fileOfRunfunction
function fileOfRun(req: Request, ran: Ran, run: { readonly id: string; readonly workflow: string; readonly commit: string; readonly at: string; readonly url?: string | undefined; }): FindingsFile

The file of one step from what its command came to: the findings its parser reads, or the finding of how it ended.

Imported by 8 tests of the run (8 passed, 0 failed): the library's results

executefunction
function execute(req: Request, env: Readonly<Record<string, string | undefined>>, echo?: ((chunk: string) => void) | undefined): Promise<FindingsFile>

Runs a request and writes its file; returns the file.

Imported by 8 tests of the run (8 passed, 0 failed): the library's results

Titles, headings, exports, tables, columns and requirements. Esc closes.