Compare commits

..
Author SHA1 Message Date
skylartaylor 16610b20b1 nightly: fix the launcher, Windows build and profile-probe review findings
- Both Linux launchers dispatch the Launcher's protocol and a bare version query before the
  XDG_DATA_HOME/HOME guard, so neither is refused for a HOME it never reads.
- `nightly.ps1` builds into the `-TargetDir` its archive steps read.
- The writable probe retries on a leftover file with its name and removes only the file it created.
- The planted-record-link test writes at RECORD rather than a sibling name, so it exercises the
  alias it plants.
2026-11-25 01:05:43 +01:00
skylartaylor f0c68d6d2c nightly: read the built commit only from a lower-case version
gate / gate (ubuntu-24.04) failed channel::tests::the_commit_is_read_back_only_from_a_nightly_version:
`commit_for` used `is_ascii_hexdigit`, which also accepts A-F, so `...gABCDEF012345` read back
as a commit although the producer's version pattern is lower-case. The check now takes digits
and a-f only, as the nightly version pattern already requires.
2026-11-25 00:59:42 +01:00
skylartaylor 45d59d1487 nightly: enforce the signing guard and read the whole push mapping
- `nightly_compile_gui` calls `nightly_refuse_signing_env` before cargo, so an exported signing
  key cannot reach the compiler or any dependency build script. The helper existed but no path
  called it.
- The candidate-workflow check reads the whole `push:` mapping by indentation instead of a
  contiguous run of non-empty lines, so a `paths:`/`paths-ignore:` filter after a blank line is
  still rejected; a negative fixture covers that layout.
2026-11-25 00:57:24 +01:00
skylartaylor 2dfba46227 nightly: make the app_dirs tests independent of the host's separator
gate / gate (ubuntu-24.04) and SonarCloud's coverage shard 2 both failed on
`each_platform_keeps_its_published_folder`: it compared a `join`ed path against a literal with
Windows backslashes, so on Linux the function's `C:\\.../GridCraft` never matched. Both
tests now build their expectation with the same `PathBuf::join` on the same base, and the
`cfg!(windows)` home switch is gone, so they hold on either host.
2026-11-25 00:49:14 +01:00
skylartaylor bfc5a35ed7 nightly: pass set_token_root itself to and_then (clippy redundant_closure) 2026-11-25 00:29:55 +01:00
skylartaylor 04198c771d nightly: if-then-else for the imported signing identity (SC2015)
shellcheck reads `A && B || C` as a possible false branch. The identity and keychain
checks are now an explicit `if`, with the same behaviour and message.
2026-11-25 00:29:55 +01:00
skylartaylor c1e55f8d27 Nightly: keep Dylan's callers, fix rustfmt, ship the kit's tar layout
- Put his nightly.yml, nightly-sign.yml and installed signing policy back byte
  for byte (no `false &&`, his five manual actors, his 605d5876 pin), and drop
  our dormant duplicates: nightly-dispatch.yml, the policy template and the
  actionlint waiver that only hid the `queue:` key he removed.
- Adapt nightly-release-tests.py to the enabled pair: no schedule, his exact
  context guards, the release managers in caller and policy, one pin, the
  installed policy's fields and platforms, plus this branch's guards for the
  committed Linux key and the Sonar fixture scope.
- cargo fmt --all (17 hunks in 7 files); clean under rustfmt 1.10 and 1.100.
- Flat nightly tar uses the kit layout: `gridcraft` is the launcher and
  `gridcraft-bin` the GUI it starts, and the launcher never starts itself.
- docs: his go-live doc, one stale sentence corrected, plus a flavor section.
- Drop the unused GRIDCRAFT_CONFIG_DIR stable knob; an empty XDG_CONFIG_HOME
  now falls back to ~/.config.
2026-11-25 00:08:19 +01:00
skylartaylor f59fdf3e84 Linux nightlies: start every format through the flavor's launch profile
Dylan's ports keep the nightly identities but start the GUI directly, and a nightly build
refuses to start without --launch-profile nightly-v1 --profile-root <dir>. Ship the launcher
every Linux nightly format needs, so an installed, extracted or sandboxed nightly never runs
against the stable profile (his remaining re-review items close with it).

- deb/rpm: usr/bin/gridcraft-nightly is a launcher; the GUI moves to
  usr/lib/gridcraft-nightly/gridcraft, which nfpm.yaml carries with mode 0755. A stable stage
  has no such file, so the three-line entry is dropped and the rendered stable nfpm.yaml stays
  byte-identical to his head.
- AppImage: AppRun is a script, not the usr/bin/gridcraft symlink, and usr/bin/gridcraft-nightly
  is installed beside it; the desktop Exec/TryExec name the launcher.
- Arch handoff: nightly-arch-launch.sh passes the profile tokens instead of relocating the four
  XDG folders (the profile holds settings, logs, the control token and the session record).
- Flatpak: bin/gridcraft-nightly is installed and is the manifest's command: and the desktop
  entry's Exec/TryExec. profile_root now accepts that package's own id
  (ai.storyteller.gridcraft.nightly) and still refuses the stable id and every other one.
- plain tarballs: bin/gridcraft-nightly in package.sh's tree and gridcraft-nightly in the flat
  nightly.sh archive, which nightly-archive.py now requires.

The profile root is ${XDG_DATA_HOME:-$HOME/.local/share}/gridcraft-nightly/profile in every
format; it sits beside, never inside, the stable rows.

Also from the re-review: the nightly metainfo no longer lists mediatypes and names the launcher
as its binary, the nightly desktop file and metainfo are validated now that the tools are
present, and nightly-common.sh passes GRIDCRAFT_VERSION on the build command as well as
inheriting it and checks the exact identity the binary prints (with the output in the message).
packaging/linux/nightly-linux-launch-tests.py runs the launcher in both moved-tree layouts and
stages deb, tar and AppImage with stub nfpm/appimagetool/strip, so the wrappers are tested
without cargo; nightly-arch-tar-test.sh asserts the launcher argv.

Builds on dylanmtaylor's co-installable Linux packages (#4733, @dylanmtaylor).

skylartaylor <skylartaylor@users.noreply.github.com>
2026-11-24 23:19:36 +01:00
skylartaylor 6157356c1a Nightly: app-side flavor, Windows and macOS packaging, dormant release callers
Give GridCraft the isolated nightly-v1 channel from the nightlies-lead kit, rebased on
dylanmtaylor's #4733 head: his Linux tar, shared helpers, Arch wrapper and Flatpak/nfpm
changes stay his and are not re-authored here (thanks, Dylan). This commit adds the app
side, Windows and macOS packaging, and the dormant release registration.

App side:
- build.rs selects the channel (GRIDCRAFT_BUILD_CHANNEL), refuses any other value and
  requires the prepared GRIDCRAFT_VERSION for a nightly, which becomes the PE
  ProductVersion and the version the app reports.
- launch_profile.rs implements the Launcher protocol (--launch-profile nightly-v1
  --profile-root <abs> -- files…, separate tokens only) and answers both --version forms
  before any root, log, identity, IPC or window work.
- profile_root.rs fences every stable data root per OS (settings and logs, the control
  token folder, both MSI install folders, the XDG folders plus the system installs and the
  Flatpak row, the four macOS Library rows and the bundle), refuses GRIDCRAFT_CONFIG_DIR,
  an inherited FLATPAK_ID, traversal and alias escapes, and proves the profile writable.
- app_dirs.rs is the single data-root resolver: validated profile, then GRIDCRAFT_CONFIG_DIR,
  then the platform default; ui.json, prefs.json and logs follow it.
- nightly_session.rs keeps a lease and an unclean-exit record, finished in on_exit (the only
  path macOS ⌘Q runs before AppKit ends the process).
- process_identity.rs sets the nightly Windows AUMID before any window; stable never does.
- A nightly skips the updater, the control server (and refuses --control), and the inherited
  control variables; the control-token folder can be pointed at the profile.
- ui-egui gains the channel (app id, name, version, commit, window titles, stable-only
  services), which About, File ▸ Account, window titles and the updater guard use. The
  window keeps a Flatpak package's own id when FLATPAK_ID is set (#4733).
- gridcraft-cli refuses the Launcher profile flags with exit 2.

Packaging: packaging/windows/nightly.ps1 with package.ps1 -Nightly and sign.ps1
-Required/-CheckOnly/-CheckBuildEnvironment; macOS nightly.sh, nightly-lib.sh,
nightly-sign.sh, nightly-verify.sh and nightly_plist.py; the nightly icon set rendered
from a deeper-field vector master by packaging/nightly-icons.py, with provenance. The
Linux tar now stages that icon (one line changed in Dylan's script).

Release: dormant nightly.yml, nightly-sign.yml and nightly-dispatch.yml (literal false &&
everywhere), the v3 policy example with no authority, the stable Linux public key,
actionlint's queue suppression, the packaging-lint source-contract job, sonar.sources
plus the exact fixture scope, and packaging/nightly-release-tests.py. Dylan's enabled
callers, installed policy and shorter docs are superseded so the port lands switched off;
the policy content stays in his branch for the enable PR.

skylartaylor <skylartaylor@users.noreply.github.com>
2026-11-24 22:45:57 +01:00
Dylan M. Taylor 98641eae37 packaging: port nightly.sh helpers and fix PR review/CI issues 2026-11-24 16:18:22 -05:00
Dylan M. Taylor b665e351c1 fix(nightly): fix CI lint/lockfile and address review comments 2026-11-24 14:21:57 -05:00
Dylan M. Taylorandskylartaylor abc551f88f ci(nightly): enable supervised manual nightly runs
Ported from storytold/photocraft#16594 by Skylar (@skylartaylor), adapted for GridCraft:
- Add .github/nightly-signing-policy.json (v3 policy for storytold/gridcraft, repo ID 1408285582, CI workflow 380135773, Sonar project storytold_gridcraft; producer_workflow_id left null until nightly.yml lands on main)
- Add .github/workflows/nightly.yml and .github/workflows/nightly-sign.yml for supervised manual workflow_dispatch runs pinned to craft-common-actions@605d58766e8f536564da8fc81d3676ac86816dea
- Add docs/nightly-release-preparation.md and packaging/nightly-release-tests.py

Credit: Skylar (@skylartaylor), storytold/photocraft#16594

Co-authored-by: skylartaylor <hi@skylar.cc>
2026-11-24 14:14:33 -05:00
Dylan M. Taylor 8007e842b9 packaging(linux): support co-installable nightly packages 2026-11-24 13:33:42 -05:00
8 changed files with 57 additions and 500 deletions
+5 -5
View File
@@ -2,13 +2,13 @@
"schema": "craft-nightly-release-policy/v3",
"repository": "storytold/gridcraft",
"repository_id": 1408285582,
"producer_workflow_id": 429713469,
"producer_workflow_id": null,
"producer_workflow_path": ".github/workflows/nightly.yml",
"producer_tooling_revision": "be00e5ccd18b68e950c8a08532f2230e7c3d0cba",
"producer_workflow_ref": "storytold/craft-common-actions/.github/workflows/nightly-unsigned.yml@be00e5ccd18b68e950c8a08532f2230e7c3d0cba",
"producer_tooling_revision": "605d58766e8f536564da8fc81d3676ac86816dea",
"producer_workflow_ref": "storytold/craft-common-actions/.github/workflows/nightly-unsigned.yml@605d58766e8f536564da8fc81d3676ac86816dea",
"signer_workflow_path": ".github/workflows/nightly-sign.yml",
"signer_tooling_revision": "be00e5ccd18b68e950c8a08532f2230e7c3d0cba",
"release_branch": "nightly-signer",
"signer_tooling_revision": "605d58766e8f536564da8fc81d3676ac86816dea",
"release_branch": "release",
"manual_actors": [
"bflatastic",
"dylanmtaylor",
+7 -10
View File
@@ -1,8 +1,7 @@
name: GridCraft release-ref nightly signer
# Enabled for supervised manual dispatch on the dedicated nightly-signer branch, which only ever
# fast-forwards to reviewed main commits (never the stable release branch).
# A reusable callee does not change context; this must be a real top-level signer-branch dispatch.
# Enabled for supervised manual dispatch on release. Main/release contents must match.
# A reusable callee does not change context; this must be a real top-level release dispatch.
on:
workflow_dispatch:
inputs:
@@ -23,23 +22,21 @@ concurrency:
jobs:
release:
# Actual context guards: official repository, manual dispatch, real nightly-signer branch.
# Actual context guards: official repository, manual dispatch, real release branch.
if: >-
github.repository == 'storytold/gridcraft' &&
github.event_name == 'workflow_dispatch' &&
github.ref == 'refs/heads/nightly-signer' && github.ref_type == 'branch'
github.ref == 'refs/heads/release' && github.ref_type == 'branch'
permissions:
contents: write
actions: read
checks: read
attestations: write
id-token: write
uses: storytold/craft-common-actions/.github/workflows/nightly-release.yml@be00e5ccd18b68e950c8a08532f2230e7c3d0cba
uses: storytold/craft-common-actions/.github/workflows/nightly-release.yml@605d58766e8f536564da8fc81d3676ac86816dea
with:
tooling-revision: be00e5ccd18b68e950c8a08532f2230e7c3d0cba
app-name: gridcraft
tooling-revision: 605d58766e8f536564da8fc81d3676ac86816dea
producer_run_id: ${{ inputs.producer_run_id }}
producer_run_attempt: ${{ inputs.producer_run_attempt }}
# No secrets: inherit or raw platform values in this caller. Only the isolated native
# callee job may bind the release environment and export its keys; that environment must
# admit nightly-signer alongside release before the first dispatch.
# callee job may bind the existing release environment and export keys in its signing step.
+4 -4
View File
@@ -22,13 +22,13 @@ jobs:
actions: read
attestations: write
id-token: write
uses: storytold/craft-common-actions/.github/workflows/nightly-unsigned.yml@be00e5ccd18b68e950c8a08532f2230e7c3d0cba
uses: storytold/craft-common-actions/.github/workflows/nightly-unsigned.yml@605d58766e8f536564da8fc81d3676ac86816dea
with:
tooling-revision: be00e5ccd18b68e950c8a08532f2230e7c3d0cba
tooling-revision: 605d58766e8f536564da8fc81d3676ac86816dea
app-name: gridcraft
manual-actors: '["bflatastic","dylanmtaylor","echelon","FredApps","skylartaylor"]'
craft-fonts-ref: b076417b5880bd4154bd22f00695b1d28c6bea83
# One producer run builds every listed platform for one all-or-nothing release. The pin is the
# craft-common-actions main commit that merged the exact-analysis admission (#371, after #370,
# #369 and #364).
# craft-common-actions main commit that merged #339 (bounded lineage compares), on top of the
# Linux/macOS signer (#342).
platforms: '["windows-x86_64","linux-x86_64","macos-aarch64"]'
+21 -49
View File
@@ -1,11 +1,11 @@
# Windows, Linux and macOS release-ref nightly: supervised manual go-live
**Enabled for supervised manual runs, not yet qualified.** The producer (`nightly.yml`, main) and the
signer (`nightly-sign.yml`, on the dedicated `nightly-signer` branch) keep only their exact context guards and run when one of the reviewed
signer (`nightly-sign.yml`, release) keep only their exact context guards and run when one of the reviewed
manual actors dispatches them. There is no schedule yet. The installed policy
[`.github/nightly-signing-policy.json`](../.github/nightly-signing-policy.json) is the v3 policy
adapted from `storytold/photocraft#16594`. `producer_workflow_id` is the registered
`nightly.yml` workflow id, read with:
adapted from `storytold/photocraft#16594`. Once `nightly.yml` lands on `main`, populate
`producer_workflow_id` before promoting the policy to `release`, read with:
```bash
gh api repos/storytold/gridcraft/actions/workflows/nightly.yml --jq .id
@@ -14,38 +14,16 @@ gh api repos/storytold/gridcraft/actions/workflows/nightly.yml --jq .id
The callers pass no platform secrets. The unsigned reusable caller's maximum OIDC/attestation
permissions are for its isolated attester; its compiler narrows to contents and Actions read
only, with no OIDC, attestation write, release environment or platform signing secrets.
Shared tooling is pinned to `be00e5ccd18b68e950c8a08532f2230e7c3d0cba`, the craft-common-actions
main commit that merged [#371](https://github.com/storytold/craft-common-actions/pull/371) (the
candidate is admitted on the built commit's own Sonar analysis, not main's latest) after
[#370](https://github.com/storytold/craft-common-actions/pull/370) (the Windows and macOS nightly
registry rows for the 14 apps) and
[#369](https://github.com/storytold/craft-common-actions/pull/369) (shared helper checkouts kept out
of the app's clean-source check, and macOS on `macos-15`), following
[#364](https://github.com/storytold/craft-common-actions/pull/364) (the signer may run on the
policy's signer branch) and [#363](https://github.com/storytold/craft-common-actions/pull/363) (the
multi-app pipeline, which makes the signer's `app-name` input required and admits any reviewed
registry app), with #342 (`a4f6fd51`, policy v3 and the `platforms` input) and #339 (`605d5876`)
earlier. Both callers name it in `uses` and `tooling-revision`. A pin is reviewed source
availability, not provider, queue, native signing or crypto qualification.
**Signer branch.** The signer runs on `refs/heads/nightly-signer`, not on the stable `release`
branch, so nightly signer files never need a stable release sync. The policy's `release_branch`
names it, the signer's guard requires it and its caller passes `app-name`. The branch only
fast-forwards to reviewed main commits, through the nightly-signer settings script's `advance` (no
queued signer run, a trust-closure scan, then the full diff of `.github/` and `packaging/`), and the
existing `release` environment must admit `nightly-signer` alongside `release` before the first
dispatch (a repository settings change, not a workflow one). Its trust closure is all of `.github/`
and `packaging/`, including `packaging/env.sh`, which `import-cert.sh` sources with the Apple keys.
On that branch only the pinned `nightly-sign.yml` caller may reach an environment: no app workflow
binds one, nothing else calls `nightly-release.yml`, and the only caller of the shared stable
`release.yml` is `release.yml`, whose callee must carry the stable-only environment guard. The
contract tests check the in-repo part on every main PR; the settings scan also resolves the callee.
Stable releases still come only from `refs/heads/release`. History does not carry over a switch
between `release` and `nightly-signer`, so the switch happens before the first publication.
Shared tooling is pinned to `605d58766e8f536564da8fc81d3676ac86816dea`, the craft-common-actions
main commit that merged [#339](https://github.com/storytold/craft-common-actions/pull/339) (bounded
lineage compares and an issue reread at the end of candidate admission) on top of
[#342](https://github.com/storytold/craft-common-actions/pull/342) (policy v3, the `platforms` input
and the Linux and macOS legs). Both callers name it in `uses` and `tooling-revision`. A pin is reviewed
source availability, not provider, queue, native signing or crypto qualification.
Existing stable workflows are unchanged.
**First runs.** The first runs are manual dispatches in this order: `nightly.yml` on main (only a
listed manual actor passes the producer's plan step), then `nightly-sign.yml` on `nightly-signer` with that
listed manual actor passes the producer's plan step), then `nightly-sign.yml` on `release` with that
producer run ID and attempt, by a listed manual actor.
**Manual actors.** `bflatastic`, `dylanmtaylor`, `echelon`, `FredApps` and `skylartaylor`, in the
@@ -66,13 +44,13 @@ so there is no separate Linux or macOS caller job and the signer caller has no p
## Installed policy values and their sources
Read on 2026-11-24; re-read anything that may have moved (and populate `producer_workflow_id` and
any Sonar debt snapshot) before `nightly-signer` is advanced to it.
any Sonar debt snapshot) before the policy is promoted to `release`.
| Field | Value | Source |
|---|---|---|
| `repository_id` | `1408285582` | `gh api repos/storytold/gridcraft --jq .id` |
| `producer_workflow_id` | `429713469` | `gh api repos/storytold/gridcraft/actions/workflows/nightly.yml` (path `.github/workflows/nightly.yml`, state `active`) |
| `producer_tooling_revision`, `signer_tooling_revision`, `producer_workflow_ref` | `be00e5cc…` (craft-common-actions exact-analysis admission, #371 after #370 and #369, following #364) | The callers' pin |
| `producer_workflow_id` | `null` (pending `main` registration) | Read with `gh api repos/storytold/gridcraft/actions/workflows/nightly.yml --jq .id` after `nightly.yml` lands on `main` |
| `producer_tooling_revision`, `signer_tooling_revision`, `producer_workflow_ref` | `605d5876…` (craft-common-actions #339) | The callers' pin |
| `manual_actors` / `automatic_signer_actors` | the five release managers / `[]` | release-managers team (id 19837241) members who can push; equals the producer caller's `manual-actors` |
| `max_age_seconds`, `max_artifact_bytes` | `86400`, `2147483648` | Go-live checklist |
| `platforms` | three rows | Suite stable identities (Windows Authenticode publisher subject, Linux OpenPGP release key fingerprint, macOS Apple Developer ID team `DJ6XS33FX8`) |
@@ -85,8 +63,8 @@ any Sonar debt snapshot) before `nightly-signer` is advanced to it.
- `.github/workflows/nightly.yml`: default-main registration of the unsigned producer, named
`GridCraft unsigned nightly`, enabled for manual dispatch by `manual-actors`; no signing secrets
may be passed or inherited.
- `.github/workflows/nightly-sign.yml`: top-level signer registration, enabled for manual dispatch
on `nightly-signer`, which carries a reviewed main commit. It rejects wrong repository/event/actual branch,
- `.github/workflows/nightly-sign.yml`: top-level release registration, enabled for manual dispatch,
and identical on main and release after reviewed promotion. It rejects wrong repository/event/actual branch,
including same-name tags. Its constant whole-run concurrency (`gridcraft-nightly-release`) is distinct
from stable, cancellation is off and `queue: max` must be hosted-qualified. The caller itself passes no
credentials; only the shared callee's sign jobs bind the `release` environment.
@@ -104,9 +82,6 @@ any Sonar debt snapshot) before `nightly-signer` is advanced to it.
- Manual actors are exactly the reviewed release managers in both `nightly.yml` and `.github/nightly-signing-policy.json`, with `automatic_signer_actors` empty.
- Root serialization in `nightly-sign.yml` remains literal (`group: gridcraft-nightly-release`, `cancel-in-progress: false`); it carries no `queue:` key while actionlint 1.7.12 rejects that key, and the value is re-added when the hosted queue is qualified.
- Installed policy v3 fields, bounds, platforms, candidate workflows, and Sonar identity match `sonar-project.properties` and the callers.
- The `nightly-signer` trust-closure scan: no app workflow binds `environment:`, only
`nightly-sign.yml` calls `nightly-release.yml` at a 40-hex SHA, and the only caller of the
shared stable `release.yml` is `release.yml`.
## GridCraft's nightly-v1 flavor (the same branch)
@@ -130,24 +105,21 @@ traversing root, a root that resolves through a link into a fenced folder, an in
`${XDG_DATA_HOME:-$HOME/.local/share}/gridcraft-nightly/profile`, a sibling of stable's
`<xdg>/gridcraft`, never an ancestor.
**Every Linux format ships a launcher.** The flat nightly tar's `gridcraft` is craft-common-actions'
shared launcher template (`scripts/nightly-launcher.sh.in` from #363, rendered for this app), so it always
supplies its own profile; the packaged formats pass an already-supplied profile through.
**Every Linux format ships a launcher, and each passes an already-supplied profile through.**
| Format | Launcher | GUI | Data root |
|---|---|---|---|
| deb/rpm | `/usr/bin/gridcraft-nightly` | `/usr/lib/gridcraft-nightly/gridcraft` | `<xdg>/gridcraft-nightly/profile` |
| AppImage | `AppRun` (a script) and `usr/bin/gridcraft-nightly` | `usr/bin/gridcraft` | same |
| flat nightly tar | `gridcraft` (the shared template) | `gridcraft-bin` | `<xdg>/ai.storyteller.gridcraft.nightly` |
| plain tree tarball | `bin/gridcraft-nightly` | `bin/gridcraft` | `<xdg>/gridcraft-nightly/profile` |
| Arch handoff | `bin/gridcraft-nightly` | `.gridcraft-nightly/gridcraft` | `<xdg>/gridcraft-nightly/profile` |
| flat nightly tar | `gridcraft` | `gridcraft-bin` | same |
| plain tree tarball | `bin/gridcraft-nightly` | `bin/gridcraft` | same |
| Arch handoff | `bin/gridcraft-nightly` | `.gridcraft-nightly/gridcraft` | same |
| Flatpak bundle | `/app/bin/gridcraft-nightly` | `/app/bin/gridcraft` | the sandbox's own `~/.local/share` |
The flat nightly tar uses the kit's standard layout: `<app>` is the launcher people run and
`<app>-bin` is the GUI ELF it starts, so the shared Unix verifier can keep requiring `gridcraft`
as the entrypoint. That launcher is the shared template: it resolves its own directory once and execs
`gridcraft-bin` with `--launch-profile nightly-v1 --profile-root <xdg>/ai.storyteller.gridcraft.nightly --`
and the user's arguments, asking a bare `--version`/`-V` in the Launcher's own form.
as the entrypoint. No launcher falls back to a relative or world-writable path for the GUI, and a
candidate that is the launcher itself is never started.
**macOS and Windows.** `GridCraft Nightly.app` (`CFBundleIdentifier
ai.storyteller.gridcraft.nightly`, associations removed) is built and verified unsigned on main and
+16 -89
View File
@@ -2,13 +2,10 @@
"""The Linux launch profile, staged the way each format ships it; no cargo build, no GUI, no network.
What is checked, all synthetic:
* `nightly-tar-launch.sh` (craft-common-actions' rendered template, the plain tar's entrypoint) starts
`<app>-bin` with the template's exact tokens and the channel's own profile root;
* `nightly-launch.sh` (the AppImage and plain-tree launcher) passes the flavor's own tokens;
* `nightly-launch.sh` (the AppImage and tar launcher) passes the flavor's own tokens and nothing else;
* `package.sh` stages the deb/rpm, AppImage and tar launchers and a nightly desktop entry, and
leaves a stable tree exactly as it was. `nfpm`, `appimagetool` and `strip` are stubs on PATH.
"""
import hashlib
import os
from pathlib import Path
import shutil
@@ -19,13 +16,9 @@ import unittest
ROOT = Path(__file__).resolve().parents[2]
LAUNCHER = ROOT / "packaging/linux/nightly-launch.sh"
TAR_LAUNCHER = ROOT / "packaging/linux/nightly-tar-launch.sh"
PACKAGE = ROOT / "packaging/linux/package.sh"
NIGHTLY_VERSION = "0.19.1-nightly.20261124.7.1.gabcdef012345"
PROFILE = "gridcraft-nightly/profile"
# The tar launcher is the shared template rendered for this app; these are its bytes.
TAR_PROFILE = "ai.storyteller.gridcraft.nightly"
TAR_LAUNCHER_SHA256 = "da4d5c6187527b57bb3d6b9f2b8791dff71c2f3421a4116cbda3cd3314b54af7"
RECORDER = """#!/bin/sh
printf '<%s>\\n' "$@"
@@ -37,7 +30,7 @@ def run(argv, cwd, env, check=True):
class MovedTreeLauncher(unittest.TestCase):
"""nightly-launch.sh as AppRun and as a plain tree tarball's launcher."""
"""nightly-launch.sh as AppRun and as an unpacked tar's launcher."""
def setUp(self):
self.scratch = tempfile.TemporaryDirectory()
@@ -50,11 +43,13 @@ class MovedTreeLauncher(unittest.TestCase):
"""Each placement puts the GUI and this launcher where its format does.
appdir: AppRun at the root, GUI in usr/bin (also usr/bin/gridcraft-nightly).
tar: the kit's flat tar, `gridcraft` launcher beside the `gridcraft-bin` GUI.
tree: a plain tree tarball, bin/gridcraft-nightly beside bin/gridcraft.
"""
tree = self.root / layout
binary, launcher_name = {
"appdir": (tree / "usr/bin/gridcraft", tree / "AppRun"),
"tar": (tree / "gridcraft-bin", tree / "gridcraft"),
"tree": (tree / "bin/gridcraft", tree / "bin/gridcraft-nightly"),
}[layout]
binary.parent.mkdir(parents=True)
@@ -71,7 +66,7 @@ class MovedTreeLauncher(unittest.TestCase):
return ["<--launch-profile>", "<nightly-v1>", "<--profile-root>", f"<{self.data / PROFILE}>", "<-->"]
def test_every_layout_starts_the_gui_through_the_launch_profile(self):
for layout in ("appdir", "tree"):
for layout in ("appdir", "tar", "tree"):
with self.subTest(layout=layout):
launcher = self.install(layout)
self.assertEqual(self.query(launcher).stdout.splitlines(), self.tokens())
@@ -97,84 +92,16 @@ class MovedTreeLauncher(unittest.TestCase):
self.assertIn("no GridCraft binary", missing.stderr)
self.assertFalse(self.data.exists(), "a refused launch creates no data folder")
def test_the_launcher_is_portable_shell(self):
for launcher in (LAUNCHER, TAR_LAUNCHER):
with self.subTest(launcher=launcher.name):
run(["sh", "-n", str(launcher)], cwd=self.root, env=self.env)
self.assertTrue(launcher.read_text().startswith("#!/bin/sh\n"))
class CanonicalTarLauncher(unittest.TestCase):
"""The plain nightly tar's entrypoint: the shared template, rendered for GridCraft."""
def setUp(self):
self.scratch = tempfile.TemporaryDirectory()
self.addCleanup(self.scratch.cleanup)
self.root = Path(self.scratch.name)
self.data = self.root / "data"
self.home = self.root / "home with space"
self.env = {"PATH": os.environ["PATH"], "XDG_DATA_HOME": str(self.data)}
def install(self):
"""The kit's flat tar: the `gridcraft` launcher beside the `gridcraft-bin` GUI."""
tree = self.root / "tar"
tree.mkdir()
(tree / "gridcraft-bin").write_text(RECORDER)
(tree / "gridcraft-bin").chmod(0o755)
shutil.copy2(TAR_LAUNCHER, tree / "gridcraft")
(tree / "gridcraft").chmod(0o755)
return tree / "gridcraft"
def prefix(self, profile_root):
return ["<--launch-profile>", "<nightly-v1>", "<--profile-root>", f"<{profile_root}>"]
def tokens(self, profile_root):
return self.prefix(profile_root) + ["<-->"]
def test_every_argument_follows_the_profile_tokens(self):
launcher = self.install()
self.assertEqual(run([str(launcher)], cwd=self.root, env=self.env).stdout.splitlines(),
self.tokens(self.data / TAR_PROFILE))
self.assertEqual(
run([str(launcher), "workbook with spaces.xlsx", "--other-name.xlsx"], cwd=self.root, env=self.env).stdout.splitlines(),
self.tokens(self.data / TAR_PROFILE) + ["<workbook with spaces.xlsx>", "<--other-name.xlsx>"],
)
def test_the_profile_root_falls_back_to_the_data_home_under_home(self):
launcher = self.install()
env = {"PATH": os.environ["PATH"], "HOME": str(self.home)}
self.assertEqual(run([str(launcher), "book.xlsx"], cwd=self.root, env=env).stdout.splitlines(),
self.tokens(self.home / ".local/share" / TAR_PROFILE) + ["<book.xlsx>"])
self.assertFalse(self.home.exists(), "the launcher creates no folder of its own")
def test_a_version_query_asks_the_gui_in_the_launcher_form(self):
launcher = self.install()
for flag in ("--version", "-V"):
with self.subTest(flag=flag):
self.assertEqual(run([str(launcher), flag], cwd=self.root, env=self.env).stdout.splitlines(),
self.prefix(self.data / TAR_PROFILE) + ["<--version>"])
def test_a_launcher_profile_argv_passes_through_unchanged(self):
# The ArtCraft Launcher names its own profile and per-install root; the app validates the pair.
launcher = self.install()
argv = ["--launch-profile", "nightly-v1", "--profile-root", str(self.root / "launcher root"), "--", "book.xlsx"]
self.assertEqual(run([str(launcher), *argv], cwd=self.root, env=self.env).stdout.splitlines(),
[f"<{arg}>" for arg in argv])
def test_a_missing_gui_fails_before_anything_runs(self):
launcher = self.install()
def test_a_flat_tar_launcher_never_starts_itself(self):
launcher = self.install("tar")
(self.root / "tar/gridcraft-bin").unlink()
missing = run([str(launcher), "book.xlsx"], cwd=self.root, env=self.env, check=False)
self.assertNotEqual(missing.returncode, 0)
self.assertEqual(missing.stdout, "")
refused = run([str(launcher)], cwd=self.root, env=self.env, check=False)
self.assertEqual(refused.returncode, 2)
self.assertIn("no GridCraft binary", refused.stderr)
def test_the_bytes_are_the_shared_template_rendered_for_gridcraft(self):
data = TAR_LAUNCHER.read_bytes()
self.assertEqual(hashlib.sha256(data).hexdigest(), TAR_LAUNCHER_SHA256,
"the tar launcher must stay byte for byte scripts/nightly-launcher.sh.in rendered for gridcraft")
self.assertIn(b'target="$dir/gridcraft-bin"', data)
self.assertIn(b'/ai.storyteller.gridcraft.nightly"', data)
self.assertNotIn(b"gridcraft-nightly/profile", data, "the profile root is the package identity")
def test_the_launcher_is_portable_shell(self):
run(["sh", "-n", str(LAUNCHER)], cwd=self.root, env=self.env)
self.assertTrue(LAUNCHER.read_text().startswith("#!/bin/sh\n"))
class FlatNightlyTar(unittest.TestCase):
@@ -183,13 +110,13 @@ class FlatNightlyTar(unittest.TestCase):
def test_the_flat_tar_stages_the_kit_layout(self):
source = (ROOT / "packaging/linux/nightly.sh").read_text()
self.assertIn('cp "$NIGHTLY_GUI" "$STAGE/gridcraft-bin"', source, "the GUI is <app>-bin")
self.assertIn('"$ROOT/packaging/linux/nightly-tar-launch.sh" "$STAGE/gridcraft"', source, "the launcher is <app>")
self.assertIn('"$ROOT/packaging/linux/nightly-launch.sh" "$STAGE/gridcraft"', source, "the launcher is <app>")
self.assertNotIn('"$STAGE/gridcraft-nightly"', source, "the flat tar's launcher is gridcraft")
policy = (ROOT / "packaging/nightly-archive.py").read_text()
self.assertIn('{"gridcraft", "gridcraft-bin", "gridcraft-nightly.png"}', policy)
self.assertIn('required = {"gridcraft", "gridcraft-bin", "gridcraft-nightly.png"', policy)
launcher = TAR_LAUNCHER.read_text()
self.assertIn('target="$dir/gridcraft-bin"', launcher, "the launcher starts the GUI the tar ships")
launcher = LAUNCHER.read_text()
self.assertIn('"$here/gridcraft-bin"', launcher, "the launcher starts the GUI the tar ships")
class StagedFormats(unittest.TestCase):
-16
View File
@@ -1,16 +0,0 @@
#!/bin/sh
# Nightly launcher generated by craft-common-actions scripts/nightly-launcher.sh.in. Do not edit:
# the shared nightly producer accepts this file only byte for byte as rendered for the app.
set -eu
dir=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)
readonly dir
target="$dir/gridcraft-bin"
readonly target
profile_root="${XDG_DATA_HOME:-$HOME/.local/share}/ai.storyteller.gridcraft.nightly"
readonly profile_root
case "${1-}" in
# The ArtCraft Launcher passes its own profile and per-install root; the app validates the pair.
--launch-profile) exec "$target" "$@" ;;
--version | -V) exec "$target" --launch-profile nightly-v1 --profile-root "$profile_root" --version ;;
esac
exec "$target" --launch-profile nightly-v1 --profile-root "$profile_root" -- "$@"
+2 -3
View File
@@ -20,11 +20,10 @@ STAGE="$NIGHTLY_WORK/stage"
mkdir -p "$STAGE"
# The kit's tar layout: `gridcraft` is the launcher people run and `gridcraft-bin` is the GUI it
# starts. An unpacked archive is isolated too, because the GUI refuses to start without a launch
# profile and the launcher is the only thing that supplies one. The launcher is craft-common-actions'
# canonical template rendered for this app (scripts/nightly_app.py launcher), not a local script.
# profile and the launcher is the only thing that supplies one.
cp "$NIGHTLY_GUI" "$STAGE/gridcraft-bin"
chmod 755 "$STAGE/gridcraft-bin"
cp "$ROOT/packaging/linux/nightly-tar-launch.sh" "$STAGE/gridcraft"
cp "$ROOT/packaging/linux/nightly-launch.sh" "$STAGE/gridcraft"
chmod 755 "$STAGE/gridcraft"
# The nightly channel's own icon (deeper field); the archive member name stays as the helper requires.
cp "$ROOT/assets/app-icon/gridcraft-nightly.png" "$STAGE/gridcraft-nightly.png"
+2 -324
View File
@@ -6,21 +6,11 @@ import hashlib
import json
from pathlib import Path
import re
import textwrap
import unittest
ROOT = Path(__file__).resolve().parents[1]
INSTALLED_POLICY = ROOT / ".github/nightly-signing-policy.json"
DISPATCHER = ROOT / ".github/workflows/nightly-dispatch.yml"
SIGNER_BRANCH = "nightly-signer"
def inline_scripts(path):
"""Read literal run blocks, not a substitute for YAML/actionlint validation."""
return [textwrap.dedent(block) for block in re.findall(
r"^ run: \|\n((?: .*\n|\n)+)", path.read_text(), re.MULTILINE)]
NIGHTLY_PLATFORMS = ("windows-x86_64", "linux-x86_64", "macos-aarch64")
# Each platform's one trust field in policy v3, and the public stable identity it must name.
NIGHTLY_TRUST = {
@@ -285,7 +275,7 @@ class NightlyEnabledCallers(unittest.TestCase):
"github.ref_type == 'branch' && (github.event_name == 'schedule' || "
"github.event_name == 'workflow_dispatch')",
"nightly-sign.yml": "github.repository == 'storytold/gridcraft' && github.event_name == 'workflow_dispatch' && "
"github.ref == 'refs/heads/nightly-signer' && github.ref_type == 'branch'",
"github.ref == 'refs/heads/release' && github.ref_type == 'branch'",
}
def test_enabled_jobs_keep_exact_context_guards(self):
@@ -357,7 +347,7 @@ class NightlyInstalledPolicy(unittest.TestCase):
self.assertEqual(set(self.policy), expected)
self.assertEqual(self.policy["schema"], "craft-nightly-release-policy/v3")
self.assertEqual(self.policy["repository"], "storytold/gridcraft")
self.assertEqual(self.policy["release_branch"], SIGNER_BRANCH, "the signer runs on its dedicated branch")
self.assertEqual(self.policy["release_branch"], "release")
self.assertIs(type(self.policy["repository_id"]), int)
self.assertGreater(self.policy["repository_id"], 0)
# producer_workflow_id is null until nightly.yml is registered on main; once set, must be a positive int.
@@ -469,318 +459,6 @@ class NightlyInstalledPolicy(unittest.TestCase):
self.assertIn(item["type"], sonar["issue_types"])
self.assertRegex(item["hash"], r"^[0-9a-f]{32}$")
def test_sonar_policy_keeps_the_shared_candidate_contract(self):
"""The Sonar shape craft-common-actions' candidate contract() admits, refused here first.
An empty issue scope, an accepted condition outside the reviewed issue types, a metric in both
lists, a missing live gate condition or a widened security bound is refused at admission, so
this suite must catch it before a nightly run can. `debt` stays empty, so any unresolved
vulnerability on main is still refused; accepting the new-code rating only records the
reviewed A threshold instead of demanding a clean rating the live gate does not.
"""
sonar = self.policy["candidate_policy"]["sonar"]
accepted = {"bugs": "BUG", "vulnerabilities": "VULNERABILITY", "code_smells": "CODE_SMELL",
"security_rating": "VULNERABILITY", "new_security_rating": "VULNERABILITY"}
gate = {"new_reliability_rating", "new_security_rating", "new_maintainability_rating",
"new_coverage", "new_duplicated_lines_density", "new_security_hotspots_reviewed"}
self.assertTrue(sonar["issue_types"], "an empty issue scope is refused as unreviewed")
self.assertEqual(len(sonar["issue_types"]), len(set(sonar["issue_types"])))
metrics = {}
for field in ("accepted_conditions", "required_conditions"):
for condition in sonar[field]:
with self.subTest(field=field, metric=condition.get("metric")):
expected = {"metric", "comparator", "error_threshold"}
if field == "accepted_conditions":
expected.add("maximum")
self.assertEqual(set(condition), expected)
self.assertNotIn(condition["metric"], metrics, "one condition per gate metric")
metrics[condition["metric"]] = condition
self.assertIn(condition["comparator"], ("GT", "LT"))
self.assertRegex(condition["error_threshold"], r"^(?:0|[1-9][0-9]*)(?:\.[0-9]+)?$")
if field != "accepted_conditions":
continue
self.assertIn(condition["metric"], accepted, "an accepted metric outside the reviewed map")
self.assertIn(accepted[condition["metric"]], sonar["issue_types"],
"an accepted failure must lie inside the reviewed issue scope")
self.assertEqual(condition["comparator"], "GT")
self.assertRegex(condition["maximum"], r"^(?:0|[1-9][0-9]*)(?:\.[0-9]+)?$")
maximum = float(condition["maximum"])
if condition["metric"] in ("security_rating", "new_security_rating"):
self.assertEqual(int(maximum), maximum, "the A..E bound is a whole rating")
self.assertTrue(1 <= maximum <= 5, "the security bound stays A..E")
self.assertEqual(condition["error_threshold"], "1", "the reviewed A threshold stays")
else:
self.assertLessEqual(maximum, len(sonar["debt"]), "accepted failures exceed the reviewed debt")
self.assertEqual({accepted[c["metric"]] for c in sonar["accepted_conditions"]}, set(sonar["issue_types"]),
"accepted conditions and reviewed issue types must cover the same scope")
self.assertEqual(set(metrics), gate, "every live gate condition stays gated exactly once")
SHARED = "storytold/craft-common-actions/.github/workflows/"
# App workflows reviewed to call the shared stable release.yml. That callee must carry the
# stable-only environment guard (dry runs and non-release refs bind no environment); the
# nightly-signer settings scan checks the resolved callee before creating or advancing the branch.
REVIEWED_STABLE_RELEASE_CALLERS = {"release.yml"}
def app_workflows():
return {path.name: path.read_text() for path in sorted((ROOT / ".github/workflows").glob("*.y*ml"))}
WORKFLOW_KEY = re.compile(r'''("(?:[^"\\]|\\.)*"|'(?:[^']|'')*'|[^\s'"#{}\[\],:&*!|>%@`?-][^:#,{}]*?|-[^\s:#][^:#,{}]*?)\s*:(?:\s+(.*))?$''')
def _workflow_key(text):
if text.startswith('"'):
return None if "\\" in text else text[1:-1]
if text.startswith("'"):
return text[1:-1].replace("''", "'")
return text
def _workflow_value(text):
"""A one-line scalar value without its comment and quotes; None when escaped or unterminated."""
text = text.strip()
if text.startswith('"'):
quoted = re.match(r'"((?:[^"\\]|\\.)*)"\s*(?:#.*)?$', text)
return None if quoted is None or "\\" in quoted.group(1) else quoted.group(1)
if text.startswith("'"):
quoted = re.match(r"'((?:[^']|'')*)'\s*(?:#.*)?$", text)
return None if quoted is None else quoted.group(1).replace("''", "'")
return re.split(r"\s+#", text, maxsplit=1)[0].strip()
def _strip_comment(text):
"""(text without its comment, unterminated) using a quote-aware scan.
As in YAML, a quote opens a quoted scalar only where a scalar starts (line start or after
`:`, `-`, `,`, `{` or `[`), and a `#` starts a comment only outside quotes, at the start or
after whitespace.
"""
quote, index = None, 0
while index < len(text):
char = text[index]
if quote == '"':
if char == "\\":
index += 2
continue
if char == '"':
quote = None
elif quote == "'":
if char == "'":
if text[index + 1:index + 2] == "'":
index += 2
continue
quote = None
elif char in "\"'" and text[:index].rstrip()[-1:] in ("", ":", "-", ",", "{", "["):
quote = char
elif char == "#" and (index == 0 or text[index - 1] in " \t"):
return text[:index].rstrip(), False
index += 1
return text.rstrip(), quote is not None
FLOW_QUOTED = re.compile(r"\"(?:[^\"\\]|\\.)*\"|'(?:[^']|'')*'")
FLOW_FORBIDDEN_KEYS = {"environment", "uses"}
def workflow_entries(source):
"""Every mapping entry in a workflow, plus the YAML forms this reader refuses.
A narrow reader, not a YAML parser (none ships with the runner's Python). Each entry is
(line, key, value, multiline): plain, single- and double-quoted keys and one-line values in
block and simple one-line flow mappings. Block scalar bodies are skipped, and an entry whose
value is a block scalar or continues on the next lines is marked multiline. It refuses whatever
could hide a key from it: escaped double-quoted keys, explicit `?` keys, merge keys, anchors,
aliases, tags, tab indentation and nested or multi-line flow.
"""
lines = source.splitlines()
entries, refused, block = [], [], None
def continues(index, indent):
for follow in lines[index + 1:]:
stripped = follow.strip()
if not stripped or stripped.startswith("#"):
continue
deeper = len(follow) - len(follow.lstrip(" ")) > indent
return deeper and not stripped.startswith("- ") and WORKFLOW_KEY.match(stripped) is None
return False
for index, raw in enumerate(lines):
number = index + 1
stripped = raw.strip()
indent = len(raw) - len(raw.lstrip(" "))
if block is not None:
if not stripped or indent > block:
continue
block = None
if not stripped or stripped.startswith("#"):
continue
if "\t" in raw[:indent + 1]:
refused.append(f"line {number}: tab indentation"); continue
body, unterminated = _strip_comment(stripped)
if unterminated:
refused.append(f"line {number}: unterminated or multi-line quoted scalar"); continue
if not body:
continue
while body.startswith("- "):
body = body[2:].lstrip()
if body == "?" or body.startswith("? "):
refused.append(f"line {number}: explicit key"); continue
match = WORKFLOW_KEY.match(body)
value = body
if match is not None:
key, value = _workflow_key(match.group(1)), match.group(2) or ""
if key is None:
refused.append(f"line {number}: escaped double-quoted key"); continue
if key == "<<":
refused.append(f"line {number}: merge key"); continue
plain = re.sub(r"\$\{\{.*?\}\}", "", value).strip()
bare = re.sub(r"\"(?:[^\"\\]|\\.)*\"|'(?:[^']|'')*'", "''", plain)
if re.match(r"[&*!]", plain):
refused.append(f"line {number}: anchor, alias or tag")
is_block = re.fullmatch(r"[|>][0-9+-]*", plain) is not None
if match is not None:
entries.append((number, key, _workflow_value(value),
is_block or ((value == "" or not is_block) and continues(index, indent))))
if "{" in bare and bare != "{}":
masked = re.fullmatch(r"\{([^{}\[\]]*)\}", FLOW_QUOTED.sub("''", value.strip()))
flow = re.fullmatch(r"\{([^{}\[\]]*)\}", value.strip())
if any(set(scalar[1:-1]) & set("#{}[],") for scalar in FLOW_QUOTED.findall(value)):
refused.append(f"line {number}: flow mapping quoted scalar with # or flow punctuation")
elif masked is None or flow is None:
refused.append(f"line {number}: nested or multi-line flow mapping")
else:
# The masked text only proves the shape: a quoted key ("uses", 'environment') keeps
# its identity, so the entries are read from the original mapping text, never ''.
for item in flow.group(1).split(","):
entry = WORKFLOW_KEY.match(item.strip())
key = _workflow_key(entry.group(1)) if entry else None
if key is None:
refused.append(f"line {number}: unreadable flow mapping entry")
elif key in FLOW_FORBIDDEN_KEYS:
refused.append(f"line {number}: {key} in a flow mapping (must be block style)")
else:
entries.append((number, key, _workflow_value(entry.group(2) or ""), False))
if match is not None and is_block:
block = indent
return entries, refused
def workflow_keys(source):
"""(line, key) for every mapping entry, plus the refused YAML forms."""
entries, refused = workflow_entries(source)
return [(number, key) for number, key, _, _ in entries], refused
SHARED_CALLEE = re.compile(r"storytold/craft-common-actions/\.github/workflows/([\w.-]+\.ya?ml)@(\S+)", re.IGNORECASE)
INSPECTED_KEYS = {"environment", "uses"}
def trust_closure_problems(workflows):
"""The nightly-signer trust-closure scan over app workflow sources; empty when the tree is safe.
Every key it inspects comes from workflow_entries(), never a regex over the raw text.
"""
problems, stable_callers, signer_calls = [], set(), 0
for name, source in workflows.items():
entries, refused = workflow_entries(source)
problems.extend(name + " uses YAML the scan cannot read (" + reason + ")" for reason in refused)
for number, key, value, multiline in entries:
if key not in INSPECTED_KEYS:
continue
if key == "environment":
problems.append(f"{name} binds an environment directly (line {number})")
continue
if value is None or multiline:
problems.append(f"{name} has a uses value the scan cannot read (line {number})")
continue
callee = SHARED_CALLEE.fullmatch(value)
if callee is None:
if re.search(r"craft-common-actions", value, re.IGNORECASE) and re.search(r"workflows/(nightly-)?release\.ya?ml", value, re.IGNORECASE):
problems.append(f"{name} has an unrecognised shared release caller (line {number})")
continue
workflow, ref = callee.group(1), callee.group(2)
if workflow.lower() in ("nightly-release.yml", "nightly-release.yaml"):
if name == "nightly-sign.yml":
signer_calls += 1
if name != "nightly-sign.yml" or not re.fullmatch(r"[0-9a-f]{40}", ref):
problems.append(name + " calls nightly-release.yml@" + ref)
if workflow.lower() in ("release.yml", "release.yaml"):
stable_callers.add(name)
if ref != "main" and not re.fullmatch(r"[0-9a-f]{40}", ref):
problems.append(name + " calls release.yml@" + ref + "; use @main or a reviewed full SHA")
if stable_callers != REVIEWED_STABLE_RELEASE_CALLERS:
problems.append("shared release.yml callers are " + ", ".join(sorted(stable_callers)))
if signer_calls != 1:
problems.append("nightly-sign.yml must call nightly-release.yml exactly once")
return problems
class NightlySignerBranchTrustClosure(unittest.TestCase):
"""On refs/heads/nightly-signer, only the pinned signer caller may reach an environment."""
def test_trust_closure_scan_passes_on_this_tree(self):
self.assertEqual(trust_closure_problems(app_workflows()), [])
def test_trust_closure_scan_refuses_each_route_into_an_environment(self):
tree = app_workflows()
bad = {
"a workflow binds an environment": {**tree, "extra.yml": "jobs:\n x:\n runs-on: ubuntu-latest\n environment: release\n"},
"a double-quoted environment key": {**tree, "extra.yml": 'jobs:\n x:\n runs-on: ubuntu-latest\n "environment": release\n'},
"a single-quoted environment key": {**tree, "extra.yml": "jobs:\n x:\n runs-on: ubuntu-latest\n 'environment' : release\n"},
"an environment mapping": {**tree, "extra.yml": "jobs:\n x:\n runs-on: ubuntu-latest\n environment:\n name: release\n"},
"an environment in a flow mapping": {**tree, "extra.yml": "jobs:\n x: {runs-on: ubuntu-latest, environment: release}\n"},
"an escaped key": {**tree, "extra.yml": 'jobs:\n x:\n runs-on: ubuntu-latest\n "environ\\u006dent": release\n'},
"a merge key": {**tree, "extra.yml": "base: &b\n runs-on: ubuntu-latest\njobs:\n x:\n <<: *b\n"},
"an explicit key": {**tree, "extra.yml": "jobs:\n x:\n ? environment\n : release\n"},
"a nested flow mapping": {**tree, "extra.yml": "jobs:\n x: {steps: [{run: a}]}\n"},
"a double-quoted uses key copying the signer": {**tree, "extra.yml": 'jobs:\n x:\n "uses": ' + SHARED + "nightly-release.yml@" + "a" * 40 + "\n"},
"a single-quoted uses key": {**tree, "extra.yml": "jobs:\n x:\n 'uses': " + SHARED + "nightly-release.yml@" + "a" * 40 + "\n"},
"a quoted uses value": {**tree, "extra.yml": 'jobs:\n x:\n uses: "' + SHARED + "nightly-release.yml@" + "a" * 40 + '"\n'},
"uses in a flow mapping": {**tree, "extra.yml": "jobs:\n x: {uses: " + SHARED + "nightly-release.yml@" + "a" * 40 + "}\n"},
"a differently cased owner": {**tree, "extra.yml": "jobs:\n x:\n uses: Storytold/Craft-Common-Actions/.github/workflows/nightly-release.yml@" + "a" * 40 + "\n"},
"a folded uses value": {**tree, "extra.yml": "jobs:\n x:\n uses: >-\n " + SHARED + "nightly-release.yml@" + "a" * 40 + "\n"},
"a continued uses value": {**tree, "extra.yml": "jobs:\n x:\n uses: " + SHARED + "\n nightly-release.yml@" + "a" * 40 + "\n"},
"a quoted second signer call": {**tree, "nightly-sign.yml": tree["nightly-sign.yml"] + " again:\n \"uses\": " + SHARED + "nightly-release.yml@" + "a" * 40 + "\n"},
"a hash inside a quoted flow scalar": {**tree, "extra.yml": 'jobs:\n x: {name: "a} # b", runs-on: ubuntu-latest, environment: release, steps: []}\n'},
"a single-quoted hash in a flow scalar": {**tree, "extra.yml": "jobs:\n x: {name: 'a # b', runs-on: ubuntu-latest}\n"},
"a comma inside a quoted flow scalar": {**tree, "extra.yml": 'jobs:\n x: {name: "a, environment: release", runs-on: ubuntu-latest}\n'},
"a bracket inside a quoted flow scalar": {**tree, "extra.yml": 'jobs:\n x: {name: "[a]", runs-on: ubuntu-latest}\n'},
"an unterminated quote": {**tree, "extra.yml": 'jobs:\n x:\n name: "a\n b"\n runs-on: ubuntu-latest\n'},
"environment in any flow mapping": {**tree, "extra.yml": "jobs:\n x:\n runs-on: ubuntu-latest\n with: {environment: release}\n"},
"a double-quoted environment key in a flow mapping": {**tree, "extra.yml": 'jobs:\n x:\n runs-on: ubuntu-latest\n with: {"environment": release}\n'},
"a single-quoted environment key in a flow mapping": {**tree, "extra.yml": "jobs:\n x:\n runs-on: ubuntu-latest\n with: {'environment': release}\n"},
"a double-quoted uses key in a flow mapping": {**tree, "extra.yml": 'jobs:\n x: {"uses": ' + SHARED + "nightly-release.yml@" + "a" * 40 + "}\n"},
"uses in any flow mapping": {**tree, "extra.yml": "jobs:\n x:\n steps:\n - {uses: actions/checkout@v4}\n"},
"another caller of the signer": {**tree, "extra.yml": "jobs:\n x:\n uses: " + SHARED + "nightly-release.yml@" + "a" * 40 + "\n"},
"a mutable signer pin": {**tree, "nightly-sign.yml": re.sub(r"nightly-release\.yml@[0-9a-f]{40}", "nightly-release.yml@main", tree["nightly-sign.yml"])},
"a new stable release caller": {**tree, "extra.yml": "jobs:\n x:\n uses: " + SHARED + "release.yml@main\n"},
"a stable caller on a branch or tag ref": {**tree, "release.yml": tree["release.yml"].replace(SHARED + "release.yml@main", SHARED + "release.yml@v1")},
}
for label, workflows in bad.items():
with self.subTest(case=label):
self.assertTrue(trust_closure_problems(workflows))
def test_quoted_keys_in_a_flow_mapping_are_read_not_masked(self):
entries, refused = workflow_entries('jobs:\n x: {runs-on: ubuntu-latest, "name": build}\n')
self.assertEqual(refused, [])
self.assertIn((2, "name", "build", False), entries, "a quoted key keeps its identity")
self.assertIn((2, "runs-on", "ubuntu-latest", False), entries)
_, refused = workflow_entries("jobs:\n x: {runs-on: ubuntu-latest, 'environment': release}\n")
self.assertEqual(refused, ["line 2: environment in a flow mapping (must be block style)"])
def test_signer_dispatch_guard_and_policy_name_the_same_branch(self):
sign = (ROOT / ".github/workflows/nightly-sign.yml").read_text()
(_, guard), = job_conditions(sign.split("\njobs:\n", 1)[1])
self.assertIn("github.ref == 'refs/heads/" + SIGNER_BRANCH + "'", guard)
self.assertNotIn("refs/heads/release", sign, "the signer no longer runs on the stable branch")
self.assertEqual(re.findall(r"(?m)^ app-name: (\S+)$", sign), ["gridcraft"], "the shared signer needs the reviewed registry app")
# This app ships no completion dispatcher yet: that workflow forwards scheduled producers
# only, and no schedule is approved. Adding it is part of a reviewed cadence change.
self.assertFalse(DISPATCHER.exists(), "a completion dispatcher needs its own reviewed activation")
self.assertEqual(json.loads(INSTALLED_POLICY.read_text())["release_branch"], SIGNER_BRANCH)
self.assertFalse((ROOT / "docs/nightly-signing-policy.example.json").exists(),
"a policy example must then name the signer branch")
if __name__ == "__main__":
unittest.main(verbosity=2)