# WORKFLOW.md The single guide for this repo's CI/CD **workflows** (GitHub Actions): **code style**, **architecture**, a **behavioral contract** (expected inputs and outputs), and a **test methodology**. Source code style lives in [`CODESTYLE.md`][codestyle]. This file covers everything under [`.github/workflows/`][workflows]. It **describes required outcomes, not a required implementation.** A workflow is correct when it satisfies the contract (section 4), whatever shape its YAML takes. Section 2 keeps workflows legible. Section 3 is the model. Section 4 is what they must *do*. Sections 5 and 6 are how to verify it and the configuration it assumes. Each guarantee names the **failure it prevents**, so the reason survives a reimplementation. ## 0. The model at a glance NxWitness ships **Docker images only**: a multi-product, multi-base set of multi-arch images on Docker Hub (five Nx VMS products x {plain, LSIO} = ten product images, plus two shared base images `nx-base` / `nx-base-lsio`, across 12 Docker Hub repositories). There is **no NuGet publish**: the .NET project (`CreateMatrix`) is a build-time **matrix generator** only, not a shipped package. Three things do the work: - **CI** runs on **every pull request**, a push to `develop`, and dispatch. It validates (unit tests + lint) and smoke-builds a representative image subset, publishing nothing. A pull request merges only when its required check is green. - **The publisher** is a **triggered-Docker** workflow, one run = one branch. It runs on a **weekly schedule** (rebuilds `main` only - full product matrix, shared base refresh for CVEs, versioned release), on a **path-scoped push to `main`** when codegen commits a new `Make/Matrix.json` pin (publishes the new product versions at once), and on **manual dispatch** (publishes the branch it is started from: `main` -> `latest`/`stable`, `develop` -> `:develop`). It never runs on an ordinary merge. - **Codegen** runs daily, dual-targeting `main` AND `develop`: it regenerates `Make/Version.json` + `Make/Matrix.json` from upstream Nx product versions and opens a PR against each base, which the merge-bot auto-merges. A merge to `main` whose matrix changed triggers the publisher's path-scoped push. There is no publish-on-merge for code and no two-branch matrix in the publisher - building only the trigger branch keeps `github.ref` aligned with the branch being versioned. Dependabot pull requests merge themselves once their checks pass. ### Glossary - **Entry workflow** - has `push` / `schedule` / `workflow_dispatch` triggers. The orchestrator that an event or a person starts. - **Reusable workflow (task)** - a `workflow_call` workflow invoked through a `uses:` reference, never triggered directly. File ends in `-task.yml`. Every task this repo runs is **hub-hosted** in `ptr727/ProjectTemplate` and reached by a SHA-pinned `uses:`, so this repo carries entry workflows only. - **Hook** - a composite action under [`.github/actions/`][actions] that a hub task runs from this repo's checkout for the repo-specific step: `docker-prepare` (the image matrix), `docker-build-base` (the shared bases), and `codegen` (the generator invocation). - **Product image** - one shipped image built from a `Make/Matrix.json` row's Dockerfile (e.g. `NxMeta`, `NxMeta-LSIO`), pushed to its own Docker Hub repo (`docker.io/ptr727/`). - **Shared base image** - `nx-base` / `nx-base-lsio`, built once and reused as the `FROM` for the product images. Its tag (`:ubuntu-noble`) is **branch-agnostic** (one shared tag, not per-branch). - **Matrix / version inputs** - `Make/Matrix.json` (the per-product image build rows: name, Dockerfile tags, build args, branch) and `Make/Version.json` (the upstream Nx version pins), both regenerated by codegen. - **Smoke build** - a CI build that compiles a representative image subset (NxMeta + NxMeta-LSIO, amd64) to prove the Dockerfiles still build, publishing and pushing nothing. Driven by a `smoke: true` input. - **Transfer artifact** - a workflow artifact handing data between jobs of one run. The durable copy lives on the GitHub release / Docker Hub. - **Threaded version** - the single NBGV `SemVer2` (plus `GitCommitId`) computed once in the hub's `get-version-task.yml`, which `build-release-task.yml` calls, and passed down as `semver2` / `ref` inputs to every consumer, never recomputed in a build task. - **GitHub App token** - a short-lived installation token from `actions/create-github-app-token`, minted from the App credentials (`CODEGEN_APP_CLIENT_ID` / `CODEGEN_APP_PRIVATE_KEY`). The merge-bot and the codegen PR-opener use it, not `GITHUB_TOKEN`: a `GITHUB_TOKEN` push does not trigger downstream workflows, and that token is read-only on Dependabot pull requests. ## 1. Purpose and how to use this document - **Contract, not implementation.** Conform to the *outcomes* in section 4 and the *architecture* in section 3. Job names and file layout may vary; the input/output behavior may not. - **"Operational" - the one definition.** The repo is **operational** when every applicable section-4 guarantee holds, every applicable section-5B scenario's observed output equals its expected output (corroborated by a 5C live probe where a live signal exists), and the section-6 configuration is in place. Anything else is **not operational**. - **Defect vs N/A.** An item is **N/A** only when this repo has no such concern (e.g. a NuGet-publish guarantee, since this repo publishes none). A construct required by an applicable guarantee but absent is a **defect**. - **Default branch is `main`.** Guarantees say "default branch" portably. This repo writes the literal `main` in the publish guards and the release-version backstop, and the anchored `^refs/heads/main$` in `version.json`'s `publicReleaseRefSpec`. ## 2. Workflow style conventions Legibility rules. Necessary but not sufficient: a perfectly styled workflow can still violate section 4. - **Action pinning.** Pin every action to a commit SHA with a trailing `# vX.Y.Z` comment. Use `# vX` only when the upstream floating major tag has no specific patch SHA. **Sole exception: `dotnet/nbgv@master`** is consumed via the floating `@master` ref, never SHA-pinned - its tag stream lags `master` substantially, so Dependabot tag-tracking would only propose downgrades to stale tags. That `uses:` lives in the hub's `get-version-task.yml`, with its rationale inline. A tool an action *installs* (not a `uses:` ref) is left unpinned to track latest. - **Hub task pinning.** A hub task is reached as `ptr727/ProjectTemplate/.github/workflows/.yml@ # `, every call at the same hub release, and Dependabot bumps the pin. A hub-side change reaches this repo only through a pin bump. - **Filename.** Reusable workflows end in `-task.yml`; entry workflows end in what they do (`-pull-request.yml`, `-release.yml`). A `-task.yml` is `uses:`-d, never triggered directly, and none is carried here. - **Workflow `name:`.** Reusable names end in **"task"**, entry names in **"action"**. - **Job and step `name:`.** Every job `name:` ends in **"job"**, every step `name:` in **"step"**, the aggregator included (`Check pull request workflow status job`). A job name also bound as a ruleset required-check `context:` is codified in the hub's repository-configuration payloads and changed only **in lockstep** with the live ruleset. - **Concurrency.** Every entry workflow declares a `concurrency` group. CI uses `group: '${{ github.workflow }}-${{ github.ref }}'`, `cancel-in-progress: true`. The publisher uses the same ref-scoped group with `cancel-in-progress: false`, so two publishes on one ref never overlap and none is cancelled mid-release. A push the plan does not publish appends `github.run_id`, so it never replaces a pending publish (D7.1). Codegen keys on the workflow only (it writes fixed `codegen-*` branches). - **Shells.** Every multi-line bash `run:` starts with `set -Eeuo pipefail`. - **Conditionals.** Multi-line `if:` uses the folded scalar `if: >-`. - **Boolean inputs.** A boolean used by both `workflow_call` and `workflow_dispatch` is declared in both trigger blocks and compared against `true` and `'true'`. - **Reusable-workflow permissions.** Job-level `permissions:` are validated before `if:`, so even a skipped job needs valid permissions. Grant least privilege; a callee's extra scope is granted by the caller. - **Allowlist `success` and `skipped` explicitly** across an optional dependency: use `(needs.X.result == 'success' || needs.X.result == 'skipped')`, not `!= 'failure'`. - **Line endings.** Workflow YAML is LF, per [`.editorconfig`][editorconfig]'s `[*]` default (Actions and Dependabot rewrite it that way). Preserve endings on every edit. ## 3. Architecture ### Three workflows: CI on pull requests, publishing on schedule/pin-push/dispatch, codegen daily CI ([`test-pull-request.yml`][test-pull-request]) and the publisher ([`publish-release.yml`][publish-release]) are separate workflows with separate concurrency, so they never race. CI tests every pull request's tree and every `develop` push, and never publishes. The publisher releases on its own triggers and never runs on an ordinary merge. Codegen ([`run-periodic-codegen-pull-request.yml`][run-periodic-codegen-pull-request] -> the hub's `run-codegen-pull-request-task.yml` -> the [`codegen`][actions-codegen] hook) keeps the version/matrix data current. *Prevents a merge from silently cutting a release, and a CI run from racing a publish on the same ref.* ### The publisher builds one branch: the trigger ref A publish builds exactly **one** branch - the run's trigger ref. The **schedule** and the **pin push** both run on `main`; a **dispatch** runs on the branch it is started from (`main` or `develop`). The jobs pass `github.ref_name` as `branch` and the triggering commit `github.sha` as `ref`, so the branch built, versioned, and tagged is always the run's own ref, pinned to one commit even if the branch advances mid-run. *No matrix and no cross-branch ref mixing - `github.ref` is the branch being published.* The hub's `publish-plan-task.yml` publishes only the long-lived branches (`main` / `develop`); a dispatch from a feature branch fails the plan job with an `::error::` and publishes nothing. To refresh `:develop`, dispatch the workflow from `develop`. Because the run's ref **is** the built branch, the hooks run from that same branch's commit - so a `develop` dispatch builds develop's own `Make/Matrix.json` rows with develop's hooks, and the schedule runs main's. The hub tasks themselves resolve at the pinned hub commit on every branch. ### The publisher's pin-push trigger The publisher's `push` trigger is branch-filtered to `main` and path-filtered to `Make/Matrix.json`. So an ordinary code merge never publishes; only a change to the codegen matrix pin (committed to `main` by the auto-merged `codegen-main` PR) does, shipping the new upstream Nx product versions immediately. develop's daily codegen pin update is sync-only - the push trigger is main-only - and never publishes; `:develop` is refreshed by manual dispatch. The weekly schedule still runs with no matrix change, to refresh the shared base image for CVEs. ### The multi-image build layer The publisher is a `plan` -> `validate` -> `build-base` -> `publish` -> `publish-docker-readme` chain (a multi-product Docker repo, the matrix and `build-base` case of the hub's Docker family). The `build-base` job logs in to Docker Hub and runs the [`docker-build-base`][actions-docker-build-base] hook to build and push the two shared bases. It is this repo's own job rather than the hub's `build-base` leg, since that leg carries no Docker Hub login and a composite hook cannot read secrets. The `publish` job calls the hub's `build-release-task.yml`, whose Docker leg (the hub's `build-docker-task.yml`) takes the product matrix from the [`docker-prepare`][actions-docker-prepare] hook, which maps the branch's `Make/Matrix.json` rows onto the hub's matrix shape. The shared base is built **once** (on the `main` run) and reused: a `develop` dispatch skips `build-base` and pulls main's published base, so it never overwrites the branch-agnostic `nx-base` tag. The hub core owns the cache policy: the product build reads both branches' registry buildcaches (`buildcache-main`, `buildcache-develop`) and writes only its own branch's cache, only when pushing. ### Versioning: compute once, thread everywhere NBGV runs once (in the hub's `get-version-task.yml`, called by `build-release-task.yml`), classifying from `github.ref`, and its outputs (`SemVer2`, `GitCommitId`) thread to every consumer via `outputs:` / `needs:` / `semver2` inputs. The hub's `build-docker-task.yml` accepts the threaded `semver2` as the image `LABEL_VERSION` and never re-runs NBGV - one classification feeds every product leg, so no second NBGV run can reclassify or collide a tag. A build job may check out a specific commit to compile it (main pins to `GitCommitId`) but consumes the threaded version. `main` (the public ref, `publicReleaseRefSpec = ^refs/heads/main$`) builds a clean `X.Y.`; every other branch a prerelease `X.Y.-g`. *Keeps each image's embedded version and the release tag in agreement.* NBGV classifies `publicReleaseRefSpec` from the `GITHUB_REF` environment variable. Because the publisher builds the **trigger ref** (one branch per run), `GITHUB_REF` already equals the branch being versioned - a schedule, a pin push, or a `main` dispatch classifies as public; a `develop` dispatch as prerelease - so no `GITHUB_REF` override is needed (`IGNORE_GITHUB_REF` is only for matrix publishers that build a non-trigger branch). The main-version backstop (D2.2) catches any misclassification. NBGV's version is the GitHub release tag on `main` and the `LABEL_VERSION` build arg baked into the images. The Docker image **tags** themselves carry the Nx product version from `Make/Matrix.json`, distinct from the NBGV build version. ### Validate at entry A run that carries a cross-input invariant (`main` must not carry a prerelease suffix, and any other branch must carry one) asserts it once with `::error::` before anything builds. The hub's `build-release-task.yml` runs that check in its `validate-release` job, which every build job `needs:`. ### Fast CI feedback, head-resolved CI runs on every pull request, and the hooks resolve from the checked-out head. So a pull request that edits a hook tests its own copy. The hub tasks resolve at their pinned commit. So a hub-side change is tested by the pull request that bumps the pin, which touches `.github/workflows/` and so runs the smoke build too. CI validates on every run through the hub's `validate-task.yml`. That covers the document linters, CSharpier and `dotnet format style`, the repo gates, and `dotnet test`. It smoke-builds a representative image subset only when image files, the Docker hooks, or the workflows changed. The check is an inline `git diff` change-gate rather than `dorny/paths-filter`. The smoke build runs the hub's `build-release-task.yml` with `smoke: true`, uploading and pushing nothing. One aggregator job gates the merge. Only its `pull_request` run takes the ruleset-bound required check name. Deleting any branch but `develop` starts no CI run. A `develop` deletion push is skipped by a `!github.event.deleted` guard on every job. Its run's `github.sha` reverts to the default branch's tip, so without the guard it would test `main`'s tree under the deleted ref. ### The Docker-only release The hub's `github-release` job tags the built commit and creates the GitHub release (auto source zip + README + LICENSE; `target_commitish` pinned to `GitCommitId`; skip-existing guard). The caller sets `github: true` only on `main`, so a `develop` dispatch cuts no release. This repo ships **no** `release-asset-*` binaries or packages - the published artifacts are the Docker Hub images - so it sets `expect_release_assets: false`, which skips the release-asset download and relaxes `fail_on_unmatched_files`. The GitHub release exists only as the version anchor / tag. The Docker Hub repository overview ([`Docker/README.md`][docker-readme], the hub default's first choice) is pushed to every product + base repo on a `main` publish by the hub's `publish-docker-readme-task.yml`, since Docker Hub does not read the GitHub README; the repo list is derived from `Make/Matrix.json` by the task's `manifest-jq` input. ### Resource lifecycle Workflow artifacts are an intra-run handoff; the durable copy lives on the GitHub release / Docker Hub. This repo uploads none: the images go straight to Docker Hub and the release carries no `release-asset-*` files. The hub's `github-release` job still owns the consume-then-delete cleanup, `continue-on-error` so housekeeping never reds the run, should a target that uploads one ever be enabled. ### Self-sufficiency: automatic updates Every Dependabot pull request, any ecosystem and any tier, auto-merges once the required checks pass, a semver-major NuGet bump included, since the required checks are the gate (D8.2). The merge-bot is the hub's `merge-bot-task.yml`. Codegen opens a `codegen-main` -> `main` and a `codegen-develop` -> `develop` PR daily; the merge-bot auto-merges each independently (`--delete-branch`). A merged dependency bump does not itself publish; a merged matrix pin on `main` does (the pin-push trigger). A person steps in only for a breaking change (a red check) or to dispatch a release. ### Flow diagrams Four diagrams trace the architecture above: the pull-request gate, the self-publisher, the bot automation, and the trigger chain that turns a daily codegen run into a published release. They depict the same outcomes that the section 4 contract specifies, drawn from the workflow YAML; if a diagram and a guarantee disagree, one of them is a defect. Triggers are blue, gates yellow, durable/published outputs green, and stop/skip outcomes red. **Pull request (CI), `test-pull-request.yml`.** Every run executes the hub's validate gate. It smoke-builds a representative image subset only when image files changed. A single aggregator gates the merge, and only its `pull_request` run produces the ruleset-bound required check (D1, D6). ```mermaid flowchart TD T(["pull_request, push: develop
(or workflow_dispatch)"]):::trig T --> D{"github.event.deleted?"}:::gate D -- "yes: develop deleted" --> X(["all jobs + aggregator skip
no failed run"]):::stop D -- "no" --> CH["changes job
inline git diff change-gate
image? base?"] D -- "no" --> V["validate job
(hub validate-task.yml)"] subgraph VT ["hub validate-task.yml"] VU["doc linters, CSharpier,
dotnet format style, repo gates
+ dotnet test"] end V --> VT CH --> SG{"image files changed?
(Docker/**, Make/Matrix.json, Make/Version.json,
.github/actions/docker-*, .github/workflows/**)"}:::gate SG -- "no" --> SS(["smoke-build skipped
(aggregator allows skip)"]):::stop SG -- "yes" --> S["smoke-build job
hub build-release-task.yml
smoke: true, never pushes
NxMeta + NxMeta-LSIO, amd64"] CH --> A VT --> A S --> A SS --> A A{"aggregator
changes AND validate AND smoke-build
succeeded or skipped?"}:::gate A -- "yes, pull_request run" --> G(["required check passes
merge unblocked"]):::pub A -- "no, pull_request run" --> R(["required check fails
merge blocked"]):::stop A -- "push or dispatch run" --> N(["non-required check
gates nothing"]):::stop classDef trig fill:#dbeafe,stroke:#2563eb,color:#1e3a8a classDef gate fill:#fef9c3,stroke:#ca8a04,color:#713f12 classDef pub fill:#dcfce7,stroke:#16a34a,color:#14532d classDef stop fill:#fee2e2,stroke:#dc2626,color:#7f1d1d ``` **Publish - `publish-release.yml`.** A weekly schedule (main), a `Make/Matrix.json` pin push (main), or a dispatch plans, validates, builds the shared base (main only), then calls the hub release chain, which versions once with NBGV, builds the branch's product matrix with the threaded SemVer2, and cuts the main-only GitHub release; the Docker Hub overviews refresh last (D0, D2, D3, D4). ```mermaid flowchart TD P1(["schedule: weekly Mon 02:00 UTC
(main only)"]):::trig --> PL P2(["push: main
paths = Make/Matrix.json (codegen pin)"]):::trig --> PL P3(["workflow_dispatch
(main or develop)"]):::trig --> PL PL{"plan job (hub publish-plan-task.yml)
publish? stable?"}:::gate PL -- "no: human push, or
feature-branch dispatch" --> PLS(["all jobs skip or plan fails
no publish"]):::stop PL -- "publish" --> VAL["validate job
(hub validate-task.yml)"] VAL --> BB{"stable (main)?"}:::gate BB -- "develop dispatch" --> BBS(["build-base skipped
reuse main's nx-base"]):::stop BB -- "main" --> BBJ["build-base job
docker login + docker-build-base hook
nx-base + nx-base-lsio
amd64 + arm64, buildcache-main"] BBJ --> PUB BBS --> PUB subgraph PUB ["publish job: hub build-release-task.yml"] GVR["get-version
NBGV @master, runs once
SemVer2 + GitCommitId"] --> VR{"validate-release
main: no prerelease '-'
other: has one"}:::gate VR -- "clean" --> BD["build-docker (hub build-docker-task.yml)
matrix from the docker-prepare hook
= the branch's Make/Matrix.json rows
amd64 + arm64 on main
LABEL_VERSION = threaded SemVer2"] BD --> RG{"github: true (main)?"}:::gate end VR -- "mismatch" --> VRX(["fail ::error::
refuse to publish"]):::stop BD --> DH[("Docker Hub
10 product repos (branch tags)")]:::pub BBJ --> DHB[("Docker Hub
2 shared base repos")]:::pub RG -- "develop" --> RGS(["no GitHub release
(:develop images only)"]):::stop RG -- "main" --> EX{"tag exists AND not dispatch?"}:::gate EX -- "yes" --> EXS(["skip release create
(no-op republish)"]):::stop EX -- "no" --> REL[("GitHub release
tag = SemVer2 at GitCommitId
prerelease: false, source zip + README + LICENSE")]:::pub PUB --> DRM["publish-docker-readme job (main)
hub publish-docker-readme-task.yml
repo list from Make/Matrix.json"] DRM --> DRO[("Docker Hub overviews (Docker/README.md)
10 product + 2 base repos")]:::pub classDef trig fill:#dbeafe,stroke:#2563eb,color:#1e3a8a classDef gate fill:#fef9c3,stroke:#ca8a04,color:#713f12 classDef pub fill:#dcfce7,stroke:#16a34a,color:#14532d classDef stop fill:#fee2e2,stroke:#dc2626,color:#7f1d1d ``` **Automation - codegen + Dependabot + merge-bot.** Daily codegen and Dependabot open in-repo bot PRs; the merge-bot enables auto-merge (or disables it on a maintainer push); the required check gates each merge (D8). ```mermaid flowchart TD SCH(["schedule daily 04:00 UTC
(or workflow_dispatch)"]):::trig --> CG subgraph CGT ["hub run-codegen-pull-request-task.yml (matrix: main, develop)"] CG["codegen job per branch
codegen hook: regenerate Version.json + Matrix.json
(deterministic, forward-only guard)"] --> CGC{"data changed?"}:::gate CGC -- "no" --> CGN(["no PR"]):::stop CGC -- "yes" --> CPR["open codegen-<branch> PR
(App token)"] end DEP(["Dependabot opens PR
any ecosystem/tier"]):::trig --> MB CPR --> MB subgraph MBT ["merge-bot-pull-request.yml -> hub merge-bot-task.yml (pull_request_target)"] MB{"event / author"}:::gate MB -- "opened/reopened
bot author" --> EN["enable auto-merge --delete-branch
squash develop / merge main"] MB -- "synchronize by maintainer" --> DIS["disable auto-merge"] end EN --> CK{"required check passes?"}:::gate CK -- "yes" --> MRG(["PR merges (App token)"]):::pub CK -- "no" --> BLK(["merge blocked
maintainer notified"]):::stop MRG -. "codegen-main Matrix.json change" .-> PUBR(["publisher pin-push auto-publishes main"]):::pub classDef trig fill:#dbeafe,stroke:#2563eb,color:#1e3a8a classDef gate fill:#fef9c3,stroke:#ca8a04,color:#713f12 classDef pub fill:#dcfce7,stroke:#16a34a,color:#14532d classDef stop fill:#fee2e2,stroke:#dc2626,color:#7f1d1d ``` **Trigger chain - daily codegen to published release.** The recurring path that ships a new upstream Nx product version with no human in the loop: only a `codegen-main` matrix change reaches the publisher's pin push; the develop pin update is sync-only, and `:develop` / the weekly base refresh come from the schedule and dispatch (D4.1, D8.3). ```mermaid flowchart TD PER(["schedule daily 04:00 UTC
run-periodic-codegen-pull-request.yml
(or workflow_dispatch)"]):::trig --> CGM CGM["codegen matrix: main + develop
regenerate Version.json + Matrix.json"] --> DCH{"Matrix.json changed?"}:::gate DCH -- "no" --> NOPR(["no PR, nothing ships"]):::stop DCH -- "yes: main" --> PRM["codegen-main -> main PR
(merge-bot auto-merges)"] DCH -- "yes: develop" --> PRD["codegen-develop -> develop PR
(merge-bot auto-merges)"] PRD --> SYNC(["develop Matrix.json updated
sync-only, push trigger is main-only
:develop refreshed by dispatch"]):::stop PRM --> PUSH(["push to main
paths = Make/Matrix.json"]):::trig PUSH --> PUB["publish-release.yml
pin-push: build base + main's product matrix"] PUB --> SINK[("Docker Hub product + base images
+ main GitHub release")]:::pub SCHED(["weekly schedule (main)
base refresh for CVEs"]):::trig --> PUB DISP(["workflow_dispatch (main or develop)
force publish that branch"]):::trig --> PUB classDef trig fill:#dbeafe,stroke:#2563eb,color:#1e3a8a classDef gate fill:#fef9c3,stroke:#ca8a04,color:#713f12 classDef pub fill:#dcfce7,stroke:#16a34a,color:#14532d classDef stop fill:#fee2e2,stroke:#dc2626,color:#7f1d1d ``` ## 4. Behavioral contract - expected outcomes Each is a **MUST**, stated as input -> output plus the failure it prevents. ### D0 - Architecture - **D0.1 CI is one run, one branch.** Input: any CI run, meaning a pull request, a `develop` push, or a dispatch. Output: `test-pull-request` validates the run's own tree and publishes nothing. The smoke build reads `main`'s `Make/Matrix.json` rows when the pull request's base, or else the run's own branch, is `main`, and `develop`'s rows otherwise. *Prevents cross-branch ref mixing in CI.* - **D0.2 The publisher builds one branch: the trigger ref.** Output: the publisher passes `github.ref_name` as `branch` and the triggering `github.sha` as `ref`, so it checks out, versions, and tags exactly the run's own branch (the schedule/pin push's `main`, or a dispatch's branch). No branch matrix; the hub's `publish-plan-task.yml` publishes only `main`/`develop`. *Prevents cross-branch ref mixing - `github.ref` is the branch being published.* - **D0.3 One version, threaded.** Output: NBGV runs once (the hub's `get-version-task.yml`, inside `build-release-task.yml`); every consumer reads it via `needs:` outputs / the `semver2` input; no consumer recomputes it. *Allowed:* checking out a specific commit to compile it, and recording the built commit as the release `target_commitish`. *Prevents an image's embedded version diverging from its tag, and a second NBGV run colliding image tags.* ### D1 - CI fast feedback - **D1.1 Every CI run validates, and image changes smoke-build.** Output: on every pull request, `develop` push, and dispatch, the `validate` job (the hub's `validate-task.yml`) runs with no paths filter. A push to any other branch starts no CI run, so a branch is validated once it has a pull request. The `smoke-build` job (NxMeta + NxMeta-LSIO, amd64, no push) runs when the inline change-gate detects an image-file change. Those are `Docker/**`, `Make/Matrix.json`, `Make/Version.json`, `.github/actions/docker-*`, and `.github/workflows/**`, the last covering a hub pin bump. *Prevents a hook, Dockerfile, or hub-task break shipping untested.* - **D1.2 Unit tests always run.** Output: the hub's `validate-task.yml` runs `dotnet test` (the codegen tool + its tests). - **D1.3 Lint enforces the editor checks in CI.** Output: the hub's `validate-task.yml` runs `dotnet csharpier check` and `dotnet format style --verify-no-changes` - the same checks the editor and the Husky pre-commit hook run - plus the document linters, `actionlint`, the composite-action schema check, `shellcheck`, `editorconfig-checker`, and the hub's repo gates. - **D1.4 Smoke never publishes and never uploads a release asset.** Output: a smoke build compiles the image subset but makes no GitHub release and no Docker push. That is `smoke: true`, which disables every push in the hub's `build-release-task.yml`, and `github: false`. The Docker login runs on every build including smoke. That buys higher pull and cache rate limits against the registry buildcache. So a Dependabot pull request's smoke build needs the Docker Hub credentials in both secret stores. A fork pull request gets no secrets, so its smoke build fails where an image file changed (D6.2). - **D1.5 One required aggregator gates merge.** Output: a single aggregator job must **succeed**. That is success, or skipped for the conditionally-skipped `smoke-build`, and never failure or cancelled. It `needs:` `changes`, `validate`, and `smoke-build`, and treats a `changes` failure as blocking. So an image-changing PR cannot merge on a `changes` failure mis-read as skip. Its name is ruleset-bound and must not be renamed. Only a `pull_request` run yields that name, through an expression `name:`. A push or dispatch run posts `Check workflow status job` instead. So it cannot post the required context without the pull request's gates. ### D2 - Validation at entry - **D2.1 Validate the cross-input invariant before publishing.** Output: the hub's `validate-release` job asserts each cross-input invariant with `::error::` (the version backstop, D2.2) before anything builds; every build job `needs:` it. The publish run also re-runs the hub's `validate-task.yml` (the `validate` job gates `build-base` and `publish`). So a publish can never ship a tree that fails the same lint and `dotnet test` gate CI enforces on each pull request. That gate is re-checked on the published commit itself. - **D2.2 Main matches version classification.** Input: a real publish run. Output: the run fails loudly if `main` carries a prerelease suffix, or if any other branch carries none. It strips `+buildmetadata` before testing for the prerelease `-`. *Prevents a develop build published as the stable `latest`.* ### D3 - Versioning and classification - **D3.1 NBGV runs once, threaded.** Output: NBGV runs once, classifying from the checked-out branch; no consumer re-invokes it. The run builds the trigger ref, so `GITHUB_REF` already matches the branch being versioned and NBGV classifies it correctly (no `IGNORE_GITHUB_REF`). The threaded `semver2` is the image `LABEL_VERSION`. - **D3.2 `main` = stable, others = prerelease.** Output: `main` -> `X.Y.Z`, any other branch -> `X.Y.Z-g`. The release-version backstop names `main`; `publicReleaseRefSpec` is `^refs/heads/main$`. - **D3.3 Version floor + git height.** Output: `version.json` sets the major.minor floor, NBGV appends the git height as the patch, never bumped on a cadence. *(Who raises the floor and when is a human-process rule in [`GOVERNANCE.md` "Release Model"][governance-release-model].)* ### D4 - Release / publish - **D4.1 Publish only on schedule, the matrix-pin push, or dispatch - never on an ordinary merge.** Output: `publish-release` triggers are `schedule` (weekly), `workflow_dispatch`, and a `push` **branch-filtered to `main` and path-filtered to `Make/Matrix.json`**. There is no other `push` trigger and no `PUBLISH_ON_MERGE` variable. The hub's `publish-plan-task.yml` publishes only `main` and `develop`, and fails a dispatch from a feature branch with an `::error::`, publishing nothing. *Prevents per-merge release churn while still shipping a new product pin at once.* - **D4.2 A publish builds the one trigger branch in full.** Output: the run builds the shared base (main run only) + the full product matrix and creates the GitHub release for `github.ref_name` - the schedule/pin push rebuilds `main` (stable / `latest`); a dispatch publishes its own branch (`main` stable / `latest`, `develop` prerelease / `:develop`, no GitHub release). *Prevents a half-published image set and cross-branch ref mixing.* - **D4.3 Tag the built commit.** Output: the release `target_commitish` is the run's `GitCommitId` (the tip of `main`), and main's images are built from that pinned commit, never the moving ref. *Prevents the tag / embedded version landing on the wrong commit.* - **D4.4 Release contents and gate.** Output: a release is a tag on the built commit plus the auto source zip, README, and LICENSE - no binary release assets (`expect_release_assets: false`; the images are the artifact). The release is `main`-only (`github: true` only when the plan says stable); `prerelease: false`. *Prevents publishing a develop build as a stable GitHub release.* - **D4.5 No-op republish.** Input: a weekly re-run whose version is unchanged. Output: the release-create step is skipped when the tag already exists (refreshed only on `workflow_dispatch`), while the Docker push still runs - re-pushing the same tags refreshes the shared base image. *Prevents duplicate releases while still refreshing the images.* - **D4.6 Publish is built from the branch CI gated.** Output: the run's ref **is** the published branch, so the hooks and the built tree resolve from that branch. The required check gates every merge to it, and the hub tasks resolve at the same pinned commit CI used. CI does not run on a `main` push, so the merged tree can differ from every merge ref a pull request run tested. The publish run therefore re-runs the hub's `validate-task.yml` on that commit (the `validate` job gates `build-base` and `publish`). The version backstop (D2.2) is the additional in-publisher gate. - **D4.7 Docker publishing authenticates with Docker Hub credentials.** Output: the publisher's `build-base` job and the hub's product build each log in via `docker/login-action` with `DOCKER_HUB_USERNAME` + `DOCKER_HUB_ACCESS_TOKEN` and push with `docker/build-push-action`; the hub's readme task pushes the Docker Hub overview with the same token, mapped by name to each hub task. There is **no NuGet/OIDC publishing** in this repo. *Prevents a missing-credential publish failure.* - **D4.8 Branch-scoped Docker buildcache.** Output: the product build reads both branches' registry caches (`buildcache-main`, `buildcache-develop`) and writes only its own branch's cache, only when pushing, so a `main` and a `develop` publish never overwrite each other's cache. The shared base, pushed only by a `main` publish, reads and writes `buildcache-main` alone. *Prevents one branch's publish destroying the other's cache hit-rate.* - **D4.9 Multi-arch, multi-product, shared-base fan-out.** Output: the publish builds every product image from `Make/Matrix.json` for `linux/amd64` + `linux/arm64`, on the shared base built once and reused; each product image pushes to its own Docker Hub repo. *Prevents a per-arch or per-product gap, and a redundant per-branch base rebuild overwriting the shared tag.* ### D5 - Resource cleanup - **D5.1 No dangling transfer artifacts.** Output: neither the publisher nor CI uploads a transfer artifact - the images push straight to Docker Hub and the release carries no `release-asset-*` files - so a run leaves none behind. The hub's `github-release` job owns the consume-then-delete cleanup (`continue-on-error`) for a target that does upload one. - **D5.2 Never red the run on cleanup.** Cleanup failures warn, never fail. ### D6 - Self-testing workflows - **D6.1 A change is testable on its own branch.** Output: a workflow or build change is exercised by CI on the branch that introduces it, no dependency on reaching `main` first. - **D6.2 Head-resolution, single producer, fork exception.** Output: CI runs on `pull_request`, so the `./.github/actions/` hooks resolve from the head (the hub tasks resolve at their pin). Only that run yields the aggregator's ruleset-bound `context:`, so it is the sole producer of that name. Dependabot and codegen PRs are in-repo branches, validated the same way. A fork pull request runs without secrets. Where it changes an image file its smoke build fails, and it is landed through an in-repo branch by maintainer action. That is the one exception. *Prevents a dual-producer context race and a false self-test claim for forks.* ### D7 - Concurrency, permissions, safety - **D7.1 The publisher serializes per ref.** Output: the ref-scoped group `${{ github.workflow }}-${{ github.ref }}`, `cancel-in-progress: false`. A push the plan does not publish appends `github.run_id`, so it never replaces a pending publish. That is a push off `main`, or one by an actor off the plan's allowlist. `main` and `develop` push disjoint tags, since a develop publish pushes no base image or readme. CI uses the same group with `cancel-in-progress: true`. The merge-bot keys on PR number (D8.1), and codegen keys on the workflow. *Prevents a schedule and a dispatch double-pushing on one ref, and a no-op run replacing a pending publish.* - **D7.2 Skipped jobs still need valid permissions.** Output: every reusable job runs under valid least-privilege `permissions:`; a callee's extra scope is granted by the caller. - **D7.3 Boolean inputs both forms.** Declared in both trigger blocks, compared against `true` and `'true'`. - **D7.4 Branch-deletion guard.** Output: every CI job carries `if: !github.event.deleted` and the aggregator `always() && !github.event.deleted`. Deleting a feature or bot branch starts no CI run, since only a `develop` push triggers one. So the guard matters only for a deletion of `develop` itself. That run's `github.sha` reverts to the default branch's tip, so it would otherwise validate and smoke-build `main`'s tree under the deleted `develop` ref. *Prevents a run that tests the wrong tree under a deleted ref.* ### D8 - Bots and automation - **D8.1 Merge-bot.** Output: a thin caller onto the hub's `merge-bot-task.yml`, run on `pull_request_target`, holding the App token, merging the PR by URL without checking out its code. Enables auto-merge on `opened`/`reopened` with `--delete-branch` (the `delete-branch: true` input); squash on `develop`, merge-commit on `main` by the PR's base ref; disables auto-merge when a maintainer pushes to a bot branch (no `--delete-branch` on the disable path). Concurrency keyed on PR number. - **D8.2 Dependabot auto-merges on green.** Output: every Dependabot PR, any ecosystem and any tier, auto-merges once the required checks pass. A failing check blocks the merge. A merged dependency bump does **not** itself publish (it ships in the next scheduled run or the next matrix-pin push). - **D8.3 Codegen dual-targets `main` AND `develop`.** Output: the daily codegen matrix runs the hub's `run-codegen-pull-request-task.yml` with the `codegen` hook. It opens a `codegen-main` -> `main` and a `codegen-develop` -> `develop` PR, with strict head/base pairing in the merge-bot. Each regenerates `Make/Version.json` + `Make/Matrix.json` **only**. The Dockerfiles are a separate, human-driven `Make/create.sh` path. The merge-bot auto-merges each independently. develop's matrix update is sync-only; a merged `codegen-main` matrix change fires the publisher's pin push. *Prevents non-linear rebase/merge-block conflicts (the rejected single-target scheme) and keeps both branches current with upstream Nx versions.* - **D8.4 Forward-only version guard.** Output: the codegen tool's forward-only guard (`ReleaseVersionForward`, covered by `CreateMatrixTests`) prevents a regenerated matrix from regressing a product version. *Prevents a generic-tag downgrade slipping in via codegen.* ### D9 - Style, static, and dropped workflows (see section 2) - **D9.1** Every action SHA-pinned with a version comment (sole exception: `dotnet/nbgv@master`, whose tag stream lags master so Dependabot tag-tracking would only propose downgrades to stale tags - a deliberate documented float, rationale inline in the hub's `get-version-task.yml`); an installed-tool version is left unpinned to track latest. - **D9.2** File/workflow/job/step names follow the suffix rules; a ruleset-bound `context:` name moves only in lockstep with the live ruleset and the hub payload it is applied from. - **D9.3** Bash `run:` blocks start `set -Eeuo pipefail`; multi-line `if:` uses `>-`. - **D9.4** Line endings follow `.editorconfig`. - **D9.5 No decorative / dropped workflows.** No date-badge (`build-datebadge-*`), no carried `-task.yml` (every task is hub-hosted), no `PUBLISH_ON_MERGE` variable, no `dorny/paths-filter` (replaced by the inline change-gate). Their presence is a defect to remove. - **D9.6** Style is enforced in CI by the hub's `validate-task.yml` (D1.3), from the same config files the editor and Husky hook use. ### D10 - Repository configuration - **D10.1 Required configuration is present.** Output: the secrets, branch rulesets, and repository settings section 6 lists are all in place, codified in the hub's repository-configuration payloads and audited by the hub's `configure.sh check` (the 5D audit). The detail is in section 6. ## 5. Test methodology ### 5A. Static audit (no execution) Read the workflow files plus `version.json` and `Make/Matrix.json` and assert the fact behind each applicable guarantee with a `file:line` citation: - **D0:** CI has no branch matrix; the publisher passes `github.ref_name` as `branch` and `github.sha` as `ref`, and the plan task publishes only `main`/`develop`; NBGV invoked once in the hub's `build-release-task.yml`, whose Docker leg consumes the threaded `semver2`; the run builds the trigger ref so `GITHUB_REF` matches the versioned branch. - **D1:** CI runs on `pull_request` with no paths filter on `validate`. The inline `changes` gate sets `image`/`base`. The `smoke-build` job is `smoke: true`, `github: false`, `dockerhub: false`, with the NxMeta subset named by `docker_image`. The aggregator `needs:` `changes` + `validate` + `smoke-build`, blocks on non-success, treats `changes` failure as blocking. - **D2:** the hub's `validate-release` checks the prerelease `-`, strips `+buildmetadata`; the hub's `validate-task.yml` is the shared gate. - **D3:** `main` appears in the backstop and the release `prerelease: false`/guard; `publicReleaseRefSpec` is `^refs/heads/main$`; `semver2` threads to `LABEL_VERSION`. - **D4:** `publish-release` triggers are `schedule` + `workflow_dispatch` + `push` (branches `[main]`, paths `[Make/Matrix.json]`) only (no other push, no `PUBLISH_ON_MERGE`); every job gates on the plan outputs; `ref` is `github.sha`, which the hub versions and tags as `GitCommitId`; `build-base` runs only when stable and develop reuses the base (`docker_build_base: false`); the builds log in with `DOCKER_HUB_*`; buildcache branch-scoped and write-gated on push; release-create gated `exists == false || workflow_dispatch`; `github` and `publish-docker-readme` gated to stable; the `docker-prepare` hook emits the branch's `Make/Matrix.json` rows, built amd64+arm64 on `main`. - **D5:** no job uploads a transfer artifact; `expect_release_assets: false`. - **D6:** CI is `pull_request`, plus a `develop` push and dispatch. The hooks resolve from the checkout. Only the `pull_request` run yields the aggregator context. Every CI job has the `!github.event.deleted` guard. - **D7:** the publisher group is ref-scoped with `cancel-in-progress: false`. The merge-bot keys on PR number, and codegen keys on the workflow. CI uses the standard group and the deletion guard. Every entry workflow declares `permissions: {}`, and each calling job grants its task's scope. - **D8/D9:** the merge-bot calls the hub's `merge-bot-task.yml` on `pull_request_target`, keyed on PR number, with `delete-branch: true`; Dependabot auto-merges every tier; codegen dual-targets main+develop and its hook regenerates only `Version.json`/`Matrix.json`; no date-badge, carried `-task.yml`, `PUBLISH_ON_MERGE`, or `dorny/paths-filter`; actions and hub tasks SHA-pinned except `nbgv@master`; names/shells/conditionals per section 2. ### 5B. End-to-end trace scenarios (deterministic from the YAML) | # | Input | Expected output | Exercises | | --- | --- | --- | --- | | S1 | PR touching `Docker/**` | `validate` + `smoke-build` (NxMeta amd64) run, **no push, no release**; aggregator success; no dangling artifacts | D0.1, D1 | | S2 | PR changing only docs | `validate` runs, the `changes` gate sets `image=false`, and `smoke-build` is skipped. The aggregator succeeds, since a skip is allowed | D1, D1.5 | | S3 | PR changing only `.github/workflows/**` (a hub pin bump included) | `validate` + `smoke-build` run, with **no push and no release**. The aggregator succeeds | D1.1, D6.1 | | S4 | weekly `schedule` | builds + publishes `main` only: shared base refresh + full product matrix (amd64+arm64) + stable release + `latest`; `target_commitish` = main's SHA; develop untouched; no dangling artifacts | D4.1, D4.2, D4.9 | | S5 | push to `main` changing `Make/Matrix.json` (codegen pin) | publishes `main` with the new product versions immediately | D4.1, D8.3 | | S6 | `workflow_dispatch` from `develop` | builds + publishes `develop`: `:develop` images, prerelease classification, `build-base` skipped (reuses main's base), **no GitHub release** | D4.1, D4.2, D3.2 | | S7 | `workflow_dispatch` re-run on `main`, no new commits | release-create refreshed on dispatch (skipped on schedule if the tag exists); Docker re-pushed (base refresh); no duplicate release | D4.5 | | S8 | `workflow_dispatch` from a feature branch | the plan job fails with an `::error::` and every later job skips -> no publish | D4.1 | | S9 | merged dependency bump (any) | not a matrix-pin change; merges don't publish -> **no release**; ships in the next scheduled run | D4.1, D8.2 | | S10 | merged develop codegen PR (`Matrix.json` change on develop) | sync-only; the pin push is main-only -> **no publish** | D8.3 | | S11 | PR with a CSharpier / format / unit-test failure | `validate` fails -> aggregator blocks the merge | D1.2, D1.3, D1.5 | | S12 | `version.json` floor bump merged | merges don't publish -> no immediate release; the new floor ships in the next publish | D3.3, D4.1 | | S13 | Dependabot semver-major NuGet bump | auto-merges on green like every other tier; a red check blocks it | D8.2 | | S14 | branch deletion | a feature or bot branch deletion starts no CI run. A `develop` deletion starts one in which every job and the aggregator skip (`!github.event.deleted`), so nothing fails | D7.4 | | S15 | `develop` -> `main` promotion (merge commit) | the merge itself does not publish; if it changed `Matrix.json` the pin push publishes main, else the next schedule does | D4.1, D8.1 | ### 5C. Live probe (where warranted, never publishing) - Open a trivial doc-only PR and confirm S2 (`validate` runs, `smoke-build` skipped, aggregator green, 0 artifacts left); open an image-touching PR and confirm S1 (smoke-build runs amd64, nothing pushed). - After a `main` publish (schedule, pin push, or dispatch) confirm a stable release (`isPrerelease == false`) with multi-arch product images (`docker buildx imagetools inspect` shows amd64 + arm64) and the shared base tags intact; after a `develop` dispatch confirm `:develop` images, prerelease classification, and that the shared `nx-base:ubuntu-noble` tag was not overwritten. A re-run adds no duplicate release. Absent publish rights, record indeterminate and rely on 5A/5B. - Trigger codegen via dispatch: confirm both `codegen-main` -> `main` and `codegen-develop` -> `develop` PRs open and the merge-bot auto-merges with branch deletion. ### 5D. Configuration audit Run the hub's `repo-config/configure.sh check / release` from a hub checkout at `main`. It confirms the listed secrets exist (in both stores), the `main`/`develop` rulesets enforce the required merge method + status check + signed commits + strict-off, and the repository settings are in place, exiting non-zero on drift. Secret *values* cannot be read back, so it asserts the names exist (failing if it cannot query them). The GitHub App installation is a best-effort check (a precise check needs app-level auth, so it notes rather than fails). The Docker Hub token's validity and push scope across the 12 repositories are a manual checklist item. ### Assessment Operational when every applicable 5A item passes, every applicable 5B scenario matches (corroborated by 5C where a live signal exists), and 5D configuration is in place. Procedure: **Audit** (5A + 5D) -> **Trace** (5B) -> **Probe** (5C, without publishing) -> **Verdict** with the failing guarantee(s) and the triggering input for each. ## 6. Repository configuration The workflows depend on configuration outside the YAML. A misconfiguration surfaces only as a failed run, so the configuration is part of "operational" (D10; audit 5D). **Secrets.** - `DOCKER_HUB_USERNAME` / `DOCKER_HUB_ACCESS_TOKEN` - Docker Hub credentials the base and product builds log in with to push the images and the repository overviews. Required in **both** the Actions and Dependabot secret stores. A Dependabot pull request's CI run gets the Dependabot store, and its Docker smoke build logs in too when an image file changed. The access token needs push scope on every product + base repo under `docker.io/ptr727/` (derived from `Make/Matrix.json`). There is no NuGet/OIDC publishing. - `CODEGEN_APP_CLIENT_ID` / `CODEGEN_APP_PRIVATE_KEY` - the GitHub App credentials the merge-bot and the codegen PR-opener mint the App token from. Required in **both** the Actions and Dependabot secret stores (a Dependabot-triggered run gets the Dependabot store). The App must be installed on the repo with `contents: write` and `pull_requests: write`. - The built-in `GITHUB_TOKEN` needs no setup. **No `PUBLISH_ON_MERGE` variable is used.** **Branch rulesets.** - `main` - merge-commit merges only; requires the aggregator status check (`Check pull request workflow status job`); requires signed commits; "require branches up to date before merging" is **off** (a forward-only `develop` makes every post-release `main` tip unreachable from `develop`, so the strict check would fail every release). - `develop` - squash merges only (keeps history linear); requires the same status check; requires signed commits; "up to date" is **off** (so same-batch bot PRs auto-merge in parallel). - The required check's `context:` matches the aggregator job name verbatim (D6.2, D9.2). **Repository settings.** Auto-merge enabled; squash and merge-commit both allowed (each ruleset narrows its branch to one); rebase off; auto-delete-on-merge **off** (so `main`/`develop` survive a promotion; the merge-bot deletes bot branches explicitly through its `delete-branch: true` input). Dependabot version **and** security updates enabled. The GitHub App installed with the scopes above. **Validation.** This configuration is codified in the hub's repository-configuration payloads and applied/audited by the hub's `configure.sh`; `check` is the 5D audit. Secret values cannot be read back, so the audit asserts the names exist (failing if they cannot be queried); the App installation is a best-effort check. [actions]: ./.github/actions/ [actions-codegen]: ./.github/actions/codegen/action.yml [actions-docker-build-base]: ./.github/actions/docker-build-base/action.yml [actions-docker-prepare]: ./.github/actions/docker-prepare/action.yml [codestyle]: ./CODESTYLE.md [docker-readme]: ./Docker/README.md [editorconfig]: ./.editorconfig [governance-release-model]: ./GOVERNANCE.md#release-model [publish-release]: ./.github/workflows/publish-release.yml [run-periodic-codegen-pull-request]: ./.github/workflows/run-periodic-codegen-pull-request.yml [test-pull-request]: ./.github/workflows/test-pull-request.yml [workflows]: ./.github/workflows/