Compare commits

..
Author SHA1 Message Date
skylartaylor e9c97bdb50 fix(nightly): the review's data-safety, probe and fixture findings
* The write probe used `std::fs::write` on a fixed name, which truncated and then
  deleted whatever regular file already sat there; it now creates a fresh name with
  `create_new`, takes the next when one is taken, and removes only its own file.
* The plugin preset Save wrote with `std::fs::write` through a link at the plugin's
  folder or at the preset file, so a Nightly profile could write outside itself.
  `save_preset` refuses a folder or file that is not a real entry and stages the
  body in the same folder, renaming it over the name (a rename replaces a link).
* The Linux check looked for stable folders at `$xdg/config` and `$xdg/data` while
  it sets `$xdg/c` and `$xdg/d`, so it could pass with stable state created.
* `package-tar-test.sh` assumed an x86_64 archive name; it derives the label the
  same way `package.sh` does.
* The Windows signing fixture derived a fake `...gaaaaaaaaaaaa` identity and set no
  build sha or date, so source validation threw before the mocked compiler; it now
  derives all three from the checkout, as the other ports' fixtures do.
* `build_channel`'s tests are now compiled into the app's test build (`#[cfg(test)]
  mod build_channel;`), as in the sibling ports, instead of never running.
2026-11-25 01:41:15 +01:00
skylartaylor e7322ec4df 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 a dependency build script.
- The candidate-workflow check reads the whole `push:` mapping by indentation, so a `paths` filter
  after a blank line is still rejected; a negative fixture covers that layout.
2026-11-25 00:59:29 +01:00
skylartaylor e194e2b71b Nightly: fix the Batch 2A review findings
- Cargo.lock: record winsafe in the soundcraft package, so every --locked
  leg (nightly and stable) resolves again.
- rustfmt over config, main, nightly_session, process_identity and
  profile_root, the five files the repo's fmt gate rejected.
- Drop the duplicated #[test] left in profile_root's tests.
- pt-BR: add "Report a problem" and "Updated by ArtCraft Launcher.", so
  the ui-egui catalog test passes.
- Nightly has no in-app updater: the UI runtime carries the launch's
  service gate, and check, tick, show and start_pending_update return
  before touching craft-update. The Check for Updates entry is not built,
  and the command answers that ArtCraft Launcher owns updates.
- Keep Stable's window title byte for byte in both menu-bar states and
  substitute only the channel's name; pin all four combinations.
- Collapse the FLATPAK_ID fence into one let-chain (collapsible_if).

Also: the README Nightly version row shows the prefix the binary prints,
the Linux Flatpak refusal check requires exit status 2 instead of passing
on any failure, the tar test's shebang is /usr/bin/env bash, and
ATTRIBUTION.md lists the Nightly icons.
2026-11-25 00:12:29 +01:00
skylartayloranddylanmtaylor 835cc9c6b5 Nightly: every Linux format launches with the flavor's profile
On top of dylanmtaylor's Linux packaging (#1740): the deb/rpm wrapper, the Arch launcher, the
Flatpak wrapper, the AppImage AppRun and a new launcher inside both tarballs exec the GUI with
`--launch-profile nightly-v1 --profile-root <dir> --`, passing a Launcher protocol or a --version
query through untouched, so nothing writes stable's settings folder and an unpacked tar is
isolated too. The FHS tar ships `soundcraft` beside `soundcraft-bin`, the Nightly metainfo drops
the MIME type its package no longer installs, nightly-common.sh passes the build channel and
checks both version forms against the prepared identity, the Nightly Flatpak's own app id is the
one Flatpak the profile fence accepts, and the archive and launcher suites run in packaging-lint.

Co-authored-by: dylanmtaylor <dylanmtaylor@users.noreply.github.com>
2026-11-24 23:12:29 +01:00
skylartaylor 80c5d82638 nightly: add the isolated SoundCraft Nightly flavor and its Windows and macOS packaging
On top of @dylanmtaylor's Linux Nightly work (#1740), the app-side flavor and the other two
platforms:

- build.rs/build_channel: SOUNDCRAFT_BUILD_CHANNEL=nightly-v1 sets cfg(soundcraft_nightly_v1),
  requires the exact feed identity (SOUNDCRAFT_VERSION, or the packaging scripts'
  SOUNDCRAFT_OVERRIDE_VERSION for the same value), and embeds the Nightly icon,
  ProductName "SoundCraft Nightly" and that version as ProductVersion.
- launch_profile: the Launcher's `--launch-profile nightly-v1 --profile-root <abs> -- <files>`
  protocol, and its `--version` form answered before any root, logger, window or dialog.
- profile_root: the Nightly root is fenced against every stable data root, install folder,
  portable install, an inherited SOUNDCRAFT_CONFIG_DIR and a Flatpak instance, then created 0700
  and probed through the app's own writer; no stable fallback. The refusal names the wrapper fix.
- config: one override makes the profile the settings folder, so ui.json, Autosave/, Presets/
  and logs/ all land inside it. SoundCraft uses no eframe storage and no single-instance socket,
  and its only IPC (the control server) and updater are off in Nightly.
- os_window/channel_titles/services: distinct app id and window id, channel caption, About
  channel and version, and an exit hook that runs once from on_exit (macOS's only exit path).
- nightly_session: lease plus unclean-exit record under the profile.
- process_identity: the explicit Windows AUMID for Nightly only.
- Packaging: macos/{nightly.sh,nightly-lib.sh,nightly-sign.sh,nightly-verify.sh,nightly_plist.py},
  windows/{nightly.ps1, package.ps1 -Nightly -BuildOnly, sign.ps1 -Required/-CheckOnly/-CheckBuildEnvironment},
  the Nightly icon set derived from the stable art, and their synthetic suites.
- Two lines in @dylanmtaylor's files, for the flavor: nightly-common.sh checks the exact
  `SoundCraft <version> (nightly-v1)` line now that it exists, and linux/nightly.sh stages the
  real Nightly icon instead of the 1024 px stand-in.
- nightly-build.yml runs all three real scripts behind the full-ci label or a dispatch, with no
  secrets, and checks the archive, the version query and the isolation refusals.
2026-11-24 22:30:26 +01:00
Dylan M. Taylor 60502e950a packaging: port Linux nightly script and archive helpers from PhotoCraft 2026-11-24 16:17:47 -05:00
Dylan M. Taylor 790c71c381 fix(linux-packaging): isolate nightly config dir, fix Exec sed delimiter, and satisfy SonarCloud 2026-11-24 15:26:34 -05:00
Dylan M. Taylor c27eb7b3a7 Fix actionlint workflow concurrency key and channel-only nightly artifact basename 2026-11-24 14:21:21 -05:00
Dylan M. Taylorandskylartaylor f145a47331 ci(nightly): enable nightly workflows for supervised manual runs
Port Skylar's (@skylartaylor) storytold/photocraft#16594 to SoundCraft:
- Add `.github/nightly-signing-policy.json` (v3 policy adapted for `storytold/soundcraft`, CI workflow `380135771`, and `storytold_soundcraft` SonarCloud project).
- Add `.github/workflows/nightly.yml` and `.github/workflows/nightly-sign.yml` pinned to `craft-common-actions@605d58766e8f536564da8fc81d3676ac86816dea` for supervised manual `workflow_dispatch` runs by release managers.
- Add `docs/nightly-release-preparation.md` and `packaging/nightly-release-tests.py` local contract tests.

Credit: @skylartaylor (storytold/photocraft#16594)

Co-authored-by: skylartaylor <hi@skylar.cc>
2026-11-24 14:14:36 -05:00
Dylan M. Taylor 6b811d1103 packaging(linux): support co-installable nightly packages 2026-11-24 13:33:40 -05:00
9 changed files with 101 additions and 501 deletions
-16
View File
@@ -1,16 +0,0 @@
-----BEGIN PGP PUBLIC KEY BLOCK-----
mDMEaulK1xYJKwYBBAHaRw8BAQdAqHJeDCjY6Hx5FTn/hW+aqu6V394ubLk0Zj3C
bftDwFm0IkFydENyYWZ0IExpbnV4IFJlbGVhc2UgU2lnbmluZyBLZXmIkwQTFgoA
OxYhBCt2dBtBSq1s0z5jEhOgBcC518PtBQJq6UrXAhsBBQsJCAcCAiICBhUKCQgL
AgQWAgMBAh4HAheAAAoJEBOgBcC518PtGeUA/RjvULBTLlccc+2wtJkfjSnCV+cf
PUMEGmW7XkZWkk51AP9w2A/WLv+79nREWEpZzI8LGK5EjrNazP+sY0l7j5rFCLgz
BGrpStcWCSsGAQQB2kcPAQEHQPl7XkQ1gWsvSPf/T9b4m/UHcjJjBpSOtpYlWR56
er5RiO8EGBYKACAWIQQrdnQbQUqtbNM+YxIToAXAudfD7QUCaulK1wIbAgCBCRAT
oAXAudfD7XYgBBkWCgAdFiEEVo3B9o+Prsx5fzx7AG2va7DvM04FAmrpStcACgkQ
AG2va7DvM07taQEA4d2VFkKRIP0g9TrE86KpnuXPap+LKqe0tfIxpdf9YxIA/0Wo
9H/iG8nH++nxC087p3HE0S+0UovxqkhXJLSr8B4JDOoA/iLRpqTdYmk6fVXMyPJo
SkOVuwZIGS6VgBdSQP0e2P2YAP41L5OoSvwdQIG3/uNrM+ieqpYeM597/hCLFs5A
ga/qCA==
=3wGQ
-----END PGP PUBLIC KEY BLOCK-----
+11 -13
View File
@@ -2,13 +2,13 @@
"schema": "craft-nightly-release-policy/v3",
"repository": "storytold/soundcraft",
"repository_id": 1408486424,
"producer_workflow_id": 429730684,
"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",
@@ -44,20 +44,18 @@
"issue_types": [
"VULNERABILITY"
],
"accepted_conditions": [
{
"metric": "new_security_rating",
"comparator": "GT",
"error_threshold": "1",
"maximum": "5"
}
],
"accepted_conditions": [],
"required_conditions": [
{
"metric": "new_reliability_rating",
"comparator": "GT",
"error_threshold": "1"
},
{
"metric": "new_security_rating",
"comparator": "GT",
"error_threshold": "1"
},
{
"metric": "new_maintainability_rating",
"comparator": "GT",
+7 -10
View File
@@ -1,8 +1,7 @@
name: SoundCraft 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/soundcraft' &&
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: soundcraft
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.
+6 -6
View File
@@ -1,7 +1,7 @@
name: SoundCraft unsigned nightly
# Enabled for supervised manual runs by the reviewed manual actors only; no schedule yet.
# A later explicit opt-in may add a cadence (and a reviewed dispatcher with it).
# Enabled for supervised manual runs by the reviewed manual actor only; no schedule yet.
# A later explicit opt-in may add a cadence (and turn on nightly-dispatch.yml with it).
on:
workflow_dispatch:
@@ -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: soundcraft
manual-actors: '["bflatastic","dylanmtaylor","echelon","FredApps","skylartaylor"]'
craft-fonts-ref: cc9269cd8d8258785dac603fba3122e5d2556795
# 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"]'
+3 -26
View File
@@ -213,23 +213,14 @@ fn initialize_nightly_process_identity() -> Result<(), process_identity::Identit
)
}
/// Whether a refusal may also open a native message box. Standard error always carries the reason;
/// this only adds a box where one renders without the app's event loop. Never on macOS: rfd's alert
/// there needs the AppKit run loop this start has not reached, so a refused nightly launch hung in
/// an invisible modal instead of exiting (GridCraft Mac smoke, 2026-11-26).
fn refusal_dialog(flavor: build_flavor::BuildFlavor, desktop_session: bool, macos: bool) -> bool {
build_flavor::needs_native_error(flavor, desktop_session) && !macos
}
/// Report a refused launch profile on standard error, and in a dialog on a Windows or X11/Wayland
/// desktop session: a Nightly build started from a file manager has no console to read. macOS keeps
/// the console line, because a modal before its event loop never appears.
/// Report a refused launch profile on standard error, and in a dialog on a desktop session: a
/// Nightly build started from a file manager has no console to read.
fn report_launch_profile_error(error: &str) {
eprintln!("SoundCraft launch profile: {error}");
let desktop_session = cfg!(windows)
|| cfg!(target_os = "macos")
|| (cfg!(target_os = "linux") && ["DISPLAY", "WAYLAND_DISPLAY"].into_iter().any(|key| std::env::var_os(key).is_some_and(|v| !v.is_empty())));
if refusal_dialog(build_flavor::COMPILED, desktop_session, cfg!(target_os = "macos")) {
if build_flavor::needs_native_error(build_flavor::COMPILED, desktop_session) {
if let Err(error) = initialize_nightly_process_identity() {
eprintln!("SoundCraft launch profile: {error}");
return;
@@ -458,17 +449,3 @@ mod tests {
assert_eq!(titles("Song * — SoundCraft"), 1);
}
}
#[cfg(test)]
mod refusal_dialog_tests {
use super::refusal_dialog;
use crate::build_flavor::BuildFlavor;
#[test]
fn a_refusal_never_blocks_on_a_modal_before_the_event_loop_on_macos() {
assert!(refusal_dialog(BuildFlavor::NightlyV1, true, false), "a desktop refusal still shows the box where one renders");
assert!(!refusal_dialog(BuildFlavor::NightlyV1, true, true), "macOS has no run loop yet: the modal would hang");
assert!(!refusal_dialog(BuildFlavor::NightlyV1, false, false), "a headless session has no box");
assert!(!refusal_dialog(BuildFlavor::Stable, true, false), "only a nightly refusal explains itself in a box");
}
}
+25 -50
View File
@@ -1,11 +1,12 @@
# 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 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 for SoundCraft; its `producer_workflow_id` is the registration ID of `nightly.yml` on `main`
(`429730684`), read with:
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 for
SoundCraft. Its `producer_workflow_id` is currently `null` until `nightly.yml` is registered on `main`;
once merged to `main`, read the workflow ID and populate `producer_workflow_id` before promoting the
policy to `release`:
```bash
gh api repos/storytold/soundcraft/actions/workflows/nightly.yml --jq .id
@@ -14,37 +15,17 @@ gh api repos/storytold/soundcraft/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.
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 producer run ID and attempt, by a listed manual actor.
**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 and
the signer's guard requires it; this app has no `nightly-dispatch.yml` at all, so nothing transports
a run automatically. The branch only fast-forwards to reviewed main commits, through the 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 and nothing else calls `nightly-release.yml`.
`packaging/nightly-release-tests.py` checks that in-repo part on every main PR. Stable releases
still come only from `refs/heads/release`.
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
producer's `manual-actors` and the policy's `manual_actors`. The list mirrors the `release-managers`
@@ -65,20 +46,19 @@ the signer caller has no platform input.
## Installed policy values and their sources
Read on 2026-11-24; re-read anything that may have moved before `nightly-signer` is advanced to it.
Read on 2026-11-24; re-read anything that may have moved (and populate `producer_workflow_id` after `nightly.yml` lands on `main`) before the policy is promoted to `release`.
| Field | Value | Source |
|---|---|---|
| `repository_id` | `1408486424` | `gh api repos/storytold/soundcraft --jq .id` |
| `producer_workflow_id` | `429730684` | `gh api repos/storytold/soundcraft/actions/workflows/nightly.yml --jq .id` (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 |
| `release_branch` | `nightly-signer` | The shared validator allows `release` or `nightly-signer`; the signer guard names the same ref |
| `producer_workflow_id` | `null` (pending registration) | Read via `gh api repos/storytold/soundcraft/actions/workflows/nightly.yml --jq .id` once `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`); equals the producer caller's `manual-actors` |
| `max_age_seconds`, `max_artifact_bytes` | `86400`, `2147483648` | Go-live checklist |
| `platforms` | three rows | Storytold stable signing identities (`windows-x86_64`, `linux-x86_64`, `macos-aarch64`) |
| `candidate_policy.required_workflows` | CI (`ci.yml`, workflow `380135771`), `gate / gate (ubuntu-24.04)` | Workflow list API and recent `main` push runs |
| `candidate_policy.sonar` | `storytold` / `storytold_soundcraft`, app `12526` | `sonar-project.properties`; the SonarCloud check on `main` commits |
| Sonar conditions | `new_security_rating` accepted (GT 1, maximum 5); the other five required | Quality gate of `storytold_soundcraft` `main`: the same six conditions, and a failing rating is admitted up to the reviewed A..E bound |
| Sonar conditions | All six quality-gate conditions required (`accepted_conditions: []`) | Quality gate of `storytold_soundcraft` `main` (all OK) |
| Sonar `issue_types` / `debt` | `VULNERABILITY`; `[]` (0 unresolved vulnerabilities on `main`) | `api/issues/search` on `main` |
## Ownership and interface
@@ -86,26 +66,21 @@ Read on 2026-11-24; re-read anything that may have moved before `nightly-signer`
- `.github/workflows/nightly.yml`: default-main registration of the unsigned producer, named
`SoundCraft 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 is distinct from stable,
cancellation is off. The caller itself passes no credentials and names the registry `app-name`;
only the shared callee's sign jobs bind the `release` environment.
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.
- Shared reusable entrypoints are `nightly-unsigned.yml` and `nightly-release.yml` in
`storytold/craft-common-actions`. Both must resolve to a **real reviewed public immutable
commit**; the defining workflow SHA and tooling input must match.
**Every Linux Nightly format starts the app the flavor's way.** The `.deb`/`.rpm` wrapper, the
AppImage's `AppRun`, the Arch launcher and the Flatpak wrapper all exec the real GUI with the literal
AppImage's `AppRun`, the Arch launcher, the Flatpak wrapper, the launcher inside the plain
`nightly.tar.gz` and the FHS tree in `package.sh`'s `.tar.gz` all exec the real GUI with the literal
`--launch-profile nightly-v1 --profile-root <${XDG_CONFIG_HOME:-~/.config}/soundcraft-nightly> --`,
and pass a Launcher protocol or a `--version`/`-V` query through untouched, so `soundcraft --version`,
the Launcher's version query and the smoke checks still answer without a profile. The plain
`nightly.tar.gz` (and `package.sh`'s tree tarball, which installs the same file) is the exception: its
`soundcraft` is craft-common-actions' shared launcher template
(#363, rendered for this app), which execs `soundcraft-bin` beside it with
`--profile-root <${XDG_DATA_HOME:-~/.local/share}/ai.storyteller.soundcraft.nightly> --`, forwards a
first-argument `--launch-profile` pair unchanged, and asks a bare `--version`/`-V` in the Launcher's
own form. The profile holds
the Launcher's version query and the smoke checks still answer without a profile. The profile holds
`ui.json`, `Autosave/`, `Presets/` and `logs/`; it is outside stable's settings folder and outside
the unpacked or installed copy, which the flavor's fence would otherwise refuse. The Nightly tarballs
therefore ship `soundcraft` as the launcher next to `soundcraft-bin`, and the Nightly Flatpak — the
+30 -48
View File
@@ -1,8 +1,8 @@
#!/usr/bin/env bash
# The launcher inside the plain Nightly tarball (packaging/linux/nightly-launch.sh): craft-common-actions'
# template rendered for SoundCraft. Every argument follows the profile tokens, the profile root is the
# package identity under the XDG data home (or HOME), and a version query is asked in the Launcher's
# own form so the GUI answers before any profile is read.
# The launcher inside the plain Nightly tarball (packaging/linux/nightly-launch.sh): a launch adds
# the Launcher's private profile, a version query or an already-formed protocol passes through, and
# the profile has the shape the app's fence accepts (absolute, no parent traversal, outside this
# unpacked copy).
set -euo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
@@ -19,61 +19,43 @@ chmod 755 "$work/tree/soundcraft-bin"
cp "$HERE/nightly-launch.sh" "$work/tree/soundcraft"
chmod 755 "$work/tree/soundcraft"
# The bytes are the shared template rendered for this app, not a local script.
sha256sum "$HERE/nightly-launch.sh" | cut -d' ' -f1 | grep -qx \
bdaa899cedd4ef71c77f21af8eb61cca4d62d585fe4d16662c4ef36ff8ed82a2 || {
echo "FAIL: nightly-launch.sh is not the shared template rendered for soundcraft" >&2
exit 1
}
head -n 1 "$work/tree/soundcraft" | grep -qx '#!/bin/sh' || { echo "FAIL: soundcraft is not a script" >&2; exit 1; }
profile="${XDG_CONFIG_HOME:-${HOME:-}/.config}/soundcraft-nightly"
case "$profile" in
/*) ;;
*) echo "FAIL: the launcher profile is not absolute: $profile" >&2; exit 1 ;;
esac
case "/$profile/" in
*/../*) echo "FAIL: the launcher profile contains parent traversal" >&2; exit 1 ;;
esac
case "$profile/" in
"$work/tree/"*) echo "FAIL: the launcher profile is inside the unpacked copy" >&2; exit 1 ;;
esac
# A hand-unpacked tar has to start the private profile even when nobody passes a flag.
export HOME="$work/home with space"
unset XDG_DATA_HOME
identity="ai.storyteller.soundcraft.nightly"
expect() {
local root="$1"
shift
expected="$(printf '<%s>\n' --launch-profile nightly-v1 --profile-root "$root" -- "$@")"
expect_launch() {
expected="$(printf '<%s>\n' --launch-profile nightly-v1 --profile-root "$profile" -- "$@")"
actual=$("$work/tree/soundcraft" "$@")
[[ "$actual" == "$expected" ]] || {
printf 'profile root %s\nexpected:\n%s\nactual:\n%s\n' "$root" "$expected" "$actual" >&2
exit 1
}
}
expect_query() {
local root="$1"
expected="$(printf '<%s>\n' --launch-profile nightly-v1 --profile-root "$root" --version)"
actual=$("$work/tree/soundcraft" --version)
[[ "$actual" == "$expected" ]] || {
printf 'expected:\n%s\nactual:\n%s\n' "$expected" "$actual" >&2
exit 1
}
actual=$("$work/tree/soundcraft" -V)
}
expect_forwarded() {
expected="$(printf '<%s>\n' "$@")"
actual=$("$work/tree/soundcraft" "$@")
[[ "$actual" == "$expected" ]] || {
printf 'expected:\n%s\nactual:\n%s\n' "$expected" "$actual" >&2
exit 1
}
}
expect "$HOME/.local/share/$identity"
expect "$HOME/.local/share/$identity" 'session with spaces.sc' '--other-name.sc'
export XDG_DATA_HOME="$work/xdg with space"
expect "$XDG_DATA_HOME/$identity" 'session.sc'
expect_query "$XDG_DATA_HOME/$identity"
unset XDG_DATA_HOME
expect_query "$HOME/.local/share/$identity"
expect_launch
expect_launch 'session with spaces.sc' '--other-name.sc'
expect_forwarded --version
expect_forwarded -V
expect_forwarded --launch-profile nightly-v1 --profile-root /launcher/profile --version
# The ArtCraft Launcher names its own profile and per-install root: the argv goes through unchanged.
actual=$("$work/tree/soundcraft" --launch-profile nightly-v1 --profile-root "$work/launcher profile with space" -- file.doc)
[[ "$actual" == "$(printf '<%s>\n' --launch-profile nightly-v1 --profile-root "$work/launcher profile with space" -- file.doc)" ]] || {
printf 'expected the Launcher argv unchanged\nactual:\n%s\n' "$actual" >&2
exit 1
}
# The launcher must be a script, not the GUI under its own name: an unpacked tar has to start the
# private profile even when nobody passes a flag.
head -n 1 "$work/tree/soundcraft" | grep -qx '#!/bin/sh' || { echo "FAIL: soundcraft is not the launcher" >&2; exit 1; }
# The launcher itself writes nothing: the profile folder is the GUI's to create.
[[ ! -e "$HOME/.local/share/$identity" ]] || { echo "FAIL: the launcher created the profile" >&2; exit 1; }
echo "PASS: the tarball launcher is the shared template and starts the GUI through the channel's profile"
echo "PASS: tarball Nightly launcher starts the GUI with the Launcher profile and forwards files"
+17 -12
View File
@@ -1,16 +1,21 @@
#!/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.
# The entry point inside the plain Nightly tarball (packaging/linux/nightly.sh installs it as
# `soundcraft`, beside the GUI as `soundcraft-bin`; package.sh's Nightly tar ships the same pair
# under bin).
#
# A Nightly build only starts with its private profile, and every package format passes the
# Launcher's literal protocol: `--launch-profile nightly-v1 --profile-root <dir> -- <files>`. The
# profile holds ui.json, Autosave/, Presets/ and logs/ outside stable's settings folder, and outside
# this unpacked copy, which the app's own fence would refuse.
set -eu
dir=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)
readonly dir
target="$dir/soundcraft-bin"
readonly target
profile_root="${XDG_DATA_HOME:-$HOME/.local/share}/ai.storyteller.soundcraft.nightly"
readonly profile_root
here="$(dirname "$(readlink -f "$0")")"
bin="$here/soundcraft-bin"
profile="${XDG_CONFIG_HOME:-${HOME:-}/.config}/soundcraft-nightly"
# The Launcher's protocol, and a bare version query, pass through untouched: the first already
# names its profile, and the second must answer without one.
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 ;;
--launch-profile | --profile-root | --version | -V) exec "$bin" "$@" ;;
esac
exec "$target" --launch-profile nightly-v1 --profile-root "$profile_root" -- "$@"
exec "$bin" --launch-profile nightly-v1 --profile-root "$profile" -- "$@"
+2 -320
View File
@@ -228,7 +228,7 @@ class NightlyEnabledCallers(unittest.TestCase):
"github.ref_type == 'branch' && (github.event_name == 'schedule' || "
"github.event_name == 'workflow_dispatch')",
"nightly-sign.yml": "github.repository == 'storytold/soundcraft' && 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):
@@ -300,7 +300,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/soundcraft")
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 None until nightly.yml is registered on main, then a positive int.
@@ -392,324 +392,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")
SIGNER_BRANCH = "nightly-signer"
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_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])
expected = ("github.repository == 'storytold/soundcraft' && github.event_name == 'workflow_dispatch'"
" && github.ref == 'refs/heads/" + SIGNER_BRANCH + "' && github.ref_type == 'branch'")
self.assertEqual(" ".join(guard.split()), expected,
"the signer guard is exactly the reviewed repository, dispatch and signer-branch expression")
self.assertEqual(re.findall(r"(?m)^ app-name: (\S+)$", sign), ["soundcraft"],
"the shared signer needs the reviewed registry app")
self.assertFalse((ROOT / ".github/workflows/nightly-dispatch.yml").exists(),
"this app has no automatic transport; adding one needs its own reviewed PR")
policy = json.loads(INSTALLED_POLICY.read_text())
self.assertEqual(policy["release_branch"], SIGNER_BRANCH)
self.assertEqual(policy["automatic_signer_actors"], [], "no automatic signer without a schedule")
if __name__ == "__main__":
unittest.main(verbosity=2)