#set page( margin: (top: 0.9in, bottom: 0.9in, left: 1.0in, right: 1.0in), ) #set text(font: "Libertinus Serif", size: 11pt) #set par(leading: 1.1em) #set heading(numbering: "1.") #set outline(indent: 1.1em) #let meta(label, value) = { table( columns: (22%, 78%), inset: (x: 6pt, y: 4pt), stroke: (paint: luma(220), thickness: 0.8pt), fill: luma(248), [*#label*], [#value], ) } #let tag(text) = { box( inset: (x: 6pt, y: 2pt), radius: 4pt, fill: luma(235), stroke: (paint: luma(210), thickness: 0.8pt), )[ `#text` ] } #let callout(title, body) = { block( inset: 10pt, radius: 6pt, fill: luma(248), stroke: (paint: luma(220), thickness: 0.8pt), )[ *#title* \ #body ] } #let gate(name, condition, on_fail) = { block[ \ == #name \ - *Pass condition:* #condition \ - *On failure:* #on_fail ] } #let stage( name, purpose: "", triggers: [], inputs: [], steps: [], outputs: [], runtime: "", runner: "", gates: [], ) = { heading(level: 2, name) if purpose != "" { [*Purpose:* #purpose] linebreak() } if runtime != "" { [*Expected runtime:* #runtime] linebreak() } if runner != "" { [*Runner/agent:* #runner] linebreak() } if triggers.len() > 0 { [*Triggers:*] for t in triggers { [- #t] } } if inputs.len() > 0 { [*Inputs:*] for i in inputs { [- #i] } } if steps.len() > 0 { [*Steps:*] for s in steps { [- #s] } } if outputs.len() > 0 { [*Outputs:*] for o in outputs { [- #o] } } if gates.len() > 0 { [*Quality gates:*] for g in gates { [- #g] } } linebreak() } #let env_table(rows) = { table( columns: (18%, 16%, 26%, 40%), inset: (x: 6pt, y: 4pt), stroke: (paint: luma(220), thickness: 0.8pt), align: (left, left, left, left), [*Environment*], [*Type*], [*Promotion rule*], [*Notes*], ..rows.flatten(), ) } #let simple_pipeline_diagram(items) = { let n = items.len() if n == 0 { return } let elements = () for (i, item) in items.enumerate() { elements.push(box( inset: 8pt, radius: 6pt, fill: luma(245), stroke: (paint: luma(210), thickness: 0.8pt), )[ *#item* ]) if i < n - 1 { elements.push(align(center + horizon)[→]) } } let box_width = 1fr let arrow_width = auto let columns = () for i in range(elements.len()) { if calc.even(i) { columns.push(box_width) } else { columns.push(arrow_width) } } grid( columns: columns, column-gutter: 8pt, align: center + horizon, ..elements ) } = CI/CD Pipeline: [PacketMix] #meta("Owner", "FreshlyBakedCake") #meta("Repository", "Patisserie (default branch: main)") #meta("CI/CD System", "Spindle a.k.a. Tangled Actions") #callout( "Scope", [ This document describes the CI/CD pipeline for *PacketMix*, including triggers, stages, environments, artifacts, quality gates, and operational procedures. ], ) #outline() = Overview == Goals - Deliver *PacketMix* safely and repeatably. - Enforce quality gates (tests, approvals). - Provide auditable deployments and fast rollback. == Non-goals - [e.g., Build system internals not covered] == High-level flow #simple_pipeline_diagram(( "Commit/PR", "Test", "Build", "Deploy", )) = Triggers & Branching == Trigger events - `push` to `[main]` - `pull_request` targeting `[main]` == Branching strategy - Primary branch: `[main]` - Release branch: `[release]` = Environments & Promotion #env_table(( ([Development], [ephemeral], [On PR], [Runs in Nixery engine]), ([Staging], [ephemeral], [On merge to main], [Runs in Nixery engine]), ([Release], [shared], [Main passes checks], [Sets code for release to machines]), )) == Promotion rules - Development → Staging: automatic on successful PR to main pipeline. - Staging → Production: automatic on main checks passing. = Secrets and Variables == Secrets - Storage: Bitwarden vault - Access model: Provisioned on machine run. == Key variables (examples) - `KEY_SSH_RELEASE`: SSH Key used for pushing to git - `KEY_SSH_REMOTE_BUILD`: SSH Key used for accessing the remote builder = Pipeline Stages #stage( "deadnix", purpose: "Check for dead nix expressions.", triggers: ("PR", "push to main"), inputs: ( "Source code", ), steps: ( "Check for unused nix bindings", ), outputs: (), runtime: "~5 seconds", runner: "linux-x64 via nixery container", gates: ( "No dead nix expressions.", ), ) #stage( "reuse", purpose: "Ensure all files are properly licensed", triggers: ("PR", "push to main"), inputs: ( "Source code", ), steps: ( "Check for REUSE compliance", ), outputs: (), runtime: "~5 seconds", runner: "linux-x64 via nixery container", gates: ( "All files are properly licensed.", ), ) #stage( "packetmix-npins-duplicate-check", purpose: "Catch duplicate npins keys.", triggers: ("PR", "push to main"), inputs: ( "Source code", ), steps: ( "Check for duplicate npins keys", ), outputs: (), runtime: "~5 seconds", runner: "linux-x64 via nixery container", gates: ( "No duplicate keys.", ), ) #stage( "packetmix-treefmt", purpose: "Check formatting of changed files.", triggers: ("PR", "push to main"), inputs: ("Source code", "KEY_SSH_REMOTE_BUILD secret"), steps: ( "Get remote builds ssh key.", "Add base system files.", "Ensure files are formatted.", ), outputs: (), runtime: "~30 seconds", runner: "linux-x64 via nixery container", gates: ("All files are formatted.",), ) #stage( "packetmix-build", purpose: "Build the project.", triggers: ("PR", "push to main"), inputs: ("Source code", "KEY_SSH_REMOTE_BUILD secret"), steps: ( "Get remote builds SSH key.", "Add base system files.", "Evaluate all systems", "Build all systems" ), outputs: ("Build artifacts",), runtime: "~1 hour", runner: "linux-x64 via nixery container", gates: ( "All systems evaluate successfully.", "All builds succeed.", ), ) #stage( "packetmix-release", purpose: "Release to systems.", triggers: ("push to main",), inputs: ("Source code", "KEY_SSH_REMOTE_BUILD secret", "KEY_SSH_REMOTE_RELEASE secret"), steps: ( "Get remote builds SSH key.", "Get release push SSH key.", "Add base system files.", "Evaluate all systems.", "Build all systems.", "Push to release", ), outputs: ("Build artifacts",), runtime: "~1 hour", runner: "linux-x64 via nixery container", gates: ( "All systems evaluate successfully.", "All builds succeed.", "Push to release succeeds.", ), ) #stage( "github", purpose: "Mirror to github.", triggers: ("push to release",), inputs: ("Source code", "KEY_SSH_GITHUB secret", "KEY_SSH_GITHUB_PACKETMIX secret", "KEY_SSH_GITHUB_SPRINKLES secret"), steps: ( "Write github SSH Key.", "Add base system files.", "Push * to GitHub.", "Write packetmix github SSH Key.", "Push packetmix to GitHub.", "Write sprinkles github SSH Key.", "Push sprinkles to GitHub." ), outputs: (), runtime: "~1 minute", runner: "linux-x64 via nixery container", gates: ("All pushes to github succeed",) ) = Quality Gates (Centralized) #gate( "Required checks on PR", [All checks succeed (see @ci_pass), Human review approved (if required).], "Block merge; require fix or approved exception.", ) = Rollback & Recovery == Rollback strategy - Primary: Force push release branch to last known good image. == When to rollback - Any system fails to start or crash loops. = Appendix == Reference links - #link("https://tangled.org/freshlybakedca.ke/patisserie/")[FreshlyBakedCake/Patisserie Repo] == Images #figure( image("ci_success.png"), caption: "CI Pipeline Success." ) #figure( image("deploy_success.png", width: 125%), caption: "Deploy to machine successful." )