forgedock 1.60.1 → 1.61.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/config-schema.mjs +44 -1
- package/bin/engine/runlog.mjs +52 -0
- package/bin/engine-cli.mjs +9 -4
- package/bin/env/bench.mjs +38 -0
- package/bin/env/cli.mjs +134 -0
- package/bin/env/env.mjs +339 -0
- package/bin/forgedock.mjs +32 -3
- package/bin/help-text.mjs +2 -0
- package/bin/lean/ci-budget.mjs +3 -1
- package/bin/lean/ci-classify.mjs +74 -0
- package/bin/lean/ci-classify.test.mjs +147 -0
- package/bin/lean/ci-emit.mjs +175 -0
- package/bin/lean/ci-emit.test.mjs +177 -0
- package/bin/lean/ci-preflight.mjs +183 -0
- package/bin/lean/ci-preflight.test.mjs +122 -0
- package/bin/lean/ci-runner-health.mjs +213 -0
- package/bin/lean/ci-runner-health.test.mjs +113 -0
- package/bin/lean/ci-watch.mjs +79 -0
- package/bin/lean/ci-watch.test.mjs +80 -0
- package/bin/lean/depcache.mjs +38 -8
- package/bin/lean/deploy-stages.mjs +514 -0
- package/bin/lean/deploy-stages.test.mjs +580 -0
- package/bin/lean/effects.mjs +50 -0
- package/bin/lean/execution.mjs +8 -1
- package/bin/lean/lean.mjs +38 -6
- package/bin/lean/lean.test.mjs +61 -0
- package/bin/lean/release-deploy.mjs +12 -6
- package/bin/lean/release-flakes.mjs +16 -0
- package/bin/lean/release-flakes.test.mjs +15 -0
- package/bin/lean/release-gates.mjs +24 -1
- package/bin/lean/release-ledger.mjs +21 -0
- package/bin/lean/release-minutes-timing.test.mjs +57 -0
- package/bin/lean/release-minutes.mjs +98 -0
- package/bin/lean/release-promote.mjs +444 -0
- package/bin/lean/release-promote.test.mjs +470 -0
- package/bin/lean/release-rollback.mjs +14 -6
- package/bin/lean/release.mjs +31 -2
- package/bin/lean/sandbox-remote.mjs +11 -3
- package/bin/lean/testengine-recall.mjs +82 -0
- package/bin/lean/testengine-recall.test.mjs +103 -0
- package/bin/lean/testengine-shard.mjs +150 -0
- package/bin/lean/testengine-shard.test.mjs +111 -0
- package/bin/lean/testengine.mjs +486 -0
- package/bin/lean/testengine.test.mjs +303 -0
- package/bin/lean/verify-settle.test.mjs +156 -0
- package/bin/lean/verify.mjs +98 -3
- package/bin/pool/agent.mjs +57 -6
- package/bin/pool/ci-events.mjs +189 -0
- package/bin/pool/ci-events.test.mjs +143 -0
- package/bin/pool/docker.mjs +7 -0
- package/bin/pool/lane-tools.mjs +1 -0
- package/bin/pool/router.mjs +25 -1
- package/bin/pool/warm.mjs +1 -1
- package/bin/stats/ci-awareness.mjs +66 -0
- package/bin/stats/index.mjs +44 -3
- package/bin/stats/release-ledger.test.mjs +226 -0
- package/bin/stats/release.mjs +365 -1
- package/bin/stats/stats.test.mjs +36 -0
- package/docs/CI.md +31 -0
- package/docs/CONFIG.md +235 -2
- package/docs/ENV-LIBRARY.md +172 -0
- package/docs/STATS.md +43 -0
- package/docs/ci-events.md +88 -0
- package/docs/test-engine.md +98 -0
- package/package.json +1 -1
- package/pool/README.md +1 -0
- package/pool/image/entrypoint.sh +15 -3
- package/pool/services/docker-compose.yml +53 -0
- package/pool/services/git-mirror.sh +22 -0
- package/templates/github-actions/forge-env/action.yml +65 -0
package/docs/CONFIG.md
CHANGED
|
@@ -620,6 +620,42 @@ ci:
|
|
|
620
620
|
|
|
621
621
|
`forgedock ci budget [--repo owner/repo] [--json] [--digest] [--propose [--base REF]]` prints the plan, included minutes, month-to-date usage across the account (billing usage API: needs a token that can read the org or user billing), the projection, the active mode, alerts (projected overage, a new burn source such as a repo flipped private) and the parity hit rate (local green -> remote red, per suite). `--digest` adds the per-repo and per-workflow month digest; `--propose` lists the runnable local jobs derived from the repo's workflow files (same tool pins). `--set-mode`, `--budget`, `--reserve`, `--plan` write the `ci` block (see `/forgedock-ci-setup`). Runner minutes are weighted by OS (Linux 1, Windows 2, macOS 10). Caches live in `~/.forge/ci-budget/` (`FORGEDOCK_CI_BUDGET_DIR`).
|
|
622
622
|
|
|
623
|
+
### `ci.tests` test engine (forge#5710)
|
|
624
|
+
|
|
625
|
+
Affected-test selection, shard planning and flaky quarantine for `forgedock tests select|shard|recall` (see [test-engine.md](test-engine.md)). Off by default. Block style; the parser flattens these keys under `ci`, so their names are unique within `ci`.
|
|
626
|
+
|
|
627
|
+
```yaml
|
|
628
|
+
ci:
|
|
629
|
+
tests:
|
|
630
|
+
selection: shadow # off (default) | shadow | enforce (refused until the recall ledger graduated)
|
|
631
|
+
suites: # "<path glob> ... => <test-file glob | @suite | *> ..."
|
|
632
|
+
- "migrations/** => tests/integration/**"
|
|
633
|
+
# run_all: ["infra/**"] # extra globs that select everything (lockfiles, manifests and CI files always do)
|
|
634
|
+
# ignore: ["**/*.md"] # changed files that select nothing
|
|
635
|
+
# test_globs: ["tests/**/*.py"] # replaces the *.test.* / *.spec.* / __tests__ / test_*.py / *_test.py convention
|
|
636
|
+
# full_branches: [main, "release/**"] # head or PR-base branches that always run the full suite
|
|
637
|
+
graduate_after: 50 # consecutive full runs with 100% failure recall before enforce may skip
|
|
638
|
+
graduate_min_failing: 1 # of those, subset selections that contained a real failure
|
|
639
|
+
shards: 4 # default shard count of `tests shard`
|
|
640
|
+
# shard_target_s: 240 # or derive the count from a per-shard time target
|
|
641
|
+
quarantine: report # off | report (default) | non-blocking (opt-in; never for an unskippable class)
|
|
642
|
+
quarantine_after: 3 # same-commit fail -> pass flips ...
|
|
643
|
+
quarantine_window_days: 14 # ... inside this window
|
|
644
|
+
# recall_ledger: /var/lib/forge/recall.jsonl # default ~/.forge/tests/<owner>__<repo>/recall.jsonl
|
|
645
|
+
```
|
|
646
|
+
|
|
647
|
+
| Key | Type | Default | Description |
|
|
648
|
+
|---|---|---|---|
|
|
649
|
+
| `selection` | string | `off` | `off`: nothing is computed. `shadow`: the selection is recorded and the full suite runs. `enforce`: only the selection runs, once the ledger graduated; before that it behaves as `shadow` and says so. |
|
|
650
|
+
| `suites` | list | none | Declared path -> suite map, the fallback for what the import graph cannot see. |
|
|
651
|
+
| `run_all`, `ignore`, `test_globs`, `full_branches` | list | see above | Selection inputs. Changing `suites`, `run_all`, `ignore` or `test_globs` restarts graduation. |
|
|
652
|
+
| `graduate_after`, `graduate_min_failing` | number | 50, 1 | Graduation criterion. |
|
|
653
|
+
| `shards`, `shard_target_s` | number | none | Shard count, or a time target to derive it from. |
|
|
654
|
+
| `quarantine`, `quarantine_after`, `quarantine_window_days` | string, number, number | `report`, 3, 14 | Flaky-test report. Quarantined tests always run. |
|
|
655
|
+
| `recall_ledger` | string | per-repo file under `~/.forge/tests/` | Where the recall ledger lives. |
|
|
656
|
+
|
|
657
|
+
Scheduled runs and `full_branches` always run the full suite, whatever the mode. **Commands that use this section**: `forgedock tests select`, `forgedock tests shard`, `forgedock tests recall`.
|
|
658
|
+
|
|
623
659
|
## `execution` (OPTIONAL)
|
|
624
660
|
|
|
625
661
|
Owner opt-in for the paid API agent backend (#4257). The API backend is **never the default**: under `--backend auto` (the default) ForgeDock uses the `claude` CLI, and when no CLI is available it fails with `CLI_BACKEND_UNAVAILABLE` instead of billing `ANTHROPIC_API_KEY`.
|
|
@@ -838,7 +874,7 @@ The release state (and so the ledger) records `lane` and `minutes: {runs, total}
|
|
|
838
874
|
|
|
839
875
|
### Deploy gate catalogue and false-block telemetry (#5583)
|
|
840
876
|
|
|
841
|
-
Optional; with no `.forge/gates.yaml` (on the ref) every command below is a no-op with zero writes. `forgedock release check-config` validates the file when present. Fields per gate under `gates:` (`schema: 1`): `id`, `protects_against` (origin issue), `where`, `determinism`, `pre_merge_artifact` (fixture), `version`, `mode` (`block|skip|rollback|freeze|warn|red`), `owner`, `review_by` (`YYYY-MM-DD`); admission also needs `on_uncertainty: inconclusive`, `failure_triggers` and `proportionality`.
|
|
877
|
+
Optional; with no `.forge/gates.yaml` (on the ref) every command below is a no-op with zero writes. `forgedock release check-config` validates the file when present. Fields per gate under `gates:` (`schema: 1`): `id`, `protects_against` (origin issue), `where`, `determinism`, `pre_merge_artifact` (fixture), `version`, `mode` (`block|skip|rollback|freeze|warn|red`), `owner`, `review_by` (`YYYY-MM-DD`); admission also needs `on_uncertainty: inconclusive`, `failure_triggers` and `proportionality`. Optional `evidence_check: <required check name>` marks a gate that re-runs work a required check already did; see [`deploy.promote`](#deploypromote-optional) for when that evidence lets the gate be skipped (a safety gate never is).
|
|
842
878
|
|
|
843
879
|
`.forge/release.yaml` `gates:`: `demote_fb_rate` (percent, default 5), `demote_window` (runs, default 20), `safety` (never demoted; default `migration-immutability`, `identity-preflight`, `backup-freshness`, `health-auto-restore`, plus the unskippable classes).
|
|
844
880
|
|
|
@@ -1071,6 +1107,7 @@ These keys are rejected by `release check-config` until their phase ships:
|
|
|
1071
1107
|
| `forgedock release p0` | Hotfix lane for an issue or branch (`--units`, `--preempt`, `--yes`). |
|
|
1072
1108
|
| `forgedock release verify` | Verify a release sha, or re-run deploy verification of a release id. |
|
|
1073
1109
|
| `forgedock release recover` | Recover a release that stopped mid-deploy. |
|
|
1110
|
+
| `forgedock release deploy` | Deploy stage engine (`deploy.engine`): `--plan [<id>] [--sha]` lists the stages that would run and why; `--resume <id> [--sha]` continues from the first failed or incomplete stage. |
|
|
1074
1111
|
| `forgedock release rollback` | Roll a release back (`--reason`, `--to flag\|unit\|full`, `--later`). |
|
|
1075
1112
|
| `forgedock release plan` | Build the release plan for a lane. |
|
|
1076
1113
|
| `forgedock release start` | Start a planned release (`--plan`, `--approve`, `--wave`). |
|
|
@@ -1081,12 +1118,96 @@ These keys are rejected by `release check-config` until their phase ships:
|
|
|
1081
1118
|
| `forgedock release init` | Write the zero-config profile. |
|
|
1082
1119
|
| `forgedock release control` | Audited controls: `hold`, `resume`, `cancel`, `lane`, `exempt`, `freeze`, `unfreeze`; each also runs as `forgedock release <verb>` and needs `--reason`. `demote`, `promote`, `rollback` and `regate` are control verbs too. |
|
|
1083
1120
|
| `forgedock release gates` | Gate telemetry (`check`, `demote`, `record`). |
|
|
1121
|
+
| `forgedock release promote` | With `--check`, `--gate`, `--attest`, `--observed`, `--report` or `--images`: build once, promote (`deploy.promote` in forge.yaml, #5711). With a gate id and `--fixture`: the control verb. |
|
|
1084
1122
|
| `forgedock release report` | Model vs measured Actions minutes. |
|
|
1085
1123
|
| `forgedock intake` | `pause`, `resume` or `status` of issue intake (`_active.intake`). |
|
|
1086
1124
|
| `forgedock ci budget` | Actions-minute budget and CI placement (#5278). |
|
|
1087
1125
|
| `controls log` | The `controls.jsonl` audit line every control verb appends; read it through `release status` and `release explain`. |
|
|
1088
1126
|
| `ci flakes`, `ci nightly` | Records, not commands: the flake ledger (`_active.flakes`) and the nightly result, read through `release status`, `release explain` and `release report`. |
|
|
1089
1127
|
|
|
1128
|
+
## `deploy.promote` (OPTIONAL)
|
|
1129
|
+
|
|
1130
|
+
Build once, promote (#5711). The release commit's CI result is recorded as evidence bound to the commit, its tree and the image digests; the deploy side checks that evidence instead of re-running tests, builds and rehearsals that already passed on the same tree. **Default off.** Once enabled it starts in shadow: it records what it would have skipped while the full pre-gate still runs.
|
|
1131
|
+
|
|
1132
|
+
```yaml
|
|
1133
|
+
deploy:
|
|
1134
|
+
promote:
|
|
1135
|
+
enabled: true # default false: nothing is read or written
|
|
1136
|
+
shadow: true # default true: record only. false = act on the evidence
|
|
1137
|
+
required_checks: [unit, build] # default: gate.required_checks, then .forge/release.yaml ci.required_checks
|
|
1138
|
+
evidence_app: github-actions # the only app whose evidence check run is trusted (default github-actions)
|
|
1139
|
+
cache_ref: registry.example/acme/buildcache # registry layer cache, one tag per service
|
|
1140
|
+
cache_mode: max # min | max (default max)
|
|
1141
|
+
builder: "" # buildx builder name (a persistent builder keeps cache mounts)
|
|
1142
|
+
rebuild_all: ["docker/base/**"] # a change here rebuilds every image
|
|
1143
|
+
services:
|
|
1144
|
+
web:
|
|
1145
|
+
image: registry.example/acme/web
|
|
1146
|
+
context: web # default "."
|
|
1147
|
+
dockerfile: web/Dockerfile # default <context>/Dockerfile
|
|
1148
|
+
paths: ["packages/ui/**"] # build inputs outside the context
|
|
1149
|
+
cache_paths: ["/app/.next/cache"] # build cache mounts the Dockerfile declares
|
|
1150
|
+
api:
|
|
1151
|
+
image: registry.example/acme/api
|
|
1152
|
+
context: services/api
|
|
1153
|
+
paths: ["libs/shared/**", "uv.lock"]
|
|
1154
|
+
cache_paths: ["/root/.cache/uv"]
|
|
1155
|
+
```
|
|
1156
|
+
|
|
1157
|
+
| Key | Type | Default | Description |
|
|
1158
|
+
|-----|------|---------|-------------|
|
|
1159
|
+
| `deploy.promote.enabled` | boolean | `false` | Master switch. Anything but `true` is off. |
|
|
1160
|
+
| `deploy.promote.shadow` | boolean | `true` | `true`: the decision is recorded and the pre-gate still runs. `false`: accepted evidence skips the pre-gate. |
|
|
1161
|
+
| `deploy.promote.required_checks` | list | `gate.required_checks`, then the policy's `ci.required_checks` | Check runs that must be `success` on the attested commit. With none, nothing is attested or skipped. |
|
|
1162
|
+
| `deploy.promote.evidence_app` | string | `github-actions` | App slug whose `forge/promote-evidence` and `forge/promote-decision` check runs are read. |
|
|
1163
|
+
| `deploy.promote.cache_ref` | string | none | Registry repository for the layer cache; each service uses the tag `<cache_ref>:<service>`. Without it no cache flags are emitted. |
|
|
1164
|
+
| `deploy.promote.cache_mode` | `min`\|`max` | `max` | `mode=` of `--cache-to`. |
|
|
1165
|
+
| `deploy.promote.builder` | string | none | `--builder` for every build. |
|
|
1166
|
+
| `deploy.promote.rebuild_all` | list of globs | none | A changed path matching one rebuilds every image. |
|
|
1167
|
+
| `deploy.promote.services.<name>.image` | string | required | Image repository; the build is tagged `<image>:<sha>`. |
|
|
1168
|
+
| `deploy.promote.services.<name>.context` | string | `.` | Build context. Every path under it is a build input. |
|
|
1169
|
+
| `deploy.promote.services.<name>.dockerfile` | string | `<context>/Dockerfile` | Dockerfile path; also a build input. |
|
|
1170
|
+
| `deploy.promote.services.<name>.paths` | list of globs | none | Build inputs outside the context. A service with context `.` and no `paths` is rebuilt on every change. |
|
|
1171
|
+
| `deploy.promote.services.<name>.cache_paths` | list | none | Targets of `RUN --mount=type=cache` mounts (a framework build cache, a package-manager cache). |
|
|
1172
|
+
| `deploy.promote.services.<name>.cache_ref` | string | `<cache_ref>:<name>` | Layer-cache reference of this service. |
|
|
1173
|
+
|
|
1174
|
+
Without `services`, the `units` of `.forge/release.yaml` that name an `image` are used (`paths`, `dockerfile`).
|
|
1175
|
+
|
|
1176
|
+
**Evidence.** `forgedock release promote --attest --sha <sha> --digests <file|json>` reads the check runs of the commit and, only when every required check concluded `success` on exactly that commit, writes the attestation `{commit, tree, images, checks: [{name, conclusion, id, run_id}], config_hash}` as the output of a `forge/promote-evidence` check run on the commit. The token must belong to an app with `checks: write` (the workflow `GITHUB_TOKEN` does). A failed, missing, skipped or unfinished required check, a malformed digest, or a configured service without a digest: exit 1, nothing written.
|
|
1177
|
+
|
|
1178
|
+
**Decision.** `forgedock release promote --gate --sha <sha> --digests <file|json>` is the deploy-side call. Evidence is looked up on the commit, its parents (a merge commit of the attested head) and the heads of pull requests merged as it (squash). The pre-gate is skipped only when all of these hold; anything else runs the full pre-gate:
|
|
1179
|
+
|
|
1180
|
+
- the evidence check run was posted by `evidence_app` and names the commit it is on;
|
|
1181
|
+
- the tree to deploy equals the attested tree;
|
|
1182
|
+
- every currently required check is in the attestation as `success`, and still is `success` on the attested commit when read again now;
|
|
1183
|
+
- every digest to deploy equals the attested digest of that service (`--digests`, else the policy's `deploy.expected_digests_command`);
|
|
1184
|
+
- the config hash (required checks and service build inputs) equals the attested one;
|
|
1185
|
+
- the block has no finding (an unknown key, a missing image, no required checks).
|
|
1186
|
+
|
|
1187
|
+
It prints the decision (`--json`: `{"schema":"forgedock.release.promote/v1","mode","would_skip","skip_pre_gate","reasons","skips","gates"}`), appends `skip_pre_gate=` and `would_skip=` to `$GITHUB_OUTPUT`, and records the decision as a `forge/promote-decision` check run on the commit. In enforce mode a decision that cannot be recorded does not skip. `--check` prints the same explanation and writes nothing.
|
|
1188
|
+
|
|
1189
|
+
When `.forge/gates.yaml` exists, each gate with an `evidence_check` is listed as skipped or kept. A gate on the safety allowlist (`gates.safety` and the unskippable classes) is always kept.
|
|
1190
|
+
|
|
1191
|
+
**Shadow.** With `shadow: true`, `skip_pre_gate` is always `false`. After the pre-gate, `forgedock release promote --observed pass|fail --sha <sha> [--minutes N]` records its outcome next to the decision. `forgedock release promote --report [--last 30]` counts, over the last commits of the default branch: decisions, would-skips, observed outcomes, agreements, **disagreements** (promote would have skipped a pre-gate that failed) and the pre-gate minutes it would have saved; it exits 1 on any disagreement. Exit criterion for the owner's decision to set `shadow: false`: at least 10 observed would-skip decisions and 0 disagreements.
|
|
1192
|
+
|
|
1193
|
+
**Image plan.** `forgedock release promote --images --base <ref> [--sha <sha>] [--json]` plans without running docker. A service is reused (previous digest, no build) only when the changed paths are known, a well-formed previous digest exists (`--previous`, else the attestation of the base commit), no `rebuild_all` path changed and no changed path matches its context, `paths` or Dockerfile. Each service to build gets `docker buildx build` arguments with `--cache-from type=registry,ref=…` and `--cache-to type=registry,ref=…,mode=…`, `--metadata-file .forge/build/<service>.json` (its `containerimage.digest` is the digest to attest) and `--push`. The plan lists each `cache_paths` mount with the id the Dockerfile gives it and warns when the Dockerfile declares no such mount. BuildKit keeps cache mounts in the builder and does not export them with `--cache-to`: use a persistent builder (`builder`) or restore them in the workflow.
|
|
1194
|
+
|
|
1195
|
+
```yaml
|
|
1196
|
+
# CI on the release commit, after tests and image builds:
|
|
1197
|
+
- run: forgedock release promote --attest --sha "$GITHUB_SHA" --digests digests.json
|
|
1198
|
+
# Deploy workflow:
|
|
1199
|
+
- id: promote
|
|
1200
|
+
run: forgedock release promote --gate --sha "$GITHUB_SHA" --digests digests.json
|
|
1201
|
+
- if: steps.promote.outputs.skip_pre_gate != 'true'
|
|
1202
|
+
run: ./scripts/pre-gate.sh # today's full pre-gate, unchanged
|
|
1203
|
+
- if: always() && steps.promote.outputs.skip_pre_gate != 'true'
|
|
1204
|
+
run: forgedock release promote --observed "${{ job.status == 'success' && 'pass' || 'fail' }}" --sha "$GITHUB_SHA"
|
|
1205
|
+
```
|
|
1206
|
+
|
|
1207
|
+
**Commands that use this section**: `forgedock release promote`
|
|
1208
|
+
|
|
1209
|
+
---
|
|
1210
|
+
|
|
1090
1211
|
## `issue_watch` (OPTIONAL)
|
|
1091
1212
|
|
|
1092
1213
|
Named, scoped, capped watches for `forgedock issue-watch` (see [ISSUE-WATCH.md](ISSUE-WATCH.md)). Write `issue_watch:`, then `watches:`, then one block per watch name. The release keys need `mode: release` and at least a `threshold` or `immediate`.
|
|
@@ -1169,6 +1290,73 @@ A diff that adds a key to one of these files with a default of `false`, `0`, `of
|
|
|
1169
1290
|
|
|
1170
1291
|
A post-deploy check whose output has a line `BLOCKED: <flag> = off ...` is not a failure: it posts one `FORGE:ROLLOUT_ASK` owner ask per flag on the rollup and parks `awaiting-measurement`; the ask is posted again only when the output (the evidence) changes. `dormancyReport` (`bin/lean/activation.mjs`) lists introduced flags still `off` after `dormant_days`, with days dormant and the parent issue, through an injected read-only `flagState(flag)` hook; a `keep-off` decision for a flag (or `PREFIX*`) silences it.
|
|
1171
1292
|
|
|
1293
|
+
## `deploy` (OPTIONAL)
|
|
1294
|
+
|
|
1295
|
+
`deploy.engine` (#5712) turns the deploy of a release into a resumable stage machine (`bin/lean/deploy-stages.mjs`). Default off: without `enabled: true` the deploy step is unchanged. Your repo keeps its own tooling (ssh, compose, k8s): a stage is a host command (`run`) or a dispatched workflow (`workflow`).
|
|
1296
|
+
|
|
1297
|
+
```yaml
|
|
1298
|
+
deploy:
|
|
1299
|
+
engine:
|
|
1300
|
+
enabled: true
|
|
1301
|
+
live_release_command: "ops/live-release" # prints the live sha, or JSON {sha, images}; used when .forge/release.yaml has no deploy.live_release_command
|
|
1302
|
+
stage_timeout_s: 1800 # default per stage (3600); a stage may set timeout_s
|
|
1303
|
+
colour:
|
|
1304
|
+
active_command: "ops/active-colour" # prints the colour serving traffic
|
|
1305
|
+
names: [blue, green] # default
|
|
1306
|
+
services:
|
|
1307
|
+
mode: shadow # off | shadow | enforce (shadow when desired_command is set)
|
|
1308
|
+
desired_command: "ops/digests --sha $FORGE_SHA" # JSON {service: {digest, config}}
|
|
1309
|
+
live_command: "ops/digests --live" # same shape, what is running
|
|
1310
|
+
canary:
|
|
1311
|
+
health_command: "ops/health" # run after each step
|
|
1312
|
+
medium: {steps: [10, 100], wait_s: 120} # defaults: low [100]; medium [10, 100] 120 s; high [10, 50, 100] 300 s
|
|
1313
|
+
rollback:
|
|
1314
|
+
budget_s: 60 # timeout of the two commands below
|
|
1315
|
+
shift_back_command: "ops/shift 0" # traffic back to the old colour
|
|
1316
|
+
abort_command: "ops/down $FORGE_COLOUR" # optional: stop the idle colour after a pre-traffic failure
|
|
1317
|
+
stages:
|
|
1318
|
+
- {id: build, kind: build, run: "ops/build", inputs: ["services/**"], services: true}
|
|
1319
|
+
- {id: expand, kind: migrate, run: "ops/migrate expand", inputs: ["db/expand/**"]}
|
|
1320
|
+
- {id: deploy-new, kind: deploy, run: "ops/up $FORGE_COLOUR", inputs: ["ops/**"], services: true, check: "ops/is-up $FORGE_COLOUR"}
|
|
1321
|
+
- {id: smoke-new, kind: smoke, run: "tests/smoke/run $FORGE_COLOUR", inputs: ["tests/smoke/**"]}
|
|
1322
|
+
- {id: shift, kind: shift, run: "ops/shift $FORGE_TRAFFIC_PCT", inputs: ["ops/router/**"]}
|
|
1323
|
+
- {id: verify, kind: verify}
|
|
1324
|
+
- {id: retire-old, kind: retire, run: "ops/down $FORGE_OLD_COLOUR", inputs: ["ops/**"]}
|
|
1325
|
+
- {id: contract, kind: contract, run: "ops/migrate contract", inputs: ["db/contract/**"]}
|
|
1326
|
+
```
|
|
1327
|
+
|
|
1328
|
+
| Stage key | Meaning |
|
|
1329
|
+
|-----------|---------|
|
|
1330
|
+
| `id` | Unique name. |
|
|
1331
|
+
| `kind` | `build`, `migrate`, `deploy`, `smoke`, `shift`, `verify`, `retire`, `contract` or `run` (default). Each kind has an idempotency contract (the engine may run a stage twice): see `devdocs/decisions/5712-deploy-stage-engine.md`. |
|
|
1332
|
+
| `run` / `workflow` | Exactly one (a `verify` stage may have neither). A workflow receives the inputs `stage`, `sha`, `release`, `colour`, `old_colour`, `services`, `traffic_pct`, `forge_epoch`. |
|
|
1333
|
+
| `inputs` | Path globs. A change to a matching file at the deploy sha re-runs the stage. Default `**` (any commit). |
|
|
1334
|
+
| `needs` | Earlier stages this stage depends on. Default: all earlier stages. It re-runs when a needed stage's outputs change, or, for a needed stage without outputs, when that stage's inputs change. |
|
|
1335
|
+
| `services` | `true`: the stage works per service; its key includes the service digests, and in `enforce` mode it is skipped when no service changed. |
|
|
1336
|
+
| `check` | Read-only probe that the stage's effect still holds. A done stage is skipped only when it passes; a failure re-runs this stage and all later ones. |
|
|
1337
|
+
| `outputs_command` | Prints a JSON object recorded as the stage's outputs. Without it, a `run` stage's last stdout line is used when it is a JSON object. |
|
|
1338
|
+
| `timeout_s` | Stage timeout. |
|
|
1339
|
+
|
|
1340
|
+
Commands get `FORGE_SHA`, `FORGE_TARGET_SHA` (what was live before), `FORGE_RELEASE`, `FORGE_STAGE`, `FORGE_COLOUR` (new), `FORGE_OLD_COLOUR`, `FORGE_RISK`, `FORGE_SERVICES` (comma list to act on; empty means the engine has no service list), `FORGE_SERVICES_SKIPPED` and, for `shift`, `FORGE_TRAFFIC_PCT`.
|
|
1341
|
+
|
|
1342
|
+
Rules the engine enforces:
|
|
1343
|
+
|
|
1344
|
+
- **Resume.** Each stage has a checkpoint (inputs hash, outputs, status) in the release state and, for a managed release, on the ledger. A stage is skipped when its checkpoint is done and its inputs are unchanged; so a resume starts at the first failed or incomplete stage, and a fix commit re-runs only the stages whose `inputs` it touches (or whose needed outputs changed).
|
|
1345
|
+
- **Smoke before traffic.** A `smoke` stage must come before the first `shift`. A failure before the shift moves no traffic: the old colour keeps serving, and there is no hold, freeze or rollback trigger.
|
|
1346
|
+
- **Rollback.** A failure from the shift up to `retire` runs `rollback.shift_back_command` within `rollback.budget_s`. If that fails, the rollback ladder is triggered as before. After `retire` the engine holds for a roll-forward.
|
|
1347
|
+
- **Changed services only.** A service is unchanged only when its image digest and config hash both match what is running. `shadow` deploys everything and records what would have been skipped and whether that agreed; `enforce` skips.
|
|
1348
|
+
- **Canary by risk class.** The risk class comes from the release risk rules (`risk.rules` of `.forge/release.yaml`, else the defaults) over the files changed since the live sha.
|
|
1349
|
+
- **Verification.** A `verify` stage is required. It checks the live record against the deployed sha, runs its own command if it has one, then the `verify` layers of `.forge/release.yaml`.
|
|
1350
|
+
|
|
1351
|
+
```bash
|
|
1352
|
+
forgedock release deploy --plan <release id> # which stages would run, and why
|
|
1353
|
+
forgedock release deploy --plan --sha <sha> --json # plan for a commit, as JSON
|
|
1354
|
+
forgedock release deploy --resume <release id> # continue from the first failed or incomplete stage
|
|
1355
|
+
forgedock release deploy --resume <release id> --sha <sha> # same, deploying a later default-branch commit that contains the release merge (a fix)
|
|
1356
|
+
```
|
|
1357
|
+
|
|
1358
|
+
To turn it off, set `enabled: false` or remove the block. A release already started by the engine must be finished (or rolled back) with the engine on.
|
|
1359
|
+
|
|
1172
1360
|
## `post_deploy` (OPTIONAL)
|
|
1173
1361
|
|
|
1174
1362
|
Deferred follow-ups whose items are all post-deploy checks are parked (`awaiting-promotion`, no lane) until the parent's fix is on `branches.default`. Keys: `precondition_cmd` (exit 0 ready, 1 parked) and `min_age` (soak window, e.g. `24h`).
|
|
@@ -1309,6 +1497,25 @@ stats:
|
|
|
1309
1497
|
| `alerts.toolchain_warning_pct` | number | No | Alert when one `TOOLCHAIN_WARNING` text is repeated on more than this percentage of lanes. Default 50. |
|
|
1310
1498
|
| `alerts.outcome_share_factor` | number | No | Alert when an outcome code other than `completed` has at least this factor of its share in the previous window. The code must be on at least 2 lanes, and the previous window must have at least `min_lanes` lanes. A code new in this window counts. Default 2. |
|
|
1311
1499
|
|
|
1500
|
+
Release ledger keys (#5718, `forgedock stats --release-ledger`, all optional; see [STATS.md](STATS.md)):
|
|
1501
|
+
|
|
1502
|
+
```yaml
|
|
1503
|
+
stats:
|
|
1504
|
+
ledger_release_base: main # default: the repo's default branch
|
|
1505
|
+
ledger_release_head: staging # default: branches.staging, else any head
|
|
1506
|
+
ledger_ci_workflows: [CI, images.yml] # names or file names; default: every workflow
|
|
1507
|
+
ledger_deploy_workflow: deploy.yml # name or file; default: detected
|
|
1508
|
+
ledger_deploy_job: "^deploy" # regex on the job name; default: detected
|
|
1509
|
+
```
|
|
1510
|
+
|
|
1511
|
+
| Field | Type | Required | Description |
|
|
1512
|
+
|-------|------|----------|-------------|
|
|
1513
|
+
| `ledger_release_base` | string | No | Branch a release PR targets. Default: the repository's default branch. |
|
|
1514
|
+
| `ledger_release_head` | string | No | Head branch of a release PR. Default: `branches.staging` when set, else every PR into the base counts. |
|
|
1515
|
+
| `ledger_ci_workflows` | list | No | Workflows (name or file name) counted as release-PR CI. Default: all. |
|
|
1516
|
+
| `ledger_deploy_workflow` | string | No | The deploy workflow (name or file). Default: the push/dispatch workflow on the base whose name says deploy, publish or release with the most runs; the report names what it picked. |
|
|
1517
|
+
| `ledger_deploy_job` | string | No | Regex for the job that rolls out. Default: the longest job whose name says deploy, else the longest job. |
|
|
1518
|
+
|
|
1312
1519
|
Each alert line names the event, the rate, the sample size (`count/sample` lanes) and one example reason. When no alert fires, nothing is printed. The flat form `stats.alerts_<key>` also works and wins. `forgedock stats --no-local` skips the alerts.
|
|
1313
1520
|
|
|
1314
1521
|
### Phase ledger (#4908)
|
|
@@ -1337,6 +1544,8 @@ verify:
|
|
|
1337
1544
|
flaky: "memory-erasure,e2e-pdf" # optional; known-flaky CI job names: reported, never block or feed the builder
|
|
1338
1545
|
post_merge: pnpm -r typecheck # optional; run on the merged tree at base-sync before the push (default: the lane's scoped typecheck)
|
|
1339
1546
|
duplicate_exports: false # optional; turn off the same-app duplicate-export check (default true)
|
|
1547
|
+
settle: condition # optional; fixed (default) | shadow | condition: wait for unreported gate checks
|
|
1548
|
+
cancel_superseded: own # optional; off (default) | own | all: cancel runs of the head a push replaced
|
|
1340
1549
|
|
|
1341
1550
|
lean:
|
|
1342
1551
|
enumerating:
|
|
@@ -1371,6 +1580,8 @@ lean:
|
|
|
1371
1580
|
| `guard_command` | map | No | Guard gate (#4693) test-file command per extension (#4792), e.g. `".py": "scripts/pytest {path}"` for a repo whose tests need a managed environment. Consulted before the contract's validate commands and the hard-coded `node --test` / `python -m pytest -q` fallbacks. `{path}` is replaced by the repo-relative path of the guard's base copy (`<name>__guardbase.<ext>`); a template without `{path}` gets it appended. Runs from the worktree root. Keys may be written with or without the leading dot. Absent: unchanged. |
|
|
1372
1581
|
| `sandboxes` | map | No | Test sandboxes (#5450): throwaway services a lane's validate commands need. One entry per name, written on one line: `postgres: { image: postgres:16, init: "make migrate DB_URL=$SANDBOX_URL", ttl: 30m }`, `redis: { image: redis:7 }`, `api: { compose: docker-compose.test.yml, service: api, needs: [postgres, redis] }`, `http-replay: { fixtures: tests/fixtures/http/, for: integration }`. Optional `port` and `ready` (a command run in the container until it exits 0) override the postgres/redis defaults. A frozen contract validate entry declares `env: ["postgres"]`; only then is a sandbox created, once per lane, with unique container names (`forge-sbx-<lane>-<name>`), ephemeral loopback ports and `forgedock.*` labels, registered in the lane ledger so teardown and `forgedock gc` reclaim it. Validate commands get `SANDBOX_<NAME>_URL` (a `fixtures` entry: `SANDBOX_<NAME>_DIR`, an absolute path); `init` runs on the host with `SANDBOX_URL`. A name with no entry, or a host without Docker, ends the lane `needs-human` (never a skip; no-Docker uses `env.tool_missing` so the lane is placed where Docker runs). A `fixtures` entry also exports `SANDBOX_<NAME>_MODE` (`replay`, or `record` with `record: true` or `FORGE_SANDBOX_RECORD=1`); an `http*` entry also exports `SANDBOX_HTTP_REPLAY_DIR`/`_MODE`. Each lane's image sandboxes join their own network `forge-sbx-<lane>-net`. `forgedock init --minimal` writes a commented proposal detected from compose files, migrations and test markers. Images are checked or pulled once per batch process (lanes share the cache). Each sandbox adds a `FORGE:SANDBOX {name, kind, ms, cost_usd}` line to the lane decisions. Operators: `forgedock sandbox up <name>... | down | ls`. Absent: no sandbox is ever created. |
|
|
1373
1582
|
| `check_run` | boolean | No | Default `false` (no Checks API call, behaviour unchanged). `true`: after each push of a reviewed head (PR open, base-sync, merge-time fix round) the engine posts one completed `forgedock/verify` check run on that head (forge#4270), `success` iff every deterministic gate the lane already ran passed: declared check commands, undeclared package edges, docs freshness, contract scope, validate ids, requirement status, hotspot growth, amendments. The output carries each gate's id, pass/fail and evidence as JSON; the run log records a `VERIFY` event. Report only: ForgeDock never makes it required and never waits on it (it is ignored by its own CI waits); requiring it is the repository's branch-protection choice. Creating check runs needs a token that may (a GitHub App with `checks: write`); a Checks API failure is logged as an anomaly and never fails the lane. |
|
|
1583
|
+
| `settle` | string | No | How long CI verification waits for a gating check name that has not reported (forge#5718). `fixed` (default): the whole 5-minute grace period, unchanged. `condition`: until the head's check suites show nothing more can report (every suite completed, the same suites on two consecutive polls, at least 20 s after the push), never longer than the grace period; an unreadable suite list keeps the fixed wait. `shadow`: waits as `fixed` and logs a `CI_SETTLE` run-log event with when the condition held (`known_at_ms`) and whether the gating set was the same (`agreed`). Turn `condition` on after shadow agrees on your repo: a workflow that registers after every suite completed (a chained `workflow_run`) is the one case the condition cannot see. The set of gating checks and their verdicts is the same in every mode. |
|
|
1584
|
+
| `cancel_superseded` | string | No | Default `off`. `own`: after the lane pushes a new head, cancel the queued and running `pull_request` / `pull_request_target` runs of its branch for an older head that this actor triggered (forge#5718). `all`: whoever triggered them. Push and dispatch runs are never cancelled (they may deploy), and a run of the current head never is. Logged as `CI_SUPERSEDED_CANCEL`. A GitHub App token has no user: set `FORGE_BOT_LOGIN` for `own`. The same check by hand: `forgedock ci cancel-superseded (--pr N \| --branch B) [--mode own\|all] [--dry-run]`. Prefer the workflow `concurrency` block ([CI.md](CI.md#superseded-runs)) where you can edit the workflow. |
|
|
1374
1585
|
| `post_merge` | string | No | Command run in the lane worktree on the merged tree after each base-sync merge, before the push (forge#4406). Default: the typecheck rows of the lane's change-scoped checks (`bin/lean/checks.mjs`), in `local` and `hybrid` mode only; `ci` mode runs no host typecheck unless `post_merge` is set. A failure resumes the builder with the output, up to `max_rounds` rounds, and the fixed head is re-reviewed; still failing is a trajectory anomaly and CI stays the gate. |
|
|
1375
1586
|
| `duplicate_exports` | boolean | No | Default `true`: at hand-off and after each base-sync merge, names the lane newly exports that another non-test module of the same app or package (nearest `package.json`/`pyproject.toml`/`setup.py`/`go.mod`/`Cargo.toml`) already declares go back to the builder once ("rename or reuse", both paths); one left over is an anomaly (forge#4406). Re-exports, default exports and names 3+ other modules declare (framework conventions) are ignored. `false` turns the check off. |
|
|
1376
1587
|
| `e2e` | string | No | e2e merge gate (forge#4403). `auto` (default): run e2e when the diff touches `e2e_paths` or a contract requirement quote has `[type:e2e]`. `always`: on every lane except docs-only ones. `never`: today's behaviour. Without `e2e_label` or `e2e_workflow` no e2e can run, so every mode keeps today's behaviour (a lane that changed specs records a decision saying so). |
|
|
@@ -1542,6 +1753,19 @@ env:
|
|
|
1542
1753
|
toolchain: "pnpm@10.4.1" # optional: overrides the detected package manager; "off" disables detection
|
|
1543
1754
|
setup: "bash scripts/reconcile-dev-db.sh" # optional: run once per fresh lane worktree, before the builder
|
|
1544
1755
|
sparse_max_kb: 1024 # optional: tracked files this size or larger stay out of lane worktrees; 0 = full checkout
|
|
1756
|
+
snapshots: # optional: environment library (#5714), off unless enabled
|
|
1757
|
+
enabled: false
|
|
1758
|
+
store: local # local | oci
|
|
1759
|
+
keep: 3
|
|
1760
|
+
max_age_days: 14
|
|
1761
|
+
ready: 2
|
|
1762
|
+
base_image: ghcr.io/acme/ci-base:1 # oci store: the image installs run in
|
|
1763
|
+
image: ghcr.io/acme/shop-env # oci store: repository snapshots are pushed to (tag = key)
|
|
1764
|
+
proxies: # optional: caching proxies lanes use (pool/services); each key independent
|
|
1765
|
+
npm: http://proxy-host:4873
|
|
1766
|
+
pypi: http://proxy-host:3141/index
|
|
1767
|
+
apt: http://proxy-host:3142
|
|
1768
|
+
git: git://proxy-host:9418
|
|
1545
1769
|
```
|
|
1546
1770
|
|
|
1547
1771
|
| Field | Type | Required | Description |
|
|
@@ -1550,7 +1774,16 @@ env:
|
|
|
1550
1774
|
| `setup` | string | No | Shell command (`bash -c`) run once in each fresh lane worktree before the builder starts, with the lane's PATH and `TMPDIR`. Use it for environment drift the repo's migrations don't cover, for example a dev-database reconcile script. Timeout 15 min. A non-zero exit ends the lane `needs-human` with code `env.setup_failed`: an environment error, not a build failure. The builder never runs. |
|
|
1551
1775
|
| `sparse_max_kb` | integer | No | Default `1024`. Lane worktrees are sparse checkouts: tracked files of this many KB or more (generated JSON, screenshots, PDFs, media) are not written to disk, which cuts per-lane disk in repos that track large assets (#4221). Lockfiles, manifests (`package.json`, `pyproject.toml`, `requirements*.txt`, ...), toolchain pins, `tsconfig*.json`, `forge.yaml`, `.gitattributes` and `.gitignore` are always checked out. A repo with no such file gets a plain checkout. The builder prompt names the absent files; `git sparse-checkout add /<path>` brings one back. `0` disables it. Git sets `extensions.worktreeConfig=true` in the repo's shared config; the sparse setting itself is per lane worktree, so the main checkout is unchanged. If the sparse setup fails, the lane uses a full checkout. |
|
|
1552
1776
|
|
|
1553
|
-
|
|
1777
|
+
| `snapshots.enabled` | boolean | No | Default `false`. Environment library (#5714, [ENV-LIBRARY.md](ENV-LIBRARY.md)): dependency trees are installed once per environment key (lockfiles + manifests + toolchain pin files + `execution.lane_tools` + image) outside any job and reused. With a pool provider, each launch asks the pool agent to keep the repo's snapshot built and staged in the cache volume; a lane whose lockfiles match claims a staged copy by directory rename (`Dependencies (...): hit (env snapshot (rename))`), and any other lane installs as before. Absent or `false`: no launch field, no lane env, no helper container. |
|
|
1778
|
+
| `snapshots.store` | `local` \| `oci` | No | Default `local` (directory store: the pool cache volume, or `FORGE_ENV_ROOT`, default `~/.forge/env`). `oci`: `forgedock env build` writes a `Dockerfile.env` for `<image>:<key>`, used as a CI job container and a deploy base layer. |
|
|
1779
|
+
| `snapshots.keep` | integer | No | Default `3`. Snapshots kept per repo, newest by last use. |
|
|
1780
|
+
| `snapshots.max_age_days` | integer | No | Default `14`. Snapshots unused this long are removed; a repo's newest always stays. |
|
|
1781
|
+
| `snapshots.ready` | integer | No | Default `2`. Staged hardlink copies the pool keeps ready per snapshot; one is consumed per claiming lane. `0`: lanes hardlink from the snapshot instead. |
|
|
1782
|
+
| `snapshots.base_image` | string | `oci` only | The image the frozen installs run in (your CI base image with the toolchain installed). Part of the key. |
|
|
1783
|
+
| `snapshots.image` | string | `oci` only | Image repository without a tag; snapshots are `<image>:<key>`. |
|
|
1784
|
+
| `proxies.npm` / `pypi` / `apt` / `git` | URL | No | `http(s)://` or `git://` URLs of the opt-in caching services in `pool/services/docker-compose.yml`. Pool lanes get the matching package-manager variables (`npm_config_registry`, `PIP_INDEX_URL`, `UV_DEFAULT_INDEX`, `FORGE_APT_PROXY`, ...; full table in [ENV-LIBRARY.md](ENV-LIBRARY.md)). Absent keys change nothing. A value that is not such a URL is ignored. |
|
|
1785
|
+
|
|
1786
|
+
**Commands that use this section**: `forgedock run-issue`, `forgedock orchestrate` (core path; `bin/engine-cli.mjs` `readEnvConfig`); `forgedock env key|build|status|gc|stage` and pool launches read `snapshots` and `proxies` (`bin/env/env.mjs` `readEnvSnapshots`)
|
|
1554
1787
|
|
|
1555
1788
|
---
|
|
1556
1789
|
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
# Environment library
|
|
2
|
+
|
|
3
|
+
Install a repo's dependencies once per lockfile change and reuse the result in lane sandboxes, CI jobs and deploy image
|
|
4
|
+
builds. Off by default; turned on per repo in `forge.yaml`.
|
|
5
|
+
|
|
6
|
+
A snapshot is the set of trees a frozen install leaves (`node_modules` directories, `.venv`) for one **environment
|
|
7
|
+
key**: a hash of the lockfiles and manifests, the toolchain pin files, `execution.lane_tools`, and the base image. The
|
|
8
|
+
key needs no tools to compute:
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
forgedock env key # 16 hex characters
|
|
12
|
+
forgedock env key --json # plus ecosystems, pins, lane tools, image
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Supported ecosystems are the ones the dependency cache detects: npm, pnpm, yarn (node-modules linker), uv and poetry,
|
|
16
|
+
at the repo root or one level down (`web/`, `services/<name>/`, `packages/<name>/`, `apps/<name>/`).
|
|
17
|
+
|
|
18
|
+
## How to turn it on
|
|
19
|
+
|
|
20
|
+
```yaml
|
|
21
|
+
env:
|
|
22
|
+
snapshots:
|
|
23
|
+
enabled: true # default false
|
|
24
|
+
store: local # local (pool cache volume) | oci (container image by key)
|
|
25
|
+
keep: 3 # snapshots kept per repo
|
|
26
|
+
max_age_days: 14 # unused snapshots older than this are removed (a repo's newest always stays)
|
|
27
|
+
ready: 2 # staged copies kept ready for lanes
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Remove the block (or set `enabled: false`) to turn it off. Nothing else changes with it off.
|
|
31
|
+
|
|
32
|
+
## Lane sandboxes (pool)
|
|
33
|
+
|
|
34
|
+
With `enabled: true` and a pool provider, each launch tells the pool agent to keep the repo's snapshot current. The
|
|
35
|
+
agent runs a short helper container beside the lanes (never inside one) that reads the repo's git mirror in the cache
|
|
36
|
+
volume, builds the snapshot for the base ref's lockfiles if it is missing, and stages `ready` copies. A lane whose
|
|
37
|
+
lockfiles match claims a staged copy with a directory rename; its run log shows
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
Dependencies (pnpm <key>): hit (env snapshot (rename)) in 0.0s
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
`(link)` means no staged copy was ready (one hardlink per file); `(copy)` means the store and the worktree are on
|
|
44
|
+
different filesystems, which the pool's own mounts never produce. A lane that changes a lockfile gets no snapshot and
|
|
45
|
+
installs as before. If the helper cannot build (for example a registry that needs a credential the helper does not
|
|
46
|
+
have), there is no snapshot and lanes install as before.
|
|
47
|
+
|
|
48
|
+
Agent settings (optional, agent config): `env_build_cpus` (2), `env_build_mem_gb` (4).
|
|
49
|
+
|
|
50
|
+
Pool lanes always use the store in their cache volume. `store` only selects what `forgedock env build` writes, so a repo
|
|
51
|
+
can set `store: oci` for CI and still get snapshots in its lanes. Run `forgedock env key` in a git checkout: the tracked
|
|
52
|
+
`package.json` files are part of the key.
|
|
53
|
+
|
|
54
|
+
## CI jobs
|
|
55
|
+
|
|
56
|
+
Use the `oci` store so jobs can pull the snapshot as their container image:
|
|
57
|
+
|
|
58
|
+
```yaml
|
|
59
|
+
env:
|
|
60
|
+
snapshots:
|
|
61
|
+
enabled: true
|
|
62
|
+
store: oci
|
|
63
|
+
base_image: ghcr.io/<owner>/<ci-base>:<tag> # the image your jobs run in today (toolchain installed)
|
|
64
|
+
image: ghcr.io/<owner>/<repo>-env # where snapshots are pushed; the key is the tag
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Build and push on a build host when the key changes on the base branch, never inside a test job:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
forgedock env build --out .forge/env/out # writes Dockerfile.env, manifest.json, build.sh; runs no installer, no docker
|
|
71
|
+
bash .forge/env/out/build.sh # docker build + push, from the repo root
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
In the workflow, one small job computes the key and the image; test jobs run in it. Copy
|
|
75
|
+
`templates/github-actions/forge-env/` to `.github/actions/forge-env/`.
|
|
76
|
+
|
|
77
|
+
```yaml
|
|
78
|
+
jobs:
|
|
79
|
+
env:
|
|
80
|
+
runs-on: ubuntu-latest
|
|
81
|
+
outputs:
|
|
82
|
+
key: ${{ steps.k.outputs.key }}
|
|
83
|
+
image: ${{ steps.k.outputs.image }}
|
|
84
|
+
steps:
|
|
85
|
+
- uses: actions/checkout@v4
|
|
86
|
+
- id: k
|
|
87
|
+
run: |
|
|
88
|
+
key=$(npx --yes forgedock env key --store oci)
|
|
89
|
+
ref="ghcr.io/<owner>/<repo>-env:$key"
|
|
90
|
+
if docker manifest inspect "$ref" >/dev/null 2>&1; then image="$ref"; else image="ghcr.io/<owner>/<ci-base>:<tag>"; fi
|
|
91
|
+
{ echo "key=$key"; echo "image=$image"; } >> "$GITHUB_OUTPUT"
|
|
92
|
+
test:
|
|
93
|
+
needs: env
|
|
94
|
+
runs-on: ubuntu-latest
|
|
95
|
+
container: ${{ needs.env.outputs.image }}
|
|
96
|
+
steps:
|
|
97
|
+
- uses: actions/checkout@v4
|
|
98
|
+
- id: deps
|
|
99
|
+
uses: ./.github/actions/forge-env
|
|
100
|
+
with: { key: "${{ needs.env.outputs.key }}" }
|
|
101
|
+
- if: steps.deps.outputs.hit != 'true'
|
|
102
|
+
run: npm ci # your normal install, unchanged
|
|
103
|
+
- run: npm test
|
|
104
|
+
working-directory: ${{ steps.deps.outputs.workdir }}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
A key with no image (a PR that changes a lockfile) runs in the base image with the normal install, so the same checks
|
|
108
|
+
run either way. `mode: prefix` (default) copies the checkout over `/work/env` and reports it as `workdir`; `mode: link`
|
|
109
|
+
symlinks the trees into the workspace and suits single-package repos without workspace links.
|
|
110
|
+
|
|
111
|
+
Python projects: the image installs dependencies only (`uv sync --frozen --no-install-project`,
|
|
112
|
+
`poetry install --sync --no-root`). If your tests import the project as an installed package, add that install as a
|
|
113
|
+
step.
|
|
114
|
+
|
|
115
|
+
## Deploy image builds
|
|
116
|
+
|
|
117
|
+
```dockerfile
|
|
118
|
+
ARG ENV_IMAGE # <env.snapshots.image>:<key>
|
|
119
|
+
FROM ${ENV_IMAGE} AS env
|
|
120
|
+
FROM node:22-slim
|
|
121
|
+
WORKDIR /app
|
|
122
|
+
COPY --from=env /work/env/node_modules ./node_modules
|
|
123
|
+
COPY . .
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Pass `--build-arg ENV_IMAGE=<image>:$(forgedock env key --store oci)`. The dependency layer is then identical across
|
|
127
|
+
builds until a lockfile changes.
|
|
128
|
+
|
|
129
|
+
## Package proxies and git mirror (optional)
|
|
130
|
+
|
|
131
|
+
`pool/services/docker-compose.yml` runs caching proxies for npm (verdaccio), PyPI (proxpi) and apt (apt-cacher-ng) and a
|
|
132
|
+
read-only git mirror. They have no authentication and bind to loopback by default; set `FORGE_PROXY_BIND` to a private
|
|
133
|
+
address reachable from pool hosts and runners. They serve public packages and public repos only.
|
|
134
|
+
|
|
135
|
+
```yaml
|
|
136
|
+
env:
|
|
137
|
+
proxies:
|
|
138
|
+
npm: http://<host>:4873
|
|
139
|
+
pypi: http://<host>:3141/index
|
|
140
|
+
apt: http://<host>:3142
|
|
141
|
+
git: git://<host>:9418
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Each key is independent; absent keys change nothing. Lanes then get:
|
|
145
|
+
|
|
146
|
+
| Key | Lane environment |
|
|
147
|
+
|---|---|
|
|
148
|
+
| `npm` | `npm_config_registry`, `YARN_NPM_REGISTRY_SERVER` (and `YARN_UNSAFE_HTTP_WHITELIST` for an http URL) |
|
|
149
|
+
| `pypi` | `PIP_INDEX_URL`, `UV_DEFAULT_INDEX`, `UV_INDEX_URL` (and `PIP_TRUSTED_HOST`, `UV_INSECURE_HOST` for an http URL) |
|
|
150
|
+
| `apt` | `FORGE_APT_PROXY`; the lane image writes `/etc/apt/apt.conf.d/01forge-proxy` |
|
|
151
|
+
| `git` | `FORGE_GIT_MIRROR`; not applied automatically (lanes already keep a bare mirror in their cache volume) |
|
|
152
|
+
|
|
153
|
+
CI runners set the same variables in the job `env:`. For checkouts, a runner can borrow objects from the mirror:
|
|
154
|
+
`git clone --reference-if-able` against a local clone of `git://<host>:9418/<owner>/<name>.git`. poetry reads its
|
|
155
|
+
sources from `pyproject.toml` and is not redirected by these variables.
|
|
156
|
+
|
|
157
|
+
## Commands
|
|
158
|
+
|
|
159
|
+
| Command | What it does |
|
|
160
|
+
|---|---|
|
|
161
|
+
| `forgedock env key [--json] [--store oci] [--lane-tools a,b] [--image ref]` | Print the checkout's key. Exit 1 when no supported lockfile is found. |
|
|
162
|
+
| `forgedock env build [--store local\|oci] [--out dir]` | Write the recipe and manifest for the key. Runs no installer and no docker. |
|
|
163
|
+
| `forgedock env build --apply` | Local store only: run the frozen installs in the checkout and publish. For a build container, not a job. |
|
|
164
|
+
| `forgedock env stage [--key k] [--count n]` | Stage ready copies of a snapshot (pool host). |
|
|
165
|
+
| `forgedock env status [--json]` | List snapshots in the local store (`FORGE_ENV_ROOT`, default `~/.forge/env`). |
|
|
166
|
+
| `forgedock env gc [--apply] [--keep n] [--max-age-days d]` | Plan, or with `--apply` perform, removal by count and age. |
|
|
167
|
+
|
|
168
|
+
## Measuring
|
|
169
|
+
|
|
170
|
+
- Lanes: `LANE_SETUP_TIMING` step `deps` and `DEPS_PREPARED` (`reason: "env snapshot (rename)"`) in the run logs (`~/.forge/runs/<owner>__<repo>__<issue>.jsonl`).
|
|
171
|
+
- This machine's filesystem: `node bin/env/bench.mjs --files 19677`.
|
|
172
|
+
- CI: the install step's duration on a hit (skipped) against a miss.
|
package/docs/STATS.md
CHANGED
|
@@ -260,6 +260,49 @@ telemetry comment in the window get their full comment list re-read (6 in parall
|
|
|
260
260
|
low). A run with no `--since` and no cache still walks the whole history once. Telemetry comments are edited in place, which
|
|
261
261
|
the comment window catches; if a cached item still looks stale, run with `--refresh`.
|
|
262
262
|
|
|
263
|
+
## Release ledger (`--release-ledger`, forge#5718)
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
npx forgedock stats --release-ledger [--repo <owner/repo>] [--since <date|21d>] [--json]
|
|
267
|
+
npx forgedock stats --release-ledger --baseline save # freeze today's numbers
|
|
268
|
+
npx forgedock stats --release-ledger --baseline compare # before/after, measured the same way
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
One table of what a release costs today against the targets, read from the GitHub Actions runs, jobs and steps API plus
|
|
272
|
+
release state. Nothing is estimated: a metric without a sample prints `n/a`. The window defaults to the last 21 days.
|
|
273
|
+
|
|
274
|
+
| Row | How it is measured |
|
|
275
|
+
|-----|--------------------|
|
|
276
|
+
| Mechanical failure surfaced | Failed CI runs whose first failed step is a checkout, toolchain, dependency or lint step: run start to run end (when the failure is visible today), p50 |
|
|
277
|
+
| Job setup (self-hosted, hosted) | Per job, seconds in checkout, toolchain and dependency-install steps (classified by step name, any ecosystem); the p50 of each class, summed |
|
|
278
|
+
| CI wall time per round | A round is every CI run of one head sha of a release PR: first run created to last run finished (first attempt), p50; cancelled rounds are left out |
|
|
279
|
+
| Pushes per release PR | Distinct head shas with CI runs per release PR, p50 (and max) |
|
|
280
|
+
| Deploy pre-gate | Live deploys: run start to the start of the deploy job, p50 |
|
|
281
|
+
| Image build | Per job, minutes in image-build steps, p50 |
|
|
282
|
+
| Deploy job (rollout) | Live deploys: the deploy job's minutes, p50; the report lists its ten longest steps |
|
|
283
|
+
| Release PR opened -> live | PR creation to the end of the first deploy that reached live for its merge commit: median and p90; `clean` = live on the first deploy attempt |
|
|
284
|
+
| Queue time | Job created to job started, p90 |
|
|
285
|
+
| CI minutes in failed / cancelled jobs | Share of job time by job conclusion |
|
|
286
|
+
| CI rounds that fail | Share of judged rounds with a failed run |
|
|
287
|
+
| Deploy attempts that reached live | Deploy runs in which a job ran, and the share whose deploy job succeeded |
|
|
288
|
+
|
|
289
|
+
The report also prints the critical-path jobs (the job that ends last in a round, with its p50 and failure rate).
|
|
290
|
+
|
|
291
|
+
What counts as a release PR, CI run and deploy is generic and can be pinned in forge.yaml (`stats.ledger_*`, see
|
|
292
|
+
[CONFIG.md](CONFIG.md#stats-optional)): a release PR is a PR into the default branch (from `branches.staging` when set); its
|
|
293
|
+
CI runs are the pull-request runs that name it (push runs of the head branch when the repo has none); the deploy workflow is
|
|
294
|
+
the push/dispatch workflow on the default branch whose name says deploy, publish or release with the most runs.
|
|
295
|
+
`--deploy-workflow <name|file>` and `--release-head <branch|any>` override per call. With `release.managed: true` the
|
|
296
|
+
managed ledger's deploy attempt counts are merged in.
|
|
297
|
+
|
|
298
|
+
Cost: one runs query per branch and event (the runs API takes seconds per page), then one jobs call per run, 4 at a time.
|
|
299
|
+
Jobs of completed runs are cached in `~/.forge/stats-cache/<owner>_<repo>/actions-jobs.json`, so a weekly re-read only
|
|
300
|
+
fetches new runs (`--no-cache` skips it). Every read is paginated and retried on transient GitHub errors.
|
|
301
|
+
|
|
302
|
+
`--baseline save` writes the metrics to `release-ledger-baseline.json` next to that cache (`--baseline-file <path>` for a
|
|
303
|
+
file you commit). `--baseline compare` prints each metric before and after with a verdict `improved|regressed|flat|n/a`
|
|
304
|
+
(flat is within 5%, or 2 points for a share) and exits 2 when there is no baseline.
|
|
305
|
+
|
|
263
306
|
## Per-release regression rule (`--by version`, forge#4628)
|
|
264
307
|
|
|
265
308
|
```bash
|