IF Commons GitHub

workflows/render

The files GitHub reads, made from the typed model (commons 0030-generated-workflows FR-001, FR-004): renderWorkflow and renderAction give the YAML of a workflow and of a composite action as text, the same bytes for the same values, each beginning with a line that says it is generated and by what.

The YAML written is the small part of it that GitHub's files need: mappings in the order the model gives, lists, scalars, comments and literal blocks for a script of more than one line. A scalar is written as it is where a YAML reader would read it as the same string, and in double quotes (JSON's) where it would read it as a number, a boolean, a null or a mapping. A script of one line is a scalar; one of several lines is a literal block that keeps its last newline (|) or drops it (|-) as the script has it.

import { renderWorkflow } from "./render.ts";
import { job, run, use } from "./model.ts";
renderWorkflow({ file: "x", name: "x", on: { push: {} }, jobs: { t: job({ runsOn: "ubuntu-latest", timeoutMinutes: 5, steps: [use("actions/checkout@v4"), run("bun test")] }) } }).includes("runs-on: ubuntu-latest"); // true

Spec: 0001-libraries FR-004

Source: commons/libraries/src/workflows/render.ts

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

GENERATORconstno test imports it
const GENERATOR: "bun commons/libraries/src/generate-workflows.ts"

The command that writes the files, named in the first line of each.

renderActionfunction
function renderAction(a: CompositeAction): string

The text of a composite action's action.yml.

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

renderWorkflowfunction
function renderWorkflow(w: Workflow): string

The text of a workflow's file.

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

scalarfunction
function scalar(v: Scalar): string

A scalar as YAML: plain where it is read back as the same string, otherwise in double quotes.

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

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