Compare commits

...
Author SHA1 Message Date
Dylan M. Taylor 5e6f3a7d79 Enable scheduled nightly builds and automatic Stage 2 signer dispatch 2026-11-28 12:58:34 -05:00
Dylan M. Taylor 274ec864ec Nightly signing pin, macOS docs layout, and profile_root reopen fix (#2430)
- Pin nightly workflows and signing policy to craft-common-actions bf94b15b708089b95c4e2d1c978e66ecf1f2f4f3 and explicitly forward the 13 reviewed same-name signing secrets in nightly-sign.yml.
- Stage macOS Nightly notices under Contents/Resources/docs for Launcher layout compatibility and add regression coverage in packaging/macos/nightly_sign_tests.py and packaging/nightly-release-tests.py.
- Allow ordinary non-shared regular files (settings and session state) in apps/deckcraft/src/profile_root.rs while keeping directory-only enforcement for Recovery, Dictionaries, and logs, with a reopen regression test.
2026-11-28 11:32:39 -05:00
FredApps f67d07f132 Parity checklist: headless counts (RFC-0052) (#2417)
* parity: headless counts in the summary (RFC-0052)

* Add the Headless header cell to the parity rows table
2026-11-27 23:32:16 +01:00
Dylan M. TaylorandFredApps 62b8306b69 ci: notify artcraft-services on release state changes (#2401)
* ci: notify artcraft-services on release state changes

* ci: pass only the dispatch token to the notify-services workflow

secrets: inherit hands the called workflow every repository secret, including
the signing credentials. The reusable workflow only reads
ARTCRAFT_SERVICES_DISPATCH_TOKEN, so map just that one.

Also record notify-services.yml in actions.lock so `gh actions-lock --verify`
passes.

---------

Co-authored-by: FredApps <[email protected]>
2026-11-27 09:17:57 -05:00
13 changed files with 485 additions and 32 deletions
+6 -4
View File
@@ -4,10 +4,10 @@
"repository_id": 1408294296,
"producer_workflow_id": 429734568,
"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": "bf94b15b708089b95c4e2d1c978e66ecf1f2f4f3",
"producer_workflow_ref": "storytold/craft-common-actions/.github/workflows/nightly-unsigned.yml@bf94b15b708089b95c4e2d1c978e66ecf1f2f4f3",
"signer_workflow_path": ".github/workflows/nightly-sign.yml",
"signer_tooling_revision": "be00e5ccd18b68e950c8a08532f2230e7c3d0cba",
"signer_tooling_revision": "bf94b15b708089b95c4e2d1c978e66ecf1f2f4f3",
"release_branch": "nightly-signer",
"manual_actors": [
"bflatastic",
@@ -88,7 +88,9 @@
}
},
"max_artifact_bytes": 2147483648,
"automatic_signer_actors": [],
"automatic_signer_actors": [
"github-actions[bot]"
],
"platforms": {
"windows-x86_64": {
"unsigned_artifact_name": "nightly-unsigned-windows-x86_64",
+3 -2
View File
@@ -11,12 +11,13 @@ workflows:
'.github/workflows/lockfile.yml':
- 'actions/[email protected]'
- 'step-security/[email protected]'
'.github/workflows/nightly-sign.yml': []
'.github/workflows/nightly.yml': []
'.github/workflows/nightly-macos.yml':
- 'actions/[email protected]'
- 'step-security/[email protected]'
'.github/workflows/nightly-sign.yml': []
'.github/workflows/nightly.yml': []
'.github/workflows/nix.yml': []
'.github/workflows/notify-services.yml': []
'.github/workflows/packaging-lint.yml':
- 'actions/[email protected]'
- 'step-security/[email protected]'
+72
View File
@@ -0,0 +1,72 @@
name: Dispatch release-ref nightly
# Transport only, never authorization. No checkout, payload parsing or release environment.
on:
workflow_run:
workflows: [DeckCraft unsigned nightly]
types: [completed]
branches: [main]
permissions: {}
jobs:
dispatch:
# Actual context guards only; no checkout, release environment or platform secrets.
if: >-
github.repository == 'storytold/deckcraft' &&
github.event_name == 'workflow_run'
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
actions: write
steps:
- name: Dispatch only the exact completed producer run and attempt
shell: python
env:
GH_TOKEN: ${{ github.token }}
run: |
import json
import os
import urllib.request
def require(value, message):
if not value:
raise RuntimeError(message)
# These filters reduce noise; the protected signer-branch validator repeats admission
# against authenticated API metadata and required attestation/quality evidence.
require(os.environ.get('GITHUB_REPOSITORY') == 'storytold/deckcraft', 'wrong repository')
require(os.environ.get('GITHUB_EVENT_NAME') == 'workflow_run', 'wrong event')
with open(os.environ['GITHUB_EVENT_PATH'], encoding='utf-8') as stream:
event = json.load(stream)
require(event.get('action') == 'completed', 'producer is not complete')
require(event.get('repository', {}).get('full_name') == 'storytold/deckcraft', 'wrong event repository')
producer = event.get('workflow_run', {})
require(producer.get('head_repository', {}).get('full_name') == 'storytold/deckcraft', 'foreign producer')
require(producer.get('path') == '.github/workflows/nightly.yml', 'wrong producer path')
require(producer.get('head_branch') == 'main', 'wrong producer branch')
require(producer.get('status') == 'completed' and producer.get('conclusion') == 'success', 'producer did not succeed')
# First scheduled attempt only; reviewed manual/re-run authority belongs to release policy.
require(producer.get('event') == 'schedule', 'not an automatic scheduled producer')
run_id, attempt = producer.get('id'), producer.get('run_attempt')
require(type(run_id) is int and run_id > 0, 'invalid producer run id')
require(type(attempt) is int and attempt == 1, 'invalid automatic producer attempt')
body = json.dumps({'ref': 'refs/heads/nightly-signer', 'inputs': {
'producer_run_id': str(run_id), 'producer_run_attempt': str(attempt)
}}).encode('utf-8')
request = urllib.request.Request(
'https://api.github.com/repos/storytold/deckcraft/actions/workflows/nightly-sign.yml/dispatches',
data=body, method='POST', headers={
'Authorization': 'Bearer ' + os.environ['GH_TOKEN'],
'Accept': 'application/vnd.github+json',
'Content-Type': 'application/json',
'X-GitHub-Api-Version': '2022-11-28',
'User-Agent': 'deckcraft-nightly-dispatch'
})
class NoRedirect(urllib.request.HTTPRedirectHandler):
def redirect_request(self, req, fp, code, msg, headers, newurl):
raise RuntimeError('dispatch redirects are forbidden')
# One bounded request, no retry: duplicate transport is not publication authority.
with urllib.request.build_opener(NoRedirect()).open(request, timeout=20) as response:
require(response.status == 204, 'dispatch was not accepted')
print('Dispatched producer run/attempt to the release-ref validator; not a signing result.')
+16 -2
View File
@@ -34,12 +34,26 @@ jobs:
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@bf94b15b708089b95c4e2d1c978e66ecf1f2f4f3
with:
tooling-revision: be00e5ccd18b68e950c8a08532f2230e7c3d0cba
tooling-revision: bf94b15b708089b95c4e2d1c978e66ecf1f2f4f3
app-name: deckcraft
producer_run_id: ${{ inputs.producer_run_id }}
producer_run_attempt: ${{ inputs.producer_run_attempt }}
secrets:
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
AZURE_SIGNING_ENDPOINT: ${{ secrets.AZURE_SIGNING_ENDPOINT }}
AZURE_SIGNING_ACCOUNT: ${{ secrets.AZURE_SIGNING_ACCOUNT }}
AZURE_CERT_PROFILE: ${{ secrets.AZURE_CERT_PROFILE }}
LINUX_SIGNING_KEY: ${{ secrets.LINUX_SIGNING_KEY }}
# 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.
+6 -4
View File
@@ -1,8 +1,10 @@
name: DeckCraft unsigned nightly
# 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).
# Runs on the reviewed nightly schedule (01:00 UTC) and for supervised manual runs
# by the reviewed manual actors. Completed scheduled runs are forwarded by nightly-dispatch.yml.
on:
schedule:
- cron: '0 1 * * *'
workflow_dispatch:
permissions:
@@ -22,9 +24,9 @@ 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@bf94b15b708089b95c4e2d1c978e66ecf1f2f4f3
with:
tooling-revision: be00e5ccd18b68e950c8a08532f2230e7c3d0cba
tooling-revision: bf94b15b708089b95c4e2d1c978e66ecf1f2f4f3
app-name: deckcraft
manual-actors: '["bflatastic","dylanmtaylor","echelon","FredApps","skylartaylor"]'
craft-fonts-ref: 37827adc41fd165f9a9234ac40f94dbad353aa69
+20
View File
@@ -0,0 +1,20 @@
name: Notify Services on Release Change
on:
release:
types:
- published
- unpublished
- created
- edited
- deleted
- prereleased
- released
permissions: {}
jobs:
notify:
uses: storytold/craft-common-actions/.github/workflows/notify-services.yml@main
secrets:
ARTCRAFT_SERVICES_DISPATCH_TOKEN: ${{ secrets.ARTCRAFT_SERVICES_DISPATCH_TOKEN }}
+1
View File
@@ -75,5 +75,6 @@ DeckCraft is a pure-Rust presentation application (PowerPoint parity target) for
- Attribution: `ATTRIBUTION.md` (a row per file under `assets/`, `docs/images/`, `docs/brand/`; `cargo xtask assets` checks it) and `NOTICE`. The ArtCraft name and logos in `docs/brand/` are trademarks (`docs/brand/LICENSE-brand.txt`).
- Fonts come from craft-fonts: builds embed `fonts/manifest.txt` and `fonts/latin-manifest.txt` from `CRAFT_FONTS_DIR`; `.cargo/config.toml` points it at `../craft-fonts` when that exists. `crates/fonts/build.rs` excludes Adobe's Source Sans/Serif/Han families and Noto CJK.
- Run: `cargo run --release -p deckcraft -- --sample --control 7990` starts the app with a sample deck and the control channel (JSON lines on `127.0.0.1:7990`; methods in `crates/ui-egui/src/control.rs`, docs in `docs/control-protocol.md`). Headless: `deckcraft-cli render --sample --all --scale 1 out/` and `deckcraft-cli run --sample --cmd ... --export out.png`. MCP: `deckcraft-cli mcp --automation-read-root DIR --automation-write-root DIR` confines the headless server to those folders; `deckcraft-cli mcp --connect 7990` drives a running app, which the roots do not confine. See `docs/mcp.md`.
- Headless column ([RFC-0052](https://github.com/storytold/craft-contrib/blob/main/rfcs/0052-headless-reach.md)): `docs/parity-checklist.md` rows may carry a fifth `Headless` cell, `no (<reach>)` or `partial (<reach>)` with a reach of `window`, `os` or `engine-gap`; without one a row is `unknown`, and `cargo xtask parity` counts them in the summary. The rows name no command ids yet, so the check refuses `yes`: adding the engine command id a row needs comes first (LightCraft's `cmd:<id>` is the model).
- Notes and progress: `plan/` is an optional gitignored notebook. Committed: `ROADMAP.md` (progress log), `docs/gaps.md` (work list), `docs/roadmap.md`, `docs/parity-checklist.md` (`cargo xtask parity` regenerates its summary), `docs/target-app-parity.md`, `docs/architecture.md`.
- Contributor credits: `docs/contributors.md`.
+76 -1
View File
@@ -162,7 +162,19 @@ fn entries_stay_inside(root: &Path) -> Result<(), String> {
};
for entry in entries {
let entry = entry.map_err(|e| format!("cannot inspect the nightly profile: {e}"))?;
private_subdirectory(root, entry.file_name(), "profile entry")?;
let path = entry.path();
let metadata = std::fs::symlink_metadata(&path).map_err(|e| format!("cannot inspect the nightly profile: {e}"))?;
// Settings and session state are ordinary files, not directories. Keep the existing
// directory-boundary check for folders (including the known folder-only entries).
let folder_only = PROFILE_FOLDERS.iter().any(|name| entry.file_name().eq_ignore_ascii_case(name));
if metadata.is_file() {
if folder_only {
return Err(format!("the nightly {} must be a directory", entry.file_name().to_string_lossy()));
}
private_regular_file(&path, &metadata)?;
} else {
private_subdirectory(root, entry.file_name(), "profile entry")?;
}
}
// The one nested file Nightly writes itself: a link at Dictionaries/user.dic would append
// "add to dictionary" words to the stable app's file instead of this profile's.
@@ -170,6 +182,42 @@ fn entries_stay_inside(root: &Path) -> Result<(), String> {
Ok(())
}
/// Persisted files must have their own ordinary file identity, not an alias to other data.
fn private_regular_file(path: &Path, metadata: &std::fs::Metadata) -> Result<(), String> {
#[cfg(unix)]
{
use std::os::unix::fs::MetadataExt as _;
if metadata.nlink() != 1 {
return Err("the nightly profile file must not be shared".into());
}
}
#[cfg(windows)]
{
use winsafe::{HFILE, co};
let (file, _) = HFILE::CreateFile(
path.to_str().ok_or("the nightly profile file path is not textual")?,
co::GENERIC::default(),
Some(co::FILE_SHARE::READ | co::FILE_SHARE::WRITE | co::FILE_SHARE::DELETE),
None,
co::DISPOSITION::OPEN_EXISTING,
co::FILE_ATTRIBUTE::NORMAL,
Some(co::FILE_FLAG::OPEN_REPARSE_POINT),
None,
None,
)
.map_err(|e| e.to_string())?;
let info = file.GetFileInformationByHandle().map_err(|e| e.to_string())?;
if info.dwFileAttributes.has(co::FILE_ATTRIBUTE::REPARSE_POINT | co::FILE_ATTRIBUTE::DIRECTORY) {
return Err("the nightly profile file must not be an alias or directory".into());
}
if info.nNumberOfLinks != 1 {
return Err("the nightly profile file must not be shared".into());
}
}
let _ = (path, metadata);
Ok(())
}
/// Recognise a portable data namespace in both the supplied and resolved path. DeckCraft ships no
/// portable package, so this only refuses a hand-made copy; it is not an inventory of arbitrary
/// custom Stable overrides or a Launcher ownership proof.
@@ -246,6 +294,8 @@ fn validate_for(
Ok(confirmed)
}
const PROFILE_FOLDERS: [&str; 3] = ["Recovery", "Dictionaries", crate::logging::LOG_DIR];
#[cfg(test)]
mod tests {
use super::*;
@@ -444,6 +494,31 @@ mod tests {
assert_eq!(std::fs::read_dir(nightly).unwrap().count(), 0);
}
#[test]
fn nightly_profile_reopens_after_saving_settings_and_session_state() {
let fixture = Fixture::new();
for platform in [Platform::Mac, Platform::Linux, Platform::Windows] {
let private = fixture.root.join(format!("nightly-reopen-{platform:?}"));
assert_eq!(fixture.check(platform, &private).unwrap(), private);
for name in ["ui.json", "prefs.json", "nightly-session.lock", "nightly-session.json"] {
std::fs::write(private.join(name), b"saved profile data").unwrap();
}
for name in PROFILE_FOLDERS {
std::fs::create_dir(private.join(name)).unwrap();
}
assert_eq!(fixture.check(platform, &private).unwrap(), private);
assert_eq!(std::fs::read(private.join("ui.json")).unwrap(), b"saved profile data");
for name in PROFILE_FOLDERS {
let path = private.join(name);
std::fs::remove_dir(&path).unwrap();
std::fs::write(&path, b"not a directory").unwrap();
assert!(fixture.check(platform, &private).is_err(), "{name} must stay a directory");
std::fs::remove_file(&path).unwrap();
std::fs::create_dir(&path).unwrap();
}
}
}
#[test]
fn mac_fences_only_app_library_subtrees_and_the_entire_bundle() {
let mut fixture = Fixture::new();
+4 -2
View File
@@ -46,10 +46,12 @@ The summary between `<!-- SUMMARY -->
Open P0 items: Contextual tabs (Shape Format, Picture Format, Table Design/Layout, Chart Design), Export to PDF (slides, notes pages, handouts; text layer, links, bookmarks; vector artwork pending), Format Shape pane, Font, size, bold, italic, underline, strikethrough (only Regular/Bold/Italic faces, #69), Edit chart data, Crop (and crop to shape, aspect ratio), Paste image from clipboard (fails on Windows, #1414, re-test after the 2026-11-01 OS-clipboard fix), Audio/video playback in the show (WMA/WMV not decodable yet), Animation pane (reorder, timing), Presenter view (notes, next slide, timer), macOS, Windows, Linux builds.
**Headless ([RFC-0052](https://github.com/storytold/craft-contrib/blob/main/rfcs/0052-headless-reach.md)): 0 yes, 0 no (window 0, os 0, engine-gap 0), 0 partial, 191 unknown.** The rows name no command ids yet, so none can be `yes`. A row may add a fifth `Headless` cell, `no (<reach>)` or `partial (<reach>)` with a reach of `window`, `os` or `engine-gap`; a row without one is `unknown`.
## Rows
| Area | Feature | Priority | Status |
|---|---|---|---|
| Area | Feature | Priority | Status | Headless |
|---|---|---|---|---|
| Application shell | Start screen (new, templates/themes, recent) | P0 | D |
| Application shell | Ribbon with Home/Insert/Draw/Design/Transitions/Animations/Slide Show/Review/View tabs | P0 | D |
| Application shell | Contextual tabs (Shape Format, Picture Format, Table Design/Layout, Chart Design) | P0 | P |
+3 -2
View File
@@ -33,11 +33,12 @@ OUTPUT="$DIST/deckcraft-$VERSION-macos-aarch64-nightly.zip"
nightly_compile_gui
APP="$NIGHTLY_WORK/stage/$MAC_NIGHTLY_APP"
mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources"
mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources/docs"
cp "$NIGHTLY_GUI" "$APP/Contents/MacOS/DeckCraft"
chmod 755 "$APP/Contents/MacOS/DeckCraft"
cp "$ROOT/assets/app-icon/deckcraft-nightly.icns" "$APP/Contents/Resources/deckcraft-nightly.icns"
nightly_copy_notices "$APP/Contents/Resources"
# Launcher admits notices under Resources/docs, not beside the icon.
nightly_copy_notices "$APP/Contents/Resources/docs"
# The private mktemp cwd is the helper authority root: stage the template inside it.
cp "$HERE/Info.plist.in" "$NIGHTLY_WORK/Info.plist.in"
(cd "$NIGHTLY_WORK" && python3 "$HERE/nightly_plist.py" --template Info.plist.in \
+82 -2
View File
@@ -1,8 +1,8 @@
#!/usr/bin/env python3
"""The macOS Nightly signing and verification scripts, run on any POSIX host against generated
fixtures and stand-in Apple tools (codesign, notarytool, stapler, spctl, security, ditto, plutil,
lipo) that log their arguments. This proves the scripts' order, refusals and cleanup; it is not a
real signature, notarization or Mac run."""
lipo) that log their arguments. The unsigned producer also runs with a stub GUI build. These
check the scripts and bundle layout, not native signing, notarization or Mac execution."""
import base64
import importlib.util
import json
@@ -27,6 +27,8 @@ COMMIT = "b" * 40
VERSION = "0.23.1-nightly.20261123.4567.1.g" + COMMIT[:12]
ASSET = f"deckcraft-{VERSION}-macos-aarch64-nightly.zip"
APP = "DeckCraft Nightly.app"
APP_NOTICES = ("README.md", "LICENSE-MIT", "LICENSE-APACHE", "NOTICE", "ATTRIBUTION.md")
OPTIONAL_NOTICES = ("LICENSE", "COPYRIGHT")
TEAM = "ABCDE12345"
IDENTITY = "0123456789ABCDEF0123456789ABCDEF01234567"
SECRETS = {
@@ -183,6 +185,50 @@ class Fixture:
z.writestr(info, b"" if path.is_dir() else path.read_bytes())
return self.input
def package(self, font_licences):
"""Drive the real producer from a clean fixture checkout, without Cargo or Apple tools."""
source = HERE.parents[1]
checkout = self.root / "source"
checkout.mkdir()
notices = APP_NOTICES + tuple(name for name in OPTIONAL_NOTICES if (source / name).is_file())
for relative in (*notices, "packaging/common.sh", "packaging/nightly-common.sh", "packaging/nightly_paths.py",
"packaging/macos/nightly.sh", "packaging/macos/nightly-lib.sh",
"packaging/macos/Info.plist.in", "packaging/macos/nightly_plist.py",
"assets/app-icon/deckcraft-nightly.icns"):
target = checkout / relative
target.parent.mkdir(parents=True, exist_ok=True)
shutil.copyfile(source / relative, target)
env = self.env(**dict.fromkeys(SECRETS))
def git(*args):
return subprocess.run(["git", "-c", "core.hooksPath=/dev/null", "-c", "commit.gpgsign=false", *args],
cwd=checkout, env=env, check=True, capture_output=True, text=True, timeout=30).stdout
git("init", "-q")
git("add", "--", ".")
git("-c", "user.name=Fixture", "-c", "[email protected]", "commit", "-qm", "Packaging fixture")
commit = git("rev-parse", "HEAD").strip()
version = VERSION[:-12] + commit[:12]
# Generated licence text exercises the copier without depending on a font checkout.
fonts = self.root / "craft-fonts"
for family, data in font_licences.items():
licence = fonts / "fonts" / family / "OFL.txt"
licence.parent.mkdir(parents=True)
licence.write_bytes(data)
# The existing cargo stub fails for every invocation. Only this producer fixture emits a GUI.
(self.bin / "cargo").write_text(
'#!/bin/sh\nset -eu\n'
'gui="$CARGO_TARGET_DIR/aarch64-apple-darwin/release/deckcraft"\n'
'mkdir -p "$(dirname "$gui")"\n'
"printf \"#!/bin/sh\\necho 'DeckCraft %s (nightly-v1)'\\n\" \"$DECKCRAFT_VERSION\" >\"$gui\"\n",
)
result = self.run(checkout / "packaging/macos/nightly.sh", "--arch", "aarch64", **dict.fromkeys(SECRETS),
DIST=str(self.dist), CARGO_TARGET_DIR=str(self.root / "target"), CRAFT_FONTS_DIR=str(fonts),
DECKCRAFT_BUILD_CHANNEL="nightly-v1", DECKCRAFT_VERSION=version,
DECKCRAFT_BUILD_SHA=commit, DECKCRAFT_BUILD_DATE="2026-11-23")
assert result.returncode == 0, result.stdout
return self.dist / ASSET.replace(VERSION, version)
def env(self, **changes):
env = {"PATH": f"{self.bin}:{os.environ['PATH']}", "HOME": str(self.root), "SHIM_LOG": str(self.log),
"SHIM_TEAM": TEAM, "SHIM_IDENTITY": IDENTITY, "RUNNER_TEMP": str(self.temp), **SECRETS}
@@ -410,6 +456,40 @@ class Verify(unittest.TestCase):
class Build(unittest.TestCase):
def test_unsigned_archive_has_launcher_layout_and_keeps_all_notices(self):
f = Fixture(self)
fonts = {"fixture-one": b"generated font notice one", "fixture-two": b"generated font notice two"}
archive = f.package(fonts)
source = HERE.parents[1]
resources = f"{APP}/Contents/Resources"
icon = "deckcraft-nightly.icns"
notice_files = {name: (source / name).read_bytes() for name in APP_NOTICES}
notice_files.update({name: (source / name).read_bytes() for name in OPTIONAL_NOTICES if (source / name).is_file()})
notice_files.update({f"OFL-{family}.txt": data for family, data in fonts.items()})
# Shipped Launcher v0.20.3 accepts these leaves only in Resources/docs, except for the root icon.
expected_files = {f"{resources}/docs/{name}": data for name, data in notice_files.items()}
expected_files[f"{resources}/{icon}"] = (source / "assets/app-icon" / icon).read_bytes()
contents = f"{APP}/Contents"
gui = f"{contents}/MacOS/DeckCraft"
with zipfile.ZipFile(archive) as zipped:
entries = zipped.infolist()
names = {entry.filename for entry in entries}
self.assertEqual(len(entries), len({name.casefold() for name in names}), "unique paths, ignoring case")
self.assertEqual({entry.filename for entry in entries if not entry.is_dir()},
set(expected_files) | {gui, f"{contents}/Info.plist", f"{contents}/PkgInfo"})
self.assertTrue({entry.filename for entry in entries if entry.is_dir()} <= {
f"{APP}/", f"{contents}/", f"{contents}/MacOS/", f"{resources}/", f"{resources}/docs/"})
for path, data in expected_files.items():
with self.subTest(path=path):
self.assertEqual(zipped.read(path), data)
mode = zipped.getinfo(path).external_attr >> 16
self.assertTrue(stat.S_ISREG(mode))
self.assertFalse(mode & 0o111)
mode = zipped.getinfo(gui).external_attr >> 16
self.assertTrue(stat.S_ISREG(mode) and mode & stat.S_IXUSR)
result = f.run("nightly-verify.sh", "--input", archive, "--expect", "unsigned", **dict.fromkeys(SECRETS))
self.assertEqual(result.returncode, 0, result.stdout)
def test_compilation_refuses_signing_material_before_building(self):
f = Fixture(self)
for name in ("APPLE_CERTIFICATE", "APPLE_PASSWORD", "MACOS_SIGN_IDENTITY", "WINDOWS_CERTIFICATE", "AZURE_CLIENT_SECRET", "LINUX_SIGNING_KEY"):
+125 -9
View File
@@ -13,6 +13,12 @@ INSTALLED_POLICY = ROOT / ".github/nightly-signing-policy.json"
SIGNER_BRANCH = "nightly-signer"
NIGHTLY_PLATFORMS = ("windows-x86_64", "linux-x86_64", "macos-aarch64")
# The pinned shared registry enables Windows, Linux and macOS for DeckCraft.
SIGNER_SECRETS = {
"AZURE_CERT_PROFILE", "AZURE_CLIENT_ID", "AZURE_CLIENT_SECRET", "AZURE_SIGNING_ACCOUNT",
"AZURE_SIGNING_ENDPOINT", "AZURE_TENANT_ID", "LINUX_SIGNING_KEY", "APPLE_CERTIFICATE",
"APPLE_CERTIFICATE_PASSWORD", "APPLE_ID", "APPLE_PASSWORD", "APPLE_TEAM_ID", "KEYCHAIN_PASSWORD",
}
# Each platform's one trust field in policy v3, and the public stable identity it must name.
NIGHTLY_TRUST = {
"windows-x86_64": ("publisher_subject",
@@ -46,6 +52,49 @@ def assert_nightly_serialization(source):
raise ValueError("nightly serialization must use its stable group and no cancellation")
def caller_entries(lines, indent):
"""Split the callers' plain YAML block entries; refuse other forms at checked levels."""
entries = {}
children = None
for line in lines:
if children is not None and line.startswith(" " * (indent + 1)):
children.append(line)
continue
row = re.fullmatch(r" " * indent + r"([A-Za-z0-9_-]+):(?: (.*))?", line)
if row is None or row[1] in entries:
raise ValueError("malformed or duplicate caller mapping entry")
children = []
entries[row[1]] = row[2], children
return entries
def assert_caller_secrets(source, job_name, names):
"""Check the actual caller's root, job and secret blocks without a YAML dependency."""
lines = [line for line in source.splitlines() if line.strip() and not line.lstrip().startswith("#")]
root = caller_entries(lines, 0)
job_marker, job_lines = root.pop("jobs", (None, []))
jobs = caller_entries(job_lines, 2)
if job_marker is not None or set(jobs) != {job_name} or jobs[job_name][0] is not None:
raise ValueError("the caller must have one plain job block")
job = caller_entries(jobs[job_name][1], 4)
if "environment" in job or "environment" in root or "secrets" in root:
raise ValueError("only the native callee may bind the environment")
if names:
if "secrets" not in job:
raise ValueError("signer requires an explicit target-specific secret map")
mode, secret_lines = job.pop("secrets")
expected = {name: ("${{ secrets." + name + " }}", []) for name in names}
if mode is not None or caller_entries(secret_lines, 6) != expected:
raise ValueError("signer must forward exactly the reviewed same-name secret references")
elif "secrets" in job:
raise ValueError("unsigned caller must not pass secrets")
for value, children in (*root.values(), *job.values()):
outside_map = "\n".join([value or "", *children])
# Scan all remaining text: quoted braces can appear before a secret reference.
if re.search(r"(?im)^\s*environment:|\bsecrets\b", outside_map):
raise ValueError("secret bindings belong only in the signer map")
def job_conditions(jobs):
"""Each job-level `if:` as (block indicator or None, the whole expression YAML would read)."""
lines = jobs.splitlines()
@@ -135,7 +184,7 @@ class TrustedSourcePreparation(unittest.TestCase):
producer_platforms(source.replace(" " + current + "\n", ""))
def test_continuation_lines_of_any_scalar_form_reach_the_guard_checks(self):
for name in ("nightly.yml", "nightly-sign.yml"):
for name in ("nightly.yml", "nightly-sign.yml", "nightly-dispatch.yml"):
source = (ROOT / ".github/workflows" / name).read_text()
expected = NightlyEnabledCallers.GUARDS[name]
guard = re.search(r"(?m)^ if: >-\n(?: [^\n]*\n)+", source)[0]
@@ -145,15 +194,39 @@ class TrustedSourcePreparation(unittest.TestCase):
(indicator, expression), = job_conditions(jobs)
self.assertFalse(indicator == ">-" and " ".join(expression.split()) == expected)
def test_no_nightly_schedule_is_registered(self):
for name, event in (("nightly.yml", "workflow_dispatch"),
("nightly-sign.yml", "workflow_dispatch")):
def test_nightly_triggers_match_reviewed_schedule_and_dispatch(self):
expected = {
"nightly.yml": [" schedule:", " workflow_dispatch:"],
"nightly-sign.yml": [" workflow_dispatch:"],
"nightly-dispatch.yml": [" workflow_run:"],
}
for name, expected_triggers in expected.items():
source = (ROOT / ".github/workflows" / name).read_text()
events = source.split("\non:\n", 1)[1].split("\npermissions:", 1)[0]
triggers = [line for line in events.splitlines() if line.startswith(" ")
and not line.startswith(" ") and line.strip() and not line.lstrip().startswith("#")]
with self.subTest(workflow=name):
self.assertEqual(triggers, [f" {event}:"], "schedule/activation needs explicit review")
self.assertEqual(triggers, expected_triggers, "schedule/activation needs explicit review")
producer = (ROOT / ".github/workflows/nightly.yml").read_text()
self.assertEqual(re.findall(r"(?m)^ - cron: (.+)$", producer), ["'0 1 * * *'"],
"nightly schedule must stay pinned to 01:00 UTC")
producer_name = re.findall(r"(?m)^name: (.+)$", producer)
dispatch = (ROOT / ".github/workflows/nightly-dispatch.yml").read_text()
self.assertEqual(producer_name, ["DeckCraft unsigned nightly"])
self.assertIn(f" workflows: [{producer_name[0]}]\n", dispatch)
self.assertIn(" types: [completed]\n", dispatch)
self.assertIn(" branches: [main]\n", dispatch)
def test_dispatch_workflow_stays_transport_only(self):
dispatch = (ROOT / ".github/workflows/nightly-dispatch.yml").read_text()
assert_caller_secrets(dispatch, "dispatch", set())
self.assertIn("\npermissions: {}\n", dispatch)
self.assertNotRegex(dispatch, r"(?m)^\s*(?:-\s*)?uses:")
self.assertIn(f"'ref': 'refs/heads/{SIGNER_BRANCH}'", dispatch)
self.assertIn("https://api.github.com/repos/storytold/deckcraft/actions/workflows/nightly-sign.yml/dispatches",
dispatch)
self.assertIn("require(producer.get('event') == 'schedule'", dispatch)
self.assertIn("require(type(attempt) is int and attempt == 1", dispatch)
def test_signer_serialization_contract_is_enforced(self):
assert_nightly_serialization((ROOT / ".github/workflows/nightly-sign.yml").read_text())
@@ -183,15 +256,56 @@ class TrustedSourcePreparation(unittest.TestCase):
assert_nightly_serialization(source.replace(old, new))
def test_no_cache_actions_or_cache_setup_options_in_app_trusted_closure(self):
for name in ("nightly.yml", "nightly-sign.yml"):
for name in ("nightly.yml", "nightly-sign.yml", "nightly-dispatch.yml"):
source = (ROOT / ".github/workflows" / name).read_text()
executable = "\n".join(line for line in source.splitlines()
if not line.lstrip().startswith("#"))
with self.subTest(workflow=name):
self.assertNotRegex(executable, r"(?im)^\s*(?:-\s*)?uses:\s*[^\n]*cache")
self.assertNotRegex(executable, r"(?im)^\s*[^\s:#]*cache[^\s:#]*:")
self.assertNotRegex(executable, r"(?im)^\s*(?:environment|secrets):")
self.assertNotIn("secrets.", executable)
def test_signer_forwards_exactly_the_reviewed_secret_names(self):
signer = (ROOT / ".github/workflows/nightly-sign.yml").read_text()
assert_caller_secrets(signer, "release", SIGNER_SECRETS)
def test_signer_refuses_missing_extra_alias_duplicate_or_inherited_secrets(self):
signer = (ROOT / ".github/workflows/nightly-sign.yml").read_text()
header = " secrets:\n"
linux = " LINUX_SIGNING_KEY: ${{ secrets.LINUX_SIGNING_KEY }}\n"
self.assertIn(linux, signer)
mutations = {
"missing name": signer.replace(linux, ""),
"extra name": signer + " EXTRA: ${{ secrets.EXTRA }}\n",
"renamed source": signer.replace(linux, linux.replace("secrets.LINUX_SIGNING_KEY", "secrets.APPLE_ID")),
"duplicate name": signer.replace(linux, linux + linux),
"duplicate map": signer + header + linux,
"quoted duplicate map": signer + ' "secrets": inherit\n',
"inherit": signer.split(header)[0] + " secrets: inherit\n",
"yaml alias": signer.replace(linux, " LINUX_SIGNING_KEY: *other\n"),
"yaml merge": signer + " <<: *other\n",
"environment": signer + " environment: release\n",
"secret outside map": signer.replace("${{ inputs.producer_run_id }}", "${{ secrets.APPLE_ID }}"),
}
for change, source in mutations.items():
with self.subTest(change=change), self.assertRaises(ValueError):
assert_caller_secrets(source, "release", SIGNER_SECRETS)
def test_unsigned_caller_has_no_secrets(self):
producer = (ROOT / ".github/workflows/nightly.yml").read_text()
assert_caller_secrets(producer, "unsigned", set())
for suffix in (" secrets: {}\n", " secrets: inherit\n",
" secrets:\n EXTRA: ${{ secrets.EXTRA }}\n",
" extra: ${{ secrets['EXTRA'] }}\n", " secrets: inherit\n"):
with self.subTest(suffix=suffix), self.assertRaises(ValueError):
assert_caller_secrets(producer + suffix, "unsigned", set())
def test_unsigned_caller_refuses_secret_after_format_brace(self):
producer = (ROOT / ".github/workflows/nightly.yml").read_text()
# This inert fixture is never dispatched; the brace is part of the format string.
env = "env:\n EXAMPLE: ${{ format('value {0}', secrets.EXAMPLE_ONLY) }}\n\n"
source = producer.replace("jobs:\n", env + "jobs:\n", 1)
with self.assertRaisesRegex(ValueError, "secret bindings belong only in the signer map"):
assert_caller_secrets(source, "unsigned", set())
def test_both_callers_use_one_shared_pin_in_uses_and_tooling_revision(self):
pins = set()
@@ -217,6 +331,7 @@ class NightlyEnabledCallers(unittest.TestCase):
"github.event_name == 'workflow_dispatch')",
"nightly-sign.yml": "github.repository == 'storytold/deckcraft' && github.event_name == 'workflow_dispatch' && "
"github.ref == 'refs/heads/" + SIGNER_BRANCH + "' && github.ref_type == 'branch'",
"nightly-dispatch.yml": "github.repository == 'storytold/deckcraft' && github.event_name == 'workflow_run'",
}
def test_enabled_jobs_keep_exact_context_guards(self):
@@ -233,7 +348,8 @@ class NightlyEnabledCallers(unittest.TestCase):
source = (ROOT / ".github/workflows/nightly.yml").read_text()
policy = json.loads(INSTALLED_POLICY.read_text())
self.assertEqual(reviewed_manual_actors(source, policy), RELEASE_MANAGERS)
self.assertEqual(policy["automatic_signer_actors"], [], "no automatic signer without a schedule")
self.assertEqual(policy["automatic_signer_actors"], ["github-actions[bot]"],
"automatic signer actor must be github-actions[bot]")
def test_an_actor_outside_the_release_managers_is_refused(self):
source = (ROOT / ".github/workflows/nightly.yml").read_text()
+71 -4
View File
@@ -6,14 +6,21 @@ use std::path::Path;
const START: &str = "<!-- SUMMARY -->";
const ROWS: &str = "\n## Rows";
/// The cells of a table line that is a scored row: `Area | Feature | Priority | Status`, with an
/// optional fifth `Headless` cell (RFC-0052).
fn row_cells(l: &str) -> Option<Vec<&str>> {
let cells: Vec<&str> = l.trim().trim_matches('|').split('|').map(str::trim).collect();
let scored = matches!(cells.len(), 4 | 5) && matches!(cells[2], "P0" | "P1" | "P2") && matches!(cells[3], "D" | "P" | "M");
scored.then_some(cells)
}
/// (area, feature, priority 0–2, value 0 / 0.5 / 1) for each table row.
pub fn rows(text: &str) -> Vec<(String, String, u8, f64)> {
let mut out = Vec::new();
for l in text.lines() {
let cells: Vec<&str> = l.trim().trim_matches('|').split('|').map(str::trim).collect();
if cells.len() != 4 {
let Some(cells) = row_cells(l) else {
continue;
}
};
let pri = match cells[2] {
"P0" => 0,
"P1" => 1,
@@ -31,6 +38,53 @@ pub fn rows(text: &str) -> Vec<(String, String, u8, f64)> {
out
}
/// A row's RFC-0052 `headless:` cell: empty or `unknown`, `no (<reach>)` or `partial (<reach>)` with
/// a reach of `window`, `os` or `engine-gap`. The rows name no command ids, so nothing can check a
/// `yes`: it is refused until a row cites the engine command that does the feature.
pub fn headless_cell(cell: Option<&str>) -> Result<(&'static str, Option<&'static str>), String> {
let c = cell.unwrap_or("").trim();
if c.is_empty() || c == "unknown" {
return Ok(("unknown", None));
}
let (value, rest) = c.split_once(' ').unwrap_or((c, ""));
let value = match value {
"no" => "no",
"partial" => "partial",
"yes" => return Err(format!("headless `{c}`: a row is `yes` only once it names the engine command id that does it (RFC-0052)")),
_ => return Err(format!("headless `{c}` is not unknown, `no (<reach>)` or `partial (<reach>)`")),
};
let reach = match rest.trim().trim_start_matches('(').trim_end_matches(')') {
"window" => "window",
"os" => "os",
"engine-gap" => "engine-gap",
r => return Err(format!("headless `{c}`: reach `{r}` is not window, os or engine-gap")),
};
Ok((value, Some(reach)))
}
/// Every row's RFC-0052 value, or the first bad cell.
pub fn headless(text: &str) -> Result<Vec<(&'static str, Option<&'static str>)>, String> {
text.lines().filter_map(row_cells).map(|c| headless_cell(c.get(4).copied()).map_err(|e| format!("{}: {e}", c[1]))).collect()
}
/// The RFC-0052 summary line.
pub fn headless_line(values: &[(&str, Option<&str>)]) -> String {
let count = |v: &str| values.iter().filter(|h| h.0 == v).count();
let no = |r: &str| values.iter().filter(|h| h.0 == "no" && h.1 == Some(r)).count();
format!(
"**Headless ([RFC-0052](https://github.com/storytold/craft-contrib/blob/main/rfcs/0052-headless-reach.md)): {} yes, {} no (window {}, os {}, engine-gap {}), {} partial, {} unknown.** \
The rows name no command ids yet, so none can be `yes`. A row may add a fifth `Headless` cell, `no (<reach>)` or \
`partial (<reach>)` with a reach of `window`, `os` or `engine-gap`; a row without one is `unknown`.\n",
count("yes"),
count("no"),
no("window"),
no("os"),
no("engine-gap"),
count("partial"),
count("unknown")
)
}
fn weight(p: u8) -> f64 {
[3.0, 2.0, 1.0][p as usize]
}
@@ -75,7 +129,7 @@ pub fn run(root: &Path) -> Result<(), String> {
return Err("docs/parity-checklist.md needs a `<!-- SUMMARY -->` marker before `## Rows`".into());
};
let rows = rows(&text[b..]);
let s = summary(&rows);
let s = format!("{}\n{}", summary(&rows), headless_line(&headless(&text[b..])?));
let new = format!("{}{START}\n{s}{}", &text[..a], &text[b..]);
std::fs::write(&path, new).map_err(|e| e.to_string())?;
print!("{s}");
@@ -96,4 +150,17 @@ mod tests {
assert!(s.contains("**Weighted breadth parity: 67%**"), "{s}");
assert!(s.contains("Open P0 items: ."));
}
#[test]
fn headless_cells_default_to_unknown_and_refuse_yes() {
let t = "| A | x | P0 | D |\n| A | y | P1 | M | no (window) |\n| B | z | P2 | P | partial (engine-gap) |\n| B | w | P2 | D | unknown |\n";
let v = headless(t).unwrap_or_default();
assert_eq!(v, [("unknown", None), ("no", Some("window")), ("partial", Some("engine-gap")), ("unknown", None)]);
assert_eq!(rows(t).len(), 4, "a fifth cell keeps the row scored");
let line = headless_line(&v);
assert!(line.contains("0 yes, 1 no (window 1, os 0, engine-gap 0), 1 partial, 2 unknown"), "{line}");
for bad in ["yes", "yes (cmd:a.b)", "no", "no (desk)", "maybe (os)"] {
assert!(headless(&format!("| A | x | P0 | D | {bad} |\n")).is_err(), "{bad}");
}
}
}