Skip to content

The open-source full-stack studio for Opus 5.5 motion video. Reverse engineering for any video. Code video with HTML: recreate, edit and render. BYOA + BYOK · Motion.md · Images, Video, Music & Voice.

fix(ci): defer Motion test promotion until DEV registry acceptance

罗高be4ff797aa03
diff --git a/.github/scripts/motion-registry-smoke.mjs b/.github/scripts/motion-registry-smoke.mjs
index 679dc28f..be099b08 100644
--- a/.github/scripts/motion-registry-smoke.mjs
+++ b/.github/scripts/motion-registry-smoke.mjs
@@ -52,7 +52,7 @@ export async function registrySmoke(directory) {
await checkpoint(phase);
try {
const work = await mkdtemp(path.join(os.tmpdir(), 'om-registry-')), env = consumerEnvironment(work);
- for (const file of ['user.npmrc', 'global.npmrc']) await writeFile(path.join(work, file), '');
+ for (const name of ['user.npmrc', 'global.npmrc']) await writeFile(path.join(work, name), '');
const project = path.join(work, 'project'), host = path.join(work, 'host');
await mkdir(project); await mkdir(env.CODEX_HOME);
await writeFile(path.join(env.CODEX_HOME, 'config.toml'), '[mcp_servers.unrelated]\ncommand = "keep-this-server"\n');
@@ -84,6 +84,11 @@ export async function registrySmoke(directory) {
assert.equal(first.appRoot, second.appRoot); assert.equal((await readdir(path.join(home, 'apps'))).length, 1);
assert.match(await readFile(path.join(env.CODEX_HOME, 'config.toml'), 'utf8'), /keep-this-server/);
const manifest = JSON.parse(await readFile(path.join(directory, 'release-npm.json')));
+ assert.equal(manifest.templateEnvironment, 'dev');
+ const state = JSON.parse(await readFile(path.join(home, 'install.json')));
+ assert.equal(state.templateEnvironment, manifest.templateEnvironment);
+ const templateConfig = JSON.parse(await readFile(path.join(first.appRoot, 'shared/template-config.json')));
+ assert.equal(templateConfig.environment, manifest.templateEnvironment);
for (const skill of manifest.skills) await access(path.join(skills, 'openmotion/skills', skill, 'SKILL.md'));
console.log('Preparing the checksum-pinned browser, FFmpeg and ffprobe');
await checkpoint('native-prepare');
@@ -94,7 +99,7 @@ export async function registrySmoke(directory) {
await checkpoint('mcp-discovery');
await discover(installed.transport, env, c.version, manifest.mcp.tools);
const report = { status: 'passed', platform, version: c.version, sourceCommit: c.sourceCommit, tgzSHA256: c.tgzSHA256,
- node: process.version, codex: '0.166.0', registryColdInstall: 'passed', repeatSetup: 'passed', unrelatedSettings: 'preserved',
+ node: process.version, codex: '0.166.0', templateEnvironment: templateConfig.environment, registryColdInstall: 'passed', repeatSetup: 'passed', unrelatedSettings: 'preserved',
nativePreparation: 'passed', mcpTools: manifest.mcp.tools.length, skills: manifest.skills.length, resources: 'passed',
realModelTurn: 'not-run', humanPlayback: 'not-run', windowsDesktopAcceptance: 'not-run' };
await writeJSON(file, report); return report;
diff --git a/.github/scripts/motion-release.mjs b/.github/scripts/motion-release.mjs
index f0749db2..fa8561de 100644
--- a/.github/scripts/motion-release.mjs
+++ b/.github/scripts/motion-release.mjs
@@ -51,7 +51,7 @@ export async function sealCandidate(build, output, source, env = process.env) {
const manifest = await json(path.join(build, 'release-npm.json'));
assert.equal(manifest.commit, (await runFile('git', ['rev-parse', 'HEAD'], { cwd: source })).trim());
assert.equal(manifest.commit, env.MOTION_SOURCE_SHA); assert.equal(manifest.version, env.MOTION_VERSION);
- assert(manifest.version.includes('-test.') && manifest.templateEnvironment === 'prod');
+ assert(manifest.version.includes('-test.') && manifest.templateEnvironment === 'dev', 'Test candidates require DEV template defaults');
assert.match(env.GITHUB_SHA || '', /^[a-f0-9]{40}$/);
assert.equal(env.GITHUB_WORKFLOW_REF, `${repository}/${candidateWorkflow}@refs/heads/main`);
assert(/^[1-9]\d*$/.test(env.GITHUB_RUN_ID || '') && /^[1-9]\d*$/.test(env.GITHUB_RUN_ATTEMPT || ''));
@@ -67,7 +67,7 @@ export async function sealCandidate(build, output, source, env = process.env) {
const identity = { package: `${guide.packageName}@${guide.version}`, sourceCommit: guide.commit,
workflowCommit: env.GITHUB_SHA, candidateRun: Number(env.GITHUB_RUN_ID), attempt: Number(env.GITHUB_RUN_ATTEMPT),
tgz: filename, tgzSHA256: await sha256(path.join(output, filename)), applicationSHA256: guide.applicationSHA256, locks: guide.locks,
- templateEnvironment: 'prod' };
+ templateEnvironment: guide.templateEnvironment };
await writeFile(path.join(output, 'acceptance.md'), template.replace('<!-- CANDIDATE_IDENTITY -->', '```json\n' + JSON.stringify(identity, null, 2) + '\n```'));
const installTemplate = await readFile(new URL('../../docs/templates/candidate-install.md', import.meta.url), 'utf8');
const values = { VERSION: guide.version, TGZ: filename, SHA256: identity.tgzSHA256, SOURCE_SHA: guide.commit,
@@ -148,10 +148,11 @@ export async function verifyCandidate(directory, expectedSHA256, run) {
assert.equal(integrity(await readFile(path.join(directory, candidate.tgz))), candidate.integrity);
const guide = await json(path.join(directory, 'install-record.json'));
assert.equal(guide.commit, candidate.sourceCommit); assert.equal(guide.version, candidate.version); assert.equal(guide.packageName, candidate.packageName);
- assert.equal(guide.tgzSHA256, expectedSHA256); assert.equal(guide.channel, 'test'); assert.equal(guide.templateEnvironment, 'prod');
+ assert.equal(guide.tgzSHA256, expectedSHA256); assert.equal(guide.channel, 'test'); assert.equal(guide.templateEnvironment, 'dev');
assert.equal(guide.guideSHA256, candidate.files['install.md']); assert.equal(guide.candidate, false);
const manifest = await json(path.join(directory, 'release-npm.json'));
assert.equal(manifest.commit, candidate.sourceCommit); assert.equal(manifest.version, candidate.version);
+ assert.equal(manifest.templateEnvironment, guide.templateEnvironment);
assert.equal(manifest.installer.sha256, expectedSHA256);
for (const name of ['source-scan.json', 'package-scan.json']) assert.equal((await json(path.join(directory, name))).status, 'passed');
return candidate;
@@ -171,6 +172,7 @@ export async function platformReports(directory, candidate) {
assert.equal(report.status, 'passed'); assert.equal(report.platform, platform);
assert.equal(report.version, candidate.version); assert.equal(report.tgzSHA256, candidate.tgzSHA256);
assert.equal(report.sourceCommit, candidate.sourceCommit);
+ assert.equal(report.templateEnvironment, 'dev');
assert.equal(report.registryColdInstall, 'passed'); assert.equal(report.nativePreparation, 'passed');
assert.equal(report.repeatSetup, 'passed'); assert.equal(report.resources, 'passed');
assert.equal(report.mcpTools, 11); assert.equal(report.skills, 5);
@@ -238,17 +240,46 @@ export async function publishNpm(directory, inputs, { fetcher = fetch, run = run
await writeJSON(path.join(directory, 'npm-publication.json'), record);
if (!before.version) {
// OIDC authenticates this publisher; its main SHA is not the prebuilt application's source.
- await run('npm', ['publish', path.join(directory, candidate.tgz), '--access', 'public', '--tag', 'test', '--ignore-scripts', '--provenance=false', '--registry=https://registry.npmjs.org/']);
+ await run('npm', ['publish', path.join(directory, candidate.tgz), '--access', 'public', '--tag', 'candidate', '--ignore-scripts', '--provenance=false', '--registry=https://registry.npmjs.org/']);
record.status = 'published-awaiting-registry'; await writeJSON(path.join(directory, 'npm-publication.json'), record);
}
return record;
}
+export async function promoteTest(directory, inputs, { fetcher = fetch, run = runFile, env = process.env } = {}) {
+ const candidate = await verifyDownloaded(directory, inputs.expectedSHA256, inputs.version);
+ await verifyAuthorization(directory, inputs, env);
+ const platforms = await platformReports(directory, candidate);
+ const npm = await json(path.join(directory, 'npm-publication.json'));
+ assert.equal(npm.tgzSHA256, candidate.tgzSHA256);
+ const before = await registryPackage(candidate, fetcher);
+ assert(before.version, 'Exact npm version is not public');
+ assert.equal(before.tags.latest ?? null, npm.previousLatest, 'npm latest changed unexpectedly; stop before channel promotion');
+ const superseded = before.tags.test && compareReleaseVersions(before.tags.test, candidate.version) > 0;
+ let status = inputs.action === 'archive-only' ? 'archive-only' : superseded ? 'superseded' : 'already-promoted';
+ if (inputs.action === 'publish-test' && !superseded && before.tags.test !== candidate.version) {
+ await run('npm', ['dist-tag', 'add', `${candidate.packageName}@${candidate.version}`, 'test', '--registry=https://registry.npmjs.org/']);
+ const after = await registryPackage(candidate, fetcher);
+ assert(after.version); assert.equal(after.tags.test, candidate.version, 'npm test promotion readback failed');
+ assert.equal(after.tags.latest ?? null, npm.previousLatest, 'npm latest changed unexpectedly');
+ status = 'promoted';
+ }
+ const record = { schemaVersion: 1, version: candidate.version, tgzSHA256: candidate.tgzSHA256, action: inputs.action,
+ publicationRun: env.GITHUB_RUN_ID, platformVerification: platforms, previousTest: before.tags.test ?? null, status };
+ await writeJSON(path.join(directory, 'test-promotion.json'), record);
+ return record;
+}
+
export async function archiveRelease(directory, inputs, config, { run = runFile, fetcher = fetch, env = process.env } = {}) {
await writeJSON(path.join(directory, 'release-attempt.json'), { action: inputs.action, tgzSHA256: inputs.expectedSHA256, stage: 'verifying-release', runId: env.GITHUB_RUN_ID });
const candidate = await verifyDownloaded(directory, inputs.expectedSHA256);
const authorization = await verifyAuthorization(directory, inputs, env);
const platforms = await platformReports(directory, candidate);
+ const promotion = await json(path.join(directory, 'test-promotion.json'));
+ assert.equal(promotion.version, candidate.version); assert.equal(promotion.tgzSHA256, candidate.tgzSHA256);
+ assert.equal(promotion.action, inputs.action); assert.equal(promotion.publicationRun, env.GITHUB_RUN_ID);
+ assert.deepEqual(promotion.platformVerification, platforms);
+ assert((inputs.action === 'archive-only' ? ['archive-only'] : ['promoted', 'already-promoted', 'superseded']).includes(promotion.status), 'Require a successful channel verification');
const record = await json(path.join(directory, 'install-record.json')), plan = storagePlan(record, config);
assert.equal(candidate.tgzSHA256, inputs.expectedSHA256);
const registry = await registryPackage(candidate, fetcher); assert(registry.version, 'Exact npm version is not public');
@@ -270,7 +301,8 @@ export async function archiveRelease(directory, inputs, config, { run = runFile,
let release = { schemaVersion: 2, packageName: candidate.packageName, version: candidate.version, sourceCommit: candidate.sourceCommit,
tgzSHA256: candidate.tgzSHA256, integrity: candidate.integrity, candidateRun: candidate.workflow,
authorization, publicationRun: env.GITHUB_RUN_ID,
- platformVerification: platforms, status: 'registry-verified', publishedAt: new Date().toISOString() };
+ platformVerification: platforms, channelPromotion: promotion, templateEnvironment: record.templateEnvironment,
+ status: 'registry-verified', publishedAt: new Date().toISOString() };
if (prior) {
const existing = JSON.parse(prior);
for (const key of ['packageName', 'version', 'sourceCommit', 'tgzSHA256', 'integrity']) assert.equal(existing[key], release[key], 'Existing release record differs: ' + key);
@@ -325,6 +357,7 @@ if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.me
} finally { await runFile('git', ['worktree', 'remove', '--force', work], { cwd: extra }).catch(() => {}); }
} else if (command === 'verify') await verifyDownloaded(directory, inputs.expectedSHA256, inputs.version);
else if (command === 'npm') await publishNpm(directory, inputs);
+ else if (command === 'promote-test') await promoteTest(directory, inputs);
else if (command === 'archive') {
for (const name of ['AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY']) assert(process.env[name], 'Missing R2 credential: ' + name);
await archiveRelease(directory, inputs, { endpoint: process.env.MOTION_R2_ENDPOINT, bucket: process.env.MOTION_R2_BUCKET, publicOrigin: process.env.MOTION_INSTALL_PUBLIC_ORIGIN });
diff --git a/.github/scripts/motion-scan.mjs b/.github/scripts/motion-scan.mjs
index 53103b0f..c578f203 100644
--- a/.github/scripts/motion-scan.mjs
+++ b/.github/scripts/motion-scan.mjs
@@ -7,6 +7,7 @@ import os from 'node:os';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { download, runFile, sha256, writeJSON } from '../../scripts/runtime-assets.mjs';
+import { releaseTemplateEnvironment } from '../../scripts/release-version.mjs';
const root = fileURLToPath(new URL('../../', import.meta.url));
export const scannerVersion = '8.30.1';
@@ -127,13 +128,15 @@ export async function scanPackage(tgz, binary) {
const pkg = JSON.parse(await readFile(path.join(outer, 'package.json')));
assert.equal(pkg.name, '@openmotion/app'); assert.equal(pkg.private, false);
const manifest = JSON.parse(await readFile(path.join(outer, 'payload/release-npm.json')));
- assert.equal(manifest.format, 'npm'); assert.equal(manifest.templateEnvironment, 'prod'); assert.equal(manifest.version, pkg.version);
+ assert.equal(manifest.format, 'npm'); assert.equal(manifest.templateEnvironment, releaseTemplateEnvironment(pkg.version)); assert.equal(manifest.version, pkg.version);
const appName = manifest.application.url.replace(/^\.\//, ''); assert.equal(path.basename(appName), appName);
const appArchive = path.join(outer, 'payload', appName); assert.equal(await sha256(appArchive), manifest.application.sha256);
await unpackChecked(appArchive, path.join(work, 'application'));
assert.equal(await sha256(path.join(work, 'application/package-lock.json')), manifest.locks.npm);
assert.equal(await sha256(path.join(work, 'application/scripts/runtime-lock.json')), manifest.locks.native);
const applicationPkg = JSON.parse(await readFile(path.join(work, 'application/package.json'))); assert.equal(applicationPkg.version, pkg.version);
+ const templates = JSON.parse(await readFile(path.join(work, 'application/shared/template-config.json')));
+ assert.equal(templates.environment, manifest.templateEnvironment, 'Application template defaults differ from the manifest');
const reports = await Promise.all([scanTree(path.join(work, 'outer'), 'package', binary), scanTree(path.join(work, 'application'), 'package', binary)]);
return { status: 'passed', version: pkg.version, tgzSHA256: await sha256(tgz), applicationSHA256: manifest.application.sha256, reports };
} finally { await rm(work, { recursive: true, force: true }); }
diff --git a/.github/workflows/motion-candidate.yml b/.github/workflows/motion-candidate.yml
index b3e995ce..bfdd406d 100644
--- a/.github/workflows/motion-candidate.yml
+++ b/.github/workflows/motion-candidate.yml
@@ -69,11 +69,11 @@ jobs:
npm run package:phase1
archive="$PWD/dist/motion-$(node -p "require('./package.json').version")-phase1.zip"
node tests/phase1-package.mjs "$archive" "$RUNNER_TEMP/phase1-e2e"
- - name: Build the final prod application tgz once and scan both archives
+ - name: Build the final DEV application tgz once and scan both archives
env:
MOTION_SOURCE_SHA: ${{ steps.source.outputs.source_sha }}
run: |
- node source/scripts/package-npm.mjs "$RUNNER_TEMP/build" "$MOTION_VERSION" --template-env=prod
+ node source/scripts/package-npm.mjs "$RUNNER_TEMP/build" "$MOTION_VERSION" --template-env=dev
cp "$RUNNER_TEMP/source-scan.json" "$RUNNER_TEMP/build/source-scan.json"
node control/.github/scripts/motion-scan.mjs package "$RUNNER_TEMP/build/openmotion-app-$MOTION_VERSION.tgz" "$RUNNER_TEMP/build/package-scan.json" "$RUNNER_TEMP/scanner/gitleaks"
node control/.github/scripts/motion-release.mjs seal "$RUNNER_TEMP/build" "$RUNNER_TEMP/candidate" source
diff --git a/.github/workflows/motion-publish-test.yml b/.github/workflows/motion-publish-test.yml
index 8c5571fa..9b9e26c7 100644
--- a/.github/workflows/motion-publish-test.yml
+++ b/.github/workflows/motion-publish-test.yml
@@ -104,6 +104,8 @@ jobs:
github-token: ${{ github.token }}
run-id: ${{ github.run_id }}
path: ${{ runner.temp }}/candidate
+ - name: Use the pinned npm CLI with trusted dist-tag support
+ run: npm install --global [email protected] --ignore-scripts --no-audit --no-fund
- name: Record explicit operator acceptance authorization
env:
GH_TOKEN: ${{ github.token }}
@@ -196,14 +198,19 @@ jobs:
retention-days: 30
if-no-files-found: warn
- snapshot:
+ promote-test:
if: ${{ always() && !cancelled() && needs.verify.result == 'success' && needs.npm.result == 'success' && needs.registry-mac.result == 'success' && needs.registry-windows.result == 'success' }}
env:
MOTION_EXPECTED_SHA256: ${{ needs.verify.outputs.tgz_sha256 }}
- MOTION_INSTALL_PUBLIC_ORIGIN: ${{ vars.CLOUDFLARE_R2_RELEASES_PUBLIC_ORIGIN }}
needs: [verify, npm, registry-mac, registry-windows]
runs-on: ubuntu-24.04
timeout-minutes: 15
+ outputs:
+ artifact_id: ${{ steps.artifact.outputs.artifact-id }}
+ permissions:
+ contents: read
+ actions: read
+ id-token: write
steps:
- uses: actions/[email protected]
with:
@@ -212,6 +219,9 @@ jobs:
- uses: actions/setup-node@v6
with:
node-version: '26.11.1'
+ registry-url: 'https://registry.npmjs.org'
+ - name: Use the pinned npm CLI with trusted dist-tag support
+ run: npm install --global [email protected] --ignore-scripts --no-audit --no-fund
- uses: actions/[email protected]
with:
artifact-ids: ${{ needs.verify.outputs.artifact_id }}
@@ -236,6 +246,64 @@ jobs:
github-token: ${{ github.token }}
run-id: ${{ github.run_id }}
path: ${{ runner.temp }}/candidate
+ - name: Advance npm test only after both native registry checks pass
+ run: node .github/scripts/motion-release.mjs promote-test "$RUNNER_TEMP/candidate"
+ - name: Retain the verified channel result
+ id: artifact
+ if: always()
+ uses: actions/[email protected]
+ with:
+ name: test-promotion-${{ github.run_id }}-${{ github.run_attempt }}
+ path: ${{ runner.temp }}/candidate/test-promotion.json
+ retention-days: 30
+ if-no-files-found: warn
+
+ snapshot:
+ if: ${{ always() && !cancelled() && needs.verify.result == 'success' && needs.npm.result == 'success' && needs.registry-mac.result == 'success' && needs.registry-windows.result == 'success' && needs.promote-test.result == 'success' }}
+ env:
+ MOTION_EXPECTED_SHA256: ${{ needs.verify.outputs.tgz_sha256 }}
+ MOTION_INSTALL_PUBLIC_ORIGIN: ${{ vars.CLOUDFLARE_R2_RELEASES_PUBLIC_ORIGIN }}
+ needs: [verify, npm, registry-mac, registry-windows, promote-test]
+ runs-on: ubuntu-24.04
+ timeout-minutes: 15
+ steps:
+ - uses: actions/[email protected]
+ with:
+ ref: ${{ github.sha }}
+ persist-credentials: false
+ - uses: actions/setup-node@v6
+ with:
+ node-version: '26.11.1'
+ - uses: actions/[email protected]
+ with:
+ artifact-ids: ${{ needs.verify.outputs.artifact_id }}
+ github-token: ${{ github.token }}
+ run-id: ${{ github.run_id }}
+ path: ${{ runner.temp }}/candidate
+ - uses: actions/[email protected]
+ with:
+ artifact-ids: ${{ needs.npm.outputs.artifact_id }}
+ github-token: ${{ github.token }}
+ run-id: ${{ github.run_id }}
+ path: ${{ runner.temp }}/candidate
+ - uses: actions/[email protected]
+ with:
+ artifact-ids: ${{ needs.registry-mac.outputs.artifact_id }}
+ github-token: ${{ github.token }}
+ run-id: ${{ github.run_id }}
+ path: ${{ runner.temp }}/candidate
+ - uses: actions/[email protected]
+ with:
+ artifact-ids: ${{ needs.registry-windows.outputs.artifact_id }}
+ github-token: ${{ github.token }}
+ run-id: ${{ github.run_id }}
+ path: ${{ runner.temp }}/candidate
+ - uses: actions/[email protected]
+ with:
+ artifact-ids: ${{ needs.promote-test.outputs.artifact_id }}
+ github-token: ${{ github.token }}
+ run-id: ${{ github.run_id }}
+ path: ${{ runner.temp }}/candidate
- name: Archive exact-version snapshots, verify canonical public bytes, then promote the default guide last
env:
AWS_ACCESS_KEY_ID: ${{ secrets.CLOUDFLARE_R2_RELEASES_AK }}
diff --git a/AGENTS.md b/AGENTS.md
index 965372a4..e6e59f50 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -18,6 +18,7 @@ This version has breaking changes — APIs, conventions, and file structure may
- Motion application development remains on `feature/motion`. Registering manual workflows on `main` does not move the application or authorize publication.
- After registration is merged, manual release jobs execute the trusted controls from `main` and select integrated application source from `feature/motion`. Before registration, those manual entries are not available on the default branch.
- Use Node 26.11.1 for control checks: `node --test tests/release-workflows.test.mjs tests/release-scan.test.mjs tests/install-guide.test.ts`. These tests need no workspace dependency installation and simulate publication services.
+- New test candidates embed DEV defaults. npm publication uses `candidate` first; only matching successful Mac/Windows native reports permit the separate promotion job to advance `test`. Stable publication, `latest` promotion and Skills platform distribution remain out of scope.
- Follow [activation and operation](docs/motion-release-activation.md). Keep completed acceptance evidence private; do not merge or publish without the task's explicit authorization.
## Commands
diff --git a/docs/install.md b/docs/install.md
index 8e24a319..fd494a3e 100644
--- a/docs/install.md
+++ b/docs/install.md
@@ -35,7 +35,7 @@ Repeat an explicit `--home` from setup on prepare. Setup installs the selected h
Setup copies the checked application into a managed writable directory and installs its locked production npm dependencies. The application and user projects do not run from the temporary npx cache. Prepare or first native use prepares the platform's independent native archives concurrently: browser/FFmpeg/ffprobe separately on macOS, browser/combined media on Windows. It waits for all components and reports a failure if any component fails; successful checked components remain reusable. This is not an offline package.
-There is no persisted switch-environment command in this version. Internal DEV testing uses its separately configured installation; merely setting an environment variable while running setup does not configure a later desktop Agent. Do not silently fall back from one environment to another.
+There is no persisted switch-environment command in this version. Test versions embed DEV defaults and use an environment-specific installation; stable versions embed prod. DEV access still requires the service network/authentication. A public npm package does not grant access or bundle private catalog contents. When changing environment, use a separate home/data/profile; merely setting an environment variable while running setup does not configure a later desktop Agent. Do not silently fall back from one environment to another.
## Upgrade, recovery and feedback
diff --git a/docs/motion-release-activation.md b/docs/motion-release-activation.md
index 68cdd91b..f38ecb9c 100644
--- a/docs/motion-release-activation.md
+++ b/docs/motion-release-activation.md
@@ -1,18 +1,18 @@
# Motion release controls on the legacy default branch
-This branch retains the legacy HTML Anything application. The Motion application still lives at the root of `feature/motion`. Registration takes effect only after this PR is merged into `main`; until then, its manual entries are not available on the default branch. These additions do not replace the application, change package/workspace metadata, merge Motion into main, or publish anything on a push/merge.
+This branch retains the legacy HTML Anything application. The Motion application still lives at the root of `feature/motion`. Registration PR #222 is merged into `main`. The follow-up controls below must be merged together with their matching Motion source changes before using the DEV candidate route. These additions do not replace the application, change package/workspace metadata, merge Motion into main, or publish anything on a push/merge.
## Scope and provenance
-The three manual workflows, their runtime helpers, installation/acceptance templates and deterministic tests are copied without modification from reviewed PR [#214](https://github.com/nexu-io/html-anything/pull/214), source commit `de45dadea282214762c7b3123cea7e6b1044f26f`. No application business logic or private Git history is imported; shared runtime helpers and tests are included as control dependencies. The extra `Motion release controls` CI job runs only syntax checks and simulated-service tests with read-only permissions; the legacy CI commands and permissions are preserved. Its runner is pinned to Ubuntu 24.04 because the locked Playwright cannot install browsers on the Ubuntu 26.04 image now selected by ubuntu-latest.
+The three manual workflows, their runtime helpers, installation/acceptance templates and deterministic tests were initially copied without modification from reviewed PR [#214](https://github.com/nexu-io/html-anything/pull/214), source commit `de45dadea282214762c7b3123cea7e6b1044f26f`. The test-channel follow-up copies the same 18 shared control files byte-for-byte from Motion commit `561e8e4c7d541560ea7659f7209163c6e3695783` and updates this control set to require DEV candidates and defer npm test promotion until native checks pass. No application business logic or private Git history is imported; shared runtime helpers and tests are included as control dependencies. The extra `Motion release controls` CI job runs only syntax checks and simulated-service tests with read-only permissions; the legacy CI commands and permissions are preserved. Its runner is pinned to Ubuntu 24.04 because the locked Playwright cannot install browsers on the Ubuntu 26.04 image now selected by ubuntu-latest.
GitHub requires a manual workflow to exist on the default branch before its Run workflow entry is available. After registration, our controls additionally require execution from `main`; they fetch the Motion application from a reviewed commit integrated into `feature/motion`. See [GitHub manual workflows](https://docs.github.com/en/actions/how-tos/manage-workflow-runs/manually-run-a-workflow).
## Activation order
-1. Integrate PR #214 into `feature/motion` after its required checks and review. This registration PR does not merge it.
-2. Review and merge this control-only PR into `main`. This makes the entries available without running any candidate build or publication. The normal credential-free CI jobs run on the merge.
-3. An npm package maintainer separately configures the GitHub trusted publisher for `@openmotion/app`: owner `nexu-io`, repository `html-anything`, workflow filename `motion-publish-test.yml`, Environment blank, and permission to publish. No stored npm token or independent approval environment is required. See [npm trusted publishers](https://docs.npmjs.com/trusted-publishers/).
+1. PR #214 is integrated into `feature/motion`, and #222 registered the original entries on `main`.
+2. Integrate the matching DEV packaging fix into `feature/motion`, then this control-only follow-up into `main`. Recompare the shared control files before using the new route. Neither merge runs a candidate build or publication; normal credential-free CI still runs.
+3. An npm package maintainer separately configures the GitHub trusted publisher for `@openmotion/app`: owner `nexu-io`, repository `html-anything`, workflow filename `motion-publish-test.yml`, Environment blank, and both **npm publish** and **Allow npm dist-tag** permissions. The promotion job requires the separate dist-tag permission; publish permission alone is insufficient. Credentialed jobs pin npm 11.21.2, which supports OIDC dist-tag operations. No stored npm token or independent approval environment is required. See [npm trusted publishers](https://docs.npmjs.com/trusted-publishers/).
4. Reuse the existing R2 Secrets `CLOUDFLARE_R2_RELEASES_AK` and `CLOUDFLARE_R2_RELEASES_SK`, and Variables `CLOUDFLARE_R2_RELEASES_BUCKET`, `CLOUDFLARE_R2_RELEASES_URL` and `CLOUDFLARE_R2_RELEASES_PUBLIC_ORIGIN`. Do not add secret values to source. Only the final storage step receives R2 credentials.
These are separate actions. Preparing or merging the registration does not authorize a package publication, repository rename or product-main cutover.
@@ -20,18 +20,18 @@ These are separate actions. Preparing or merging the registration does not autho
## Daily operation
1. **Build:** Actions → Motion candidate build → Run workflow → select `main`. Enter a new `X.Y.Z-test.N` version; normally leave `source_sha` empty to freeze the latest `feature/motion` head once. A supplied full SHA must already be integrated into that branch. The build checks/scans source and archives, and retains the exact candidate for 30 days without npm OIDC or R2 credentials.
-2. **Download and accept:** Download `motion-candidate-<version>` from the successful run, extract it and give its directory to the Agent: “Follow candidate-install.md, verify candidate.json and the local tgz hash, install the exact local package with an isolated host profile, application home, data and Skills directories, complete prepare, and record actual results in a private copy of acceptance.md. Mark unrun checks NOT RUN. Do not publish.” Keep actual host loading, template/edit/export checks, real Agent creation and human playback separate. Public test software defaults to prod templates; internal DEV packages use a separate process.
-3. **Publish:** Only after acceptance, Actions → Motion test publication → Run workflow → select `main`. Enter the exact accepted version and confirm `accepted`. This is the publication authorization, with no later independent approval dialog. Candidate provenance/hashes and scans are checked again; only the accepted tgz is published to npm `test`, then anonymously checked on Mac/Windows before immutable R2 snapshots and the default test guide are updated.
+2. **Download and accept:** Download `motion-candidate-<version>` from the successful run, extract it and give its directory to the Agent: “Follow candidate-install.md, verify candidate.json and the local tgz hash, install the exact local package with an isolated host profile, application home, data and Skills directories, complete prepare, and record actual results in a private copy of acceptance.md. Mark unrun checks NOT RUN. Do not publish.” Keep actual host loading, template/edit/export checks, real Agent creation and human playback separate. New public test software defaults to DEV templates; existing prod test versions retain their original defaults. The package exposes DEV routing configuration without private catalog snapshots or credentials. DEV network access/authentication is still required.
+3. **Publish:** Only after acceptance, Actions → Motion test publication → Run workflow → select `main`. Enter the exact accepted version and confirm `accepted`. This is the publication authorization, with no later independent approval dialog. Candidate provenance/hashes and scans are checked again; only the accepted tgz is published under npm `candidate`, then anonymously checked on Mac/Windows. A separate npm-OIDC-only job verifies both reports, their exact identity and installed DEV defaults, advances `test`, and reads the tag back. Only then does the credential-isolated R2 job archive snapshots and advance the default guide.
-Before npm publication, use the candidate's **local** `candidate-install.md`, not the sibling registry `install.md`. After publication, the moving test guide is `https://releases.open-design.ai/open-motion/dev/install.md`; the immutable guide is `/open-motion/dev/<version>/install.md`. Stable publication is not implemented by these controls, and npm `latest` is not deliberately changed.
+Before npm publication, use the candidate's **local** `candidate-install.md`, not the sibling registry `install.md`. After publication, the moving test guide is `https://releases.open-design.ai/open-motion/dev/install.md`; the immutable guide is `/open-motion/dev/<version>/install.md`. Stable publication, npm `latest` promotion and Skills platform/marketplace upload are not implemented by these controls. Five Skills are bundled and installed locally; that is not platform publication.
## Risk and recovery boundaries
- Registration is a capability change: users who can dispatch the trusted publication workflow can confirm and start a public release. There is no independent approval gate at this stage. Protect workflow edits and restrict operational access; the operator confirmation records intent, not proof of private testing.
- Builds do not publish. The publication form defaults acceptance to false and rejects missing, expired, ambiguous or untrusted candidates, changed bytes and unintegrated source. Do not rebuild a published version or guess among duplicate candidate artifacts.
-- npm publication cannot be rolled back atomically with later checks. If native verification or R2 upload fails, npm may already be public while the default guide stays unchanged. Inspect retained records before using Re-run failed jobs; those retries reuse successful producer artifact IDs and never rebuild the candidate.
+- npm publication cannot be rolled back atomically with later checks. The exact candidate and `candidate` tag are public before native verification. If either native check fails, `test` and the default guide remain unchanged. R2 failure after successful native/tag checks may leave `test` on the verified new version and the default guide on the prior one; this is not an atomic npm/R2 transaction. Inspect `test-promotion.json` and retained attempt records. Never use npm dist-tag as a dry-run against the real registry. Inspect retained records before using Re-run failed jobs; those retries reuse successful producer artifact IDs and never rebuild the candidate.
- Motion snapshot recovery writes versioned R2 snapshots for an already published identical npm package; it does not build, publish npm, move tags or access the default guide. Channel rollback and client/data recovery require separate decisions.
- A single publication concurrency group and version/ETag checks protect channel promotion. Operate one release at a time; GitHub does not provide a durable FIFO queue.
- Disabling/removing these workflow registrations later does not undo a published npm version, restore user projects or revoke npm trust. Those are separate operations.
-The implementation manual remains on the [reviewed Motion branch](https://github.com/nexu-io/html-anything/blob/de45dadea282214762c7b3123cea7e6b1044f26f/docs/release-workflows.md). Keep the full acceptance record internal. Real hosted workflow dispatch, npm OIDC, registry-native acceptance and R2/CDN writes need a separately authorized rehearsal; passing these control tests does not establish that those external integrations are active.
+The current [implementation manual](https://github.com/nexu-io/html-anything/blob/feature/motion/docs/release-workflows.md) is maintained with the Motion source; the original #214 snapshot above records registration provenance. For later control fixes, submit paired Motion/main PRs and compare all shared workflow/helper/template/test bytes before release. The maintainer of the control change owns both updates; a Motion-only fix does not update the executable main controls. Record both PRs and exact commits in the release review. Keep the full acceptance record internal. Real hosted workflow dispatch, npm OIDC, registry-native acceptance and R2/CDN writes need a separately authorized rehearsal; passing these control tests does not establish that those external integrations are active.
diff --git a/docs/templates/candidate-install.md b/docs/templates/candidate-install.md
index 19072324..ad41b47b 100644
--- a/docs/templates/candidate-install.md
+++ b/docs/templates/candidate-install.md
@@ -1,6 +1,6 @@
# Install the OpenMotion {{VERSION}} candidate
-This is a **local candidate installation guide**. It installs the complete `{{TGZ}}` next to this file, not an unpublished npm registry version. The application, MCP, built Studio and five Skills are embedded. Native browser/FFmpeg/ffprobe and locked npm dependencies still need network access when prepared. Public test software defaults to prod templates.
+This is a **local candidate installation guide**. It installs the complete `{{TGZ}}` next to this file, not an unpublished npm registry version. The application, MCP, built Studio and five Skills are embedded. Native browser/FFmpeg/ffprobe and locked npm dependencies still need network access when prepared. Public test software defaults to DEV templates. The source address is public configuration; access still requires the DEV service network/authentication. The package contains no private catalog snapshot or credentials.
## Frozen identity
@@ -21,7 +21,7 @@ This is a **local candidate installation guide**. It installs the complete `{{TG
```
Replace `HOST` with `codex`, `claude`, `deepseek` or `workbuddy`. Carry the explicit `--home`, `--data-dir`, `--skills-dir` and host-specific options from the platform recipe; repeat the same home for prepare. Wait for setup and prepare to finish before native use. Keep using this local package; no sidecar application/manifest download or source build is required.
-4. Follow this host's discovery/reload action. Verify the actual application version, prod template environment, eleven MCP Tools, resources and five Skills, including a `motion_get_project` call against the isolated data directory. Registration or installation success alone is not host loading or creative acceptance.
+4. Follow this host's discovery/reload action. Verify the actual application version, DEV template environment, eleven MCP Tools, resources and five Skills, including a `motion_get_project` call against the isolated data directory. Registration or installation success alone is not host loading or creative acceptance.
5. Follow the tester's requested acceptance cases in `acceptance.md`: use an independent test project for template creation, editing, save/reopen and MP4 export. Do not modify an existing user project or start a paid provider call without its separate authorization. Retain technical export checks separately from real Agent creation and human audio/video playback.
6. Fill a **private copy** of `acceptance.md` with actual PASS / FAIL / NOT RUN results and evidence. Report failures and retain the generated candidate identity. Do not edit/re-upload the frozen candidate artifact. Do not publish npm, upload a guide or change a tag as part of installation/testing.
diff --git a/docs/templates/release-record.md b/docs/templates/release-record.md
index 2f187e6c..5396bce0 100644
--- a/docs/templates/release-record.md
+++ b/docs/templates/release-record.md
@@ -44,7 +44,8 @@ Use PASS / FAIL / NOT RUN and link retained evidence. CI success alone cannot fi
## Publication follow-up
- Publication run / npm exact version / registry hash and integrity:
-- Native registry cold-install report per platform:
+- Native registry cold-install report per platform, including embedded/installed template environment:
+- Verified npm test promotion / prior test version / promotion run:
- Immutable R2 version / release-record / guide URL and verified hash:
- Default entry / previous entry / final publication phase:
- Failure, recovery or user feedback:
diff --git a/scripts/install-guide.mjs b/scripts/install-guide.mjs
index 7f072eab..2b756ac9 100644
--- a/scripts/install-guide.mjs
+++ b/scripts/install-guide.mjs
@@ -3,7 +3,7 @@ import { mkdir, readFile } from 'node:fs/promises';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { runFile, sha256, writeAtomic, writeJSON } from './runtime-assets.mjs';
-import { checkReleaseVersion } from './release-version.mjs';
+import { checkReleaseVersion, releaseTemplateEnvironment } from './release-version.mjs';
export function validateGuideSpec(name, version) {
assert.match(name || '', /^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/, 'Require an npm package name');
@@ -17,7 +17,7 @@ export function validateGuideIdentity(pkg, manifest) {
assert.equal(pkg.private, false, 'Only public release candidates may have a public installation guide');
assert.equal(pkg.version, manifest.version, 'Package and embedded manifest versions differ');
assert.equal(manifest.schemaVersion, 1, 'Unsupported release manifest');
- assert.equal(manifest.templateEnvironment, 'prod', 'Public guides require prod defaults');
+ assert.equal(manifest.templateEnvironment, releaseTemplateEnvironment(pkg.version), 'Template defaults must match the release channel');
assert.equal(pkg.bin?.openmotion, 'scripts/npm-installer.mjs', 'Missing Motion entry point');
assert.match(manifest.commit || '', /^[a-f0-9]{40}$/, 'Require the built source SHA');
for (const hash of [manifest.application?.sha256, manifest.locks?.npm, manifest.locks?.native]) assert.match(hash || '', /^[a-f0-9]{64}$/, 'Require release checksums');
diff --git a/scripts/release-version.mjs b/scripts/release-version.mjs
index e487f0bc..d64755f7 100644
--- a/scripts/release-version.mjs
+++ b/scripts/release-version.mjs
@@ -4,6 +4,11 @@ export function checkReleaseVersion(version) {
assert.match(version, /^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-test\.[1-9]\d*(?:\.[1-9]\d*)*)?$/, 'Use MAJOR.MINOR.PATCH or MAJOR.MINOR.PATCH-test.N[.N]');
}
+export function releaseTemplateEnvironment(version) {
+ checkReleaseVersion(version);
+ return version.includes('-test.') ? 'dev' : 'prod';
+}
+
export function compareReleaseVersions(left, right) {
checkReleaseVersion(left); checkReleaseVersion(right);
const parts = value => {
diff --git a/tests/install-guide.test.ts b/tests/install-guide.test.ts
index 31c41348..67cbb19d 100644
--- a/tests/install-guide.test.ts
+++ b/tests/install-guide.test.ts
@@ -8,7 +8,7 @@ import { publishGuide, storagePlan } from '../.github/scripts/publish-install-gu
import { runFile } from '../scripts/runtime-assets.mjs';
const pkg = { name: '@openmotion/app', version: '0.6.4-test.1', private: false, bin: { openmotion: 'scripts/npm-installer.mjs' } };
-const manifest = { schemaVersion: 1, version: pkg.version, templateEnvironment: 'prod', commit: 'a'.repeat(40),
+const manifest = { schemaVersion: 1, version: pkg.version, templateEnvironment: 'dev', commit: 'a'.repeat(40),
application: { sha256: 'b'.repeat(64) }, locks: { npm: 'c'.repeat(64), native: 'd'.repeat(64) },
runtime: { targets: { mac: { platform: 'darwin', arch: 'arm64', minimumOS: '26.0' } } } };
const config = { endpoint: 'https://example.r2.cloudflarestorage.com', bucket: 'example-guides', publicOrigin: 'https://download.example.invalid' };
@@ -61,8 +61,11 @@ test('guide rendering pins the exact npm package, built source and hash while re
for (const name of ['https://evil.invalid/a', 'x;echo bad', '--script', '@bad/no/extra']) assert.throws(() => validateGuideSpec(name, pkg.version));
assert.throws(() => validateGuideSpec(pkg.name, 'latest'));
assert.throws(() => validateGuideIdentity({ ...pkg, private: true }, manifest), /public/);
- assert.throws(() => validateGuideIdentity(pkg, { ...manifest, templateEnvironment: 'dev' }), /prod/);
+ assert.throws(() => validateGuideIdentity(pkg, { ...manifest, templateEnvironment: 'prod' }), /Template defaults/);
assert.throws(() => validateGuideIdentity(pkg, { ...manifest, version: '0.6.4' }), /versions differ/);
+ const stable = { ...pkg, version: '0.6.4' };
+ assert.equal(validateGuideIdentity(stable, { ...manifest, version: stable.version, templateEnvironment: 'prod' }), 'stable');
+ assert.throws(() => validateGuideIdentity(stable, { ...manifest, version: stable.version }), /Template defaults/);
});
test('publication verifies the immutable URL before conditional fixed promotion and retains the prior guide', async t => {
diff --git a/tests/release-fixture.mjs b/tests/release-fixture.mjs
index b4988e20..0024f91a 100644
--- a/tests/release-fixture.mjs
+++ b/tests/release-fixture.mjs
@@ -3,7 +3,7 @@ import os from 'node:os';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { runFile, sha256, writeJSON } from '../scripts/runtime-assets.mjs';
-import { sealCandidate, repository, candidateWorkflow, publicationWorkflow, authorizationReceipt } from '../.github/scripts/motion-release.mjs';
+import { sealCandidate, repository, candidateWorkflow, publicationWorkflow, authorizationReceipt, platformReports } from '../.github/scripts/motion-release.mjs';
export async function candidateFixture(t) {
const work = await mkdtemp(path.join(os.tmpdir(), 'motion-release-test-'));
@@ -11,12 +11,13 @@ export async function candidateFixture(t) {
const root = fileURLToPath(new URL('../', import.meta.url)), build = path.join(work, 'build'), directory = path.join(work, 'candidate');
const commit = (await runFile('git', ['rev-parse', 'HEAD'], { cwd: root })).trim(), version = '0.6.4-test.99';
const app = path.join(work, 'app'), pkg = path.join(work, 'package');
- await mkdir(path.join(app, 'scripts'), { recursive: true }); await mkdir(path.join(pkg, 'payload'), { recursive: true }); await mkdir(build);
+ await mkdir(path.join(app, 'scripts'), { recursive: true }); await mkdir(path.join(app, 'shared')); await mkdir(path.join(pkg, 'payload'), { recursive: true }); await mkdir(build);
await writeJSON(path.join(app, 'package.json'), { version }); await writeJSON(path.join(app, 'package-lock.json'), {});
await writeJSON(path.join(app, 'scripts/runtime-lock.json'), {});
- const application = path.join(pkg, 'payload', `openmotion-application-${version}.tar.gz`);
+ await writeJSON(path.join(app, 'shared/template-config.json'), { environment: 'dev' });
+ const application = path.join(pkg, 'payload', `openmotion-application-${version}-dev.tar.gz`);
await runFile('tar', ['-czf', application, '-C', app, '.']);
- const manifest = { schemaVersion: 1, version, format: 'npm', templateEnvironment: 'prod', commit,
+ const manifest = { schemaVersion: 1, version, format: 'npm', templateEnvironment: 'dev', commit,
application: { url: './' + path.basename(application), sha256: await sha256(application) },
locks: { npm: await sha256(path.join(app, 'package-lock.json')), native: await sha256(path.join(app, 'scripts/runtime-lock.json')) },
runtime: { targets: { mac: { platform: 'darwin', arch: 'arm64', minimumOS: '26.0' } } } };
@@ -38,9 +39,10 @@ export async function candidateFixture(t) {
const authorization = authorizationReceipt(candidate, { id: 800, run_attempt: 1, actor: { login: 'operator' } }, inputs.action);
await writeJSON(path.join(directory, 'authorization.json'), authorization);
for (const platform of ['darwin-arm64', 'win32-x64']) await writeJSON(path.join(directory, `registry-${platform}.json`), {
- status: 'passed', platform, version, sourceCommit: commit, tgzSHA256: candidate.tgzSHA256,
+ status: 'passed', templateEnvironment: 'dev', platform, version, sourceCommit: commit, tgzSHA256: candidate.tgzSHA256,
registryColdInstall: 'passed', nativePreparation: 'passed', repeatSetup: 'passed', resources: 'passed', mcpTools: 11, skills: 5,
});
await writeJSON(path.join(directory, 'npm-publication.json'), { tgzSHA256: candidate.tgzSHA256, previousLatest: '0.5.0' });
+ await writeJSON(path.join(directory, 'test-promotion.json'), { version, tgzSHA256: candidate.tgzSHA256, action: inputs.action, publicationRun: publicationEnv.GITHUB_RUN_ID, status: 'already-promoted', platformVerification: await platformReports(directory, candidate) });
return { work, root, build, directory, candidate, inputs, provenance, app, pkg, manifest, authorization, env: publicationEnv };
}
diff --git a/tests/release-scan.test.mjs b/tests/release-scan.test.mjs
index 2aba686c..2246c8b3 100644
--- a/tests/release-scan.test.mjs
+++ b/tests/release-scan.test.mjs
@@ -39,11 +39,20 @@ test('tracked source is scanned without ignore-file bypasses; secret errors expo
test('the scanner opens the nested application, rejects hidden private content and rejects linked archive entries', async t => {
const f = await candidateFixture(t), { binary } = await scanner(t);
assert.equal((await scanPackage(path.join(f.directory, f.candidate.tgz), binary)).status, 'passed');
- await writeFile(path.join(f.app, '.env'), 'EXAMPLE=not-a-real-secret');
+ const templates = path.join(f.app, 'shared/template-config.json');
+ await writeJSON(templates, { environment: 'prod' });
const appArchive = path.join(f.pkg, 'payload', f.manifest.application.url.slice(2));
- await runFile('tar', ['-czf', appArchive, '-C', f.app, '.']);
- await writeJSON(path.join(f.pkg, 'payload/release-npm.json'), { ...f.manifest, application: { ...f.manifest.application, sha256: await sha256(appArchive) } });
- const tgz = path.join(f.work, 'hidden.tgz'); await runFile('tar', ['-czf', tgz, '-C', f.work, 'package']);
+ const tgz = path.join(f.work, 'hidden.tgz');
+ const repack = async () => {
+ await runFile('tar', ['-czf', appArchive, '-C', f.app, '.']);
+ await writeJSON(path.join(f.pkg, 'payload/release-npm.json'), { ...f.manifest, application: { ...f.manifest.application, sha256: await sha256(appArchive) } });
+ await runFile('tar', ['-czf', tgz, '-C', f.work, 'package']);
+ };
+ await repack();
+ await assert.rejects(scanPackage(tgz, binary), /template defaults differ/);
+ await writeJSON(templates, { environment: 'dev' });
+ await writeFile(path.join(f.app, '.env'), 'EXAMPLE=not-a-real-secret');
+ await repack();
await assert.rejects(scanPackage(tgz, binary), /environment-file/);
await symlink('package.json', path.join(f.app, 'linked')); const linked = path.join(f.work, 'linked.tar.gz');
await runFile('tar', ['-czf', linked, '-C', f.app, '.']);
diff --git a/tests/release-workflows.test.mjs b/tests/release-workflows.test.mjs
index 01c18606..20858b6b 100644
--- a/tests/release-workflows.test.mjs
+++ b/tests/release-workflows.test.mjs
@@ -1,10 +1,10 @@
import test from 'node:test';
import assert from 'node:assert/strict';
-import { readFile, writeFile } from 'node:fs/promises';
+import { readFile, writeFile, rm } from 'node:fs/promises';
import path from 'node:path';
import { createHash } from 'node:crypto';
import { candidateFixture } from './release-fixture.mjs';
-import { releaseInputs, resolveSource, validateSource, validateRun, verifyDownloaded, downloadCandidate, publishNpm, archiveRelease, repository, candidateWorkflow, recoveryWorkflow, publicationWorkflow, candidateJobName, findCandidate, authorizationReceipt, recordAuthorization } from '../.github/scripts/motion-release.mjs';
+import { releaseInputs, resolveSource, validateSource, validateRun, verifyDownloaded, downloadCandidate, publishNpm, promoteTest, archiveRelease, repository, candidateWorkflow, recoveryWorkflow, publicationWorkflow, candidateJobName, findCandidate, authorizationReceipt, recordAuthorization } from '../.github/scripts/motion-release.mjs';
import { compareReleaseVersions } from '../scripts/release-version.mjs';
import { consumerEnvironment } from '../.github/scripts/motion-registry-smoke.mjs';
import { runFile } from '../scripts/runtime-assets.mjs';
@@ -109,7 +109,7 @@ function registry(candidate, exists = true, tag = candidate.version, latest = '0
test('npm publishes only new exact bytes; identical retry and archive-only never write, mismatches fail', async t => {
const f = await candidateFixture(t); let calls = 0;
assert.notEqual(f.candidate.sourceCommit, f.candidate.workflow.sha, 'Application and workflow source identities are independent');
- const run = async (command, args) => { calls++; assert.equal(command, 'npm'); assert(args.includes('--ignore-scripts') && args.includes('test')); assert(args.includes('--provenance=false'), 'Do not attest the publication main SHA as the prebuilt application source'); assert.equal(args[1], path.join(f.directory, f.candidate.tgz)); };
+ const run = async (command, args) => { calls++; assert.equal(command, 'npm'); assert(args.includes('--ignore-scripts') && args.includes('candidate')); assert(args.includes('--provenance=false'), 'Do not attest the publication main SHA as the prebuilt application source'); assert.equal(args[1], path.join(f.directory, f.candidate.tgz)); };
await publishNpm(f.directory, f.inputs, { run, fetcher: registry(f.candidate, false), env: f.env }); assert.equal(calls, 1);
await publishNpm(f.directory, f.inputs, { run, fetcher: registry(f.candidate), env: f.env });
await assert.rejects(publishNpm(f.directory, f.inputs, { run, fetcher: registry({ ...f.candidate, integrity: 'different' }), env: f.env }), /different bytes/); assert.equal(calls, 1);
@@ -128,6 +128,37 @@ test('a stale candidate or authorization from another run cannot publish or move
assert.equal(calls, 0);
});
+test('test promotion requires both matching DEV native reports and preserves the old channel on failure', async t => {
+ const f = await candidateFixture(t); let writes = 0, tag = '0.6.4-test.1';
+ const options = { env: f.env, fetcher: () => registry(f.candidate, true, tag)(), run: async (command, args) => {
+ assert.equal(command, 'npm'); assert.deepEqual(args.slice(0, 4), ['dist-tag', 'add', '@openmotion/app@' + f.candidate.version, 'test']);
+ writes++; tag = f.candidate.version;
+ } };
+ const file = path.join(f.directory, 'registry-win32-x64.json'), original = await readFile(file, 'utf8');
+ for (const patch of [{ status: 'failed' }, { tgzSHA256: '0'.repeat(64) }, { templateEnvironment: 'prod' }, { nativePreparation: 'failed' }]) {
+ await writeFile(file, JSON.stringify({ ...JSON.parse(original), ...patch }));
+ await assert.rejects(promoteTest(f.directory, f.inputs, options));
+ assert.equal(writes, 0); assert.equal(tag, '0.6.4-test.1');
+ }
+ await rm(file); await assert.rejects(promoteTest(f.directory, f.inputs, options), /ENOENT/);
+ assert.equal(writes, 0); assert.equal(tag, '0.6.4-test.1');
+ await writeFile(file, original);
+ await assert.rejects(promoteTest(f.directory, f.inputs, { ...options, fetcher: registry(f.candidate, true, tag, '0.6.4') }), /latest changed/);
+ await assert.rejects(promoteTest(f.directory, f.inputs, { ...options, env: { GITHUB_RUN_ID: '801' } }), /another publication run/);
+ assert.equal(writes, 0);
+ assert.equal((await promoteTest(f.directory, f.inputs, options)).status, 'promoted');
+ assert.equal(writes, 1); assert.equal(tag, f.candidate.version);
+ assert.equal((await promoteTest(f.directory, f.inputs, options)).status, 'already-promoted');
+ assert.equal(writes, 1);
+});
+
+test('promotion never regresses a newer test tag and archive-only has no npm write', async t => {
+ const f = await candidateFixture(t), run = async () => { throw Error('Unexpected npm mutation'); };
+ assert.equal((await promoteTest(f.directory, f.inputs, { run, env: f.env, fetcher: registry(f.candidate, true, '0.6.4-test.100') })).status, 'superseded');
+ await writeFile(path.join(f.directory, 'authorization.json'), JSON.stringify({ ...f.authorization, action: 'archive-only' }));
+ assert.equal((await promoteTest(f.directory, { ...f.inputs, action: 'archive-only' }, { run, env: f.env, fetcher: registry(f.candidate) })).status, 'archive-only');
+});
+
test('test version ordering handles numeric suffixes, stable versions and unsafe numeric widths', () => {
for (const [a, b] of [['0.6.4-test.10', '0.6.4-test.9'], ['0.6.4', '0.6.4-test.99'], ['0.6.5-test.1', '0.6.4'], ['0.6.4-test.1.2', '0.6.4-test.1'], ['0.6.4-test.9007199254740993', '0.6.4-test.9007199254740992']]) {
assert.equal(compareReleaseVersions(a, b), 1); assert.equal(compareReleaseVersions(b, a), -1);
@@ -139,22 +170,26 @@ test('test version ordering handles numeric suffixes, stable versions and unsafe
test('partial publication retries use the retained producer artifact IDs across attempts', async () => {
const workflow = await readFile(new URL('../.github/workflows/motion-publish-test.yml', import.meta.url), 'utf8');
const jobs = Object.fromEntries(workflow.split('\njobs:\n')[1].split(/(?=^ [\w-]+:\n)/m).filter(s => s.trim()).map(s => [s.match(/^ ([\w-]+):\n/)[1], s]));
- const producers = ['verify', 'npm', 'registry-mac', 'registry-windows'];
+ const producers = ['verify', 'npm', 'registry-mac', 'registry-windows', 'promote-test'];
const render = (value, attempt) => value.replaceAll('${{ github.run_id }}', '800').replaceAll('${{ github.run_attempt }}', String(attempt));
for (const id of producers) {
assert(jobs[id], 'A platform needs its own retained output: ' + id);
assert(jobs[id].includes('artifact_id: ${{ steps.artifact.outputs.artifact-id }}'), 'Expose the actual uploaded artifact ID');
assert(jobs[id].includes(' id: artifact\n'));
}
- for (const id of ['npm', 'registry-mac', 'registry-windows', 'snapshot']) {
+ for (const id of ['npm', 'registry-mac', 'registry-windows', 'promote-test', 'snapshot']) {
assert(jobs[id].includes('if: ${{ always() && !cancelled() && needs.verify.result'), 'Successful retained producers must still supply partial retry consumers: ' + id);
}
const downloads = id => [...jobs[id].matchAll(/artifact-ids: \$\{\{ needs\.([\w-]+)\.outputs\.artifact_id \}\}/g)].map(m => m[1]);
assert.deepEqual(downloads('npm'), ['verify']);
assert.deepEqual(downloads('registry-mac'), ['verify']);
assert.deepEqual(downloads('registry-windows'), ['verify']);
+ assert.deepEqual(downloads('promote-test'), producers.slice(0, -1));
assert.deepEqual(downloads('snapshot'), producers);
- assert(jobs.snapshot.includes('needs: [verify, npm, registry-mac, registry-windows]'));
+ assert(jobs.snapshot.includes('needs: [verify, npm, registry-mac, registry-windows, promote-test]'));
+ assert(jobs['promote-test'].includes('needs.registry-mac.result') && jobs['promote-test'].includes('needs.registry-windows.result'));
+ assert(jobs['promote-test'].includes('id-token: write') && !jobs.snapshot.includes('id-token: write'));
+ assert(jobs['promote-test'].includes('[email protected]'));
assert(jobs.npm.includes(' actions: read\n'), 'The credentialed npm job needs only read access to input artifacts');
for (const job of Object.values(jobs)) {
for (const step of job.split(/(?=^ - )/m).filter(s => s.includes('uses: actions/download-artifact@'))) {
@@ -183,6 +218,7 @@ test('daily build and publication are separate manual entries without an indepen
const header = workflow.split('\njobs:\n')[0];
assert(build.includes('workflow_dispatch:') && build.includes('version:') && build.includes('source_sha:'));
assert(build.includes('name: ' + candidateJobName) && build.includes('ref: ${{ steps.source.outputs.source_sha }}'));
+ assert(build.includes('--template-env=dev') && !build.includes('--template-env=prod'));
assert(build.includes('name: motion-candidate-${{ inputs.version }}') && build.includes('candidate-install.md'));
assert(!build.includes('concurrency:') && !build.includes('secrets.') && !build.includes('id-token:'));
assert(header.includes('version:') && header.includes('accepted:') && header.includes('default: false'));
@@ -226,8 +262,10 @@ test('interrupted archive resumes identical snapshots, verifies the exact public
test('archive-only never reads or writes the moving entry, and failed platform acceptance blocks all storage calls', async t => {
const f = await candidateFixture(t), store = storage(f.candidate);
await writeFile(path.join(f.directory, 'authorization.json'), JSON.stringify({ ...f.authorization, action: 'archive-only' }));
+ await promoteTest(f.directory, { ...f.inputs, action: 'archive-only' }, { fetcher: registry(f.candidate), env: f.env, run: async () => { throw Error('Archive-only cannot write npm'); } });
await archiveRelease(f.directory, { ...f.inputs, action: 'archive-only' }, config, store);
assert(!store.reads.includes('open-motion/dev/install.md') && !store.writes.includes('open-motion/dev/install.md'));
+ await writeFile(path.join(f.directory, 'authorization.json'), JSON.stringify(f.authorization));
await writeFile(path.join(f.directory, 'registry-win32-x64.json'), JSON.stringify({ status: 'failed' }));
const before = store.reads.length; await assert.rejects(archiveRelease(f.directory, f.inputs, config, store)); assert.equal(store.reads.length, before);
});
@@ -265,15 +303,17 @@ test('no-publication rehearsal carries one accepted candidate through npm and st
const run = { ...origin, id: 800, path: publicationWorkflow, actor: { login: 'operator' } };
const github = async url => { assert(String(url).endsWith('/actions/runs/800')); return Response.json(run); };
await writeFile(path.join(f.directory, 'authorization.json'), '{}');
- let npmWrites = 0, published = false;
- const npm = { env: f.env, fetcher: () => registry(f.candidate, published)(), run: async (command, args) => {
- assert.equal(command, 'npm'); assert.equal(args[1], path.join(f.directory, f.candidate.tgz));
- npmWrites++; published = true;
+ let npmWrites = 0, tagWrites = 0, published = false, testTag = '0.6.4-test.1';
+ const npm = { env: f.env, fetcher: () => registry(f.candidate, published, testTag)(), run: async (command, args) => {
+ assert.equal(command, 'npm');
+ if (args[0] === 'dist-tag') { tagWrites++; testTag = f.candidate.version; }
+ else { assert.equal(args[1], path.join(f.directory, f.candidate.tgz)); assert.equal(args[args.indexOf('--tag') + 1], 'candidate'); npmWrites++; published = true; }
} };
await assert.rejects(publishNpm(f.directory, f.inputs, npm));
assert.equal(npmWrites, 0, 'No authorization means no registry write');
await recordAuthorization(f.directory, f.inputs, github, f.env);
await publishNpm(f.directory, f.inputs, npm);
+ await promoteTest(f.directory, f.inputs, npm);
await archiveRelease(f.directory, f.inputs, config, store);
assert.equal(npmWrites, 1);
const release = JSON.parse(store.objects.get(`open-motion/dev/${f.candidate.version}/release-record.json`));
@@ -282,6 +322,8 @@ test('no-publication rehearsal carries one accepted candidate through npm and st
assert.equal(release.tgzSHA256, f.candidate.tgzSHA256);
assert.equal(store.writes.at(-1), 'open-motion/dev/install.md');
await publishNpm(f.directory, f.inputs, npm);
+ await promoteTest(f.directory, f.inputs, npm);
await archiveRelease(f.directory, f.inputs, config, store);
assert.equal(npmWrites, 1, 'Retry never repacks or republishes the accepted bytes');
+ assert.equal(tagWrites, 1, 'Retry never moves an already verified tag again');
});