GENERATORconstno test imports itconst GENERATOR: "bun commons/libraries/src/generate-workflows.ts"The command that writes the files, named in the first line of each.
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"); // trueSpec: 0001-libraries FR-004
GENERATORconstno test imports itconst GENERATOR: "bun commons/libraries/src/generate-workflows.ts"The command that writes the files, named in the first line of each.
renderActionfunctionfunction renderAction(a: CompositeAction): stringThe text of a composite action's action.yml.
renderWorkflowfunctionfunction renderWorkflow(w: Workflow): stringThe text of a workflow's file.
scalarfunctionfunction scalar(v: Scalar): stringA scalar as YAML: plain where it is read back as the same string, otherwise in double quotes.