Pipelines
Writing pipelines with an AI agent
What to give an AI agent so it writes correct pipeline files, and the loop it should follow.
Available in repositories branchd reads pipeline files for. It is switching repositories on one at a time: until yours is, it keeps running its
.forge-ci.yamlor.xeonr-ci.yaml. See What is available.
Not yet available (cli 0.39.0):
branchd ci lintchecking every event a file lists (as the push check does) andbranchd run start --pipeline … --input …are in the next CLI release.ci lintandci planfrom 0.33.0 read pipeline files;branchd upgradeupdates.
Give it three things
- The complete reference, one file:
https://docs.xeonr.io/docs/branchd/pipelines/reference.md: every key, rule and limit in plain Markdown. For worked examples too, every page of the section in one fetch:https://docs.xeonr.io/docs/branchd/pipelines/llms-full.txt(index:…/pipelines/llms.txt). - The schema:
https://docs.xeonr.io/schemas/branchd/pipeline.json(andstep.json,packages.json). - The commands it may run:
branchd ci lintandbranchd ci plan, from the repository's root.
A prompt that works:
Write .branchd/pipelines/ci.yaml for this repository. Read
https://docs.xeonr.io/docs/branchd/pipelines/llms-full.txt first and use only
keys it documents (the reference alone is …/pipelines/reference.md); the schema is
https://docs.xeonr.io/schemas/branchd/pipeline.json. After each change, run
`branchd ci lint` and fix every refusal it prints, then run
`branchd ci plan` for a push to main and for a pull request
(`branchd ci plan --event pull_request`) and check that the jobs I expect run.
Do not push until lint passes.The loop
- Write the file, starting from the closest guide's example. Every example names its path on its first line.
branchd ci lint: compiles every pipeline file for a push to the default branch, tostage, to a feature branch, avtag, a pull request, a scheduled run and a manual run of each pipeline that has one, then each file for every event itson:lists (as branchd checks a push). Exit code 1 means at least one case was refused; each refusal names the file and line, and most say what to write instead (Refusals).branchd ci plan: lists every job, whether it runs for that ref and event, and why.--ref <branch or tag>,--event push|pull_request|schedule|manual|trigger,--pipeline <name>and--input k=vchoose the case.--jsonprints it for a program to read.- Push. branchd compiles the changed files again for every event; a
file the push breaks refuses the push with
file:line:column: message. Fix it and push again; do not use-o ci.allow-invalid. Then read the run:branchd run watch <n>, thenbranchd run failure <n>if it fails.
Things agents get wrong
- GitHub Actions habits. There is no
actions/checkout(the checkout is automatic), noruns-on: ubuntu-latest(jobs name animage:), nogithub.*context (usebranch,sha,event,pr.number), nohashFiles()(usecache.files), and no${{ secrets.X }}(list the secret under the job'ssecrets:and read$X). - GitLab CI habits.
stages,script,rules,variablesandextendsare refused, each with its replacement in the message. if:on outputs.if:is decided before the run starts and cannot readsteps.*orneeds.*outputs.- A need on a job that does not run. Give both jobs the same
if:, or mark the needoptional: true. .yml. Files end in.yaml.${{ secrets.X }}andgithub.token. The job token is$BRANCHD_TOKEN, and it reads only its own repository; ask for more withpermissions:.- A typed step among
run:steps needsisolated: trueand aworkspace:. - Assuming the CLI is in the job. It is not; use
curlandgitwith$BRANCHD_TOKEN.