diff --git a/.github/documentation-policy.json b/.github/documentation-policy.json new file mode 100644 index 00000000..9f97a61e --- /dev/null +++ b/.github/documentation-policy.json @@ -0,0 +1,20 @@ +{ + "schema": 1, + "documents": [ + { + "path": "CONTRACT.md", + "kind": "contract", + "purpose": "Define the public encoding, decoding, validation and error contracts." + }, + { + "path": "SECURITY_MEMORY_MODEL.md", + "kind": "reference", + "purpose": "Explain sensitive-buffer ownership, cleanup guarantees and platform limits." + }, + { + "path": "docs/protobuf.md", + "kind": "reference", + "purpose": "Describe the public protobuf contract and supported serialization formats." + } + ] +} diff --git a/.github/workflows/android-runtime-gate.yml b/.github/workflows/android-runtime-gate.yml index 4e94be19..a79752c2 100644 --- a/.github/workflows/android-runtime-gate.yml +++ b/.github/workflows/android-runtime-gate.yml @@ -30,7 +30,7 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 with: repository: reallyme/release-readiness - ref: e323ea52bc1f76e67df03fc95e19d596fb54bd03 + ref: 16aab5287de498e858ff3b85d9e66d7c9f7ebb74 path: .release-readiness persist-credentials: false diff --git a/.github/workflows/cla.yaml b/.github/workflows/cla.yaml index 1c06dd82..75bf6f7c 100644 --- a/.github/workflows/cla.yaml +++ b/.github/workflows/cla.yaml @@ -14,18 +14,20 @@ on: types: [checks_requested] permissions: - actions: write - checks: read - contents: write - pull-requests: write - statuses: write + contents: read jobs: - CLAAssistant: - # This workflow uses repository write permissions and never checks out PR code. + cla-signatures: + # Only the signature action may update the signature branch, comment, and + # rerun a failed PR check. It never checks out or executes PR code. # Filter comments here so ordinary issue and PR discussion does not start # a runner. Only signature and recheck comments on PRs reach the action. + permissions: + actions: write + contents: write + pull-requests: write if: >- + github.event_name != 'merge_group' && github.repository_owner == 'reallyme' && toJSON(github.event.repository.private) == 'false' && (github.event.repository.visibility == null || github.event.repository.visibility == 'public') && @@ -37,7 +39,6 @@ jobs: timeout-minutes: 5 steps: - name: Check contributor signatures - if: github.event_name == 'pull_request_target' || github.event_name == 'issue_comment' uses: iainmcgin/cla-github-action@0d27e5a16278d4adb6b0c4b92f08ad27b0a21dc8 # v3.2.0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -48,8 +49,21 @@ jobs: allowlist: 'dependabot[bot],github-actions[bot],renovate[bot]' require-opener-as-author: 'true' + cla-merge-queue: + # Queue validation only reads PR metadata and completed workflow runs. + permissions: + actions: read + contents: read + pull-requests: read + if: >- + github.event_name == 'merge_group' && + github.repository_owner == 'reallyme' && + toJSON(github.event.repository.private) == 'false' && + (github.event.repository.visibility == null || github.event.repository.visibility == 'public') + runs-on: ubuntu-24.04 + timeout-minutes: 5 + steps: - name: Verify CLA checks for queued pull requests - if: github.event_name == 'merge_group' env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} BASE_SHA: ${{ github.event.merge_group.base_sha }} @@ -116,3 +130,36 @@ jobs: exit 1 fi done + + CLAAssistant: + # Keep one required check name while isolating the write-capable action + # from the read-only queue check. Failed or skipped required work fails closed. + needs: [cla-signatures, cla-merge-queue] + permissions: + contents: none + if: >- + always() && + github.repository_owner == 'reallyme' && + toJSON(github.event.repository.private) == 'false' && + (github.event.repository.visibility == null || github.event.repository.visibility == 'public') && + (github.event_name != 'issue_comment' || + (github.event.issue.pull_request && + (github.event.comment.body == 'recheck' || + contains(github.event.comment.body, 'I have read the CLA Document and I hereby sign the CLA')))) + runs-on: ubuntu-24.04 + timeout-minutes: 5 + steps: + - name: Require the applicable CLA result + env: + SIGNATURE_RESULT: ${{ needs.cla-signatures.result }} + QUEUE_RESULT: ${{ needs.cla-merge-queue.result }} + shell: bash + run: | + set -euo pipefail + case "$GITHUB_EVENT_NAME" in + pull_request_target|issue_comment) + [[ "$SIGNATURE_RESULT" == success && "$QUEUE_RESULT" == skipped ]] ;; + merge_group) + [[ "$QUEUE_RESULT" == success && "$SIGNATURE_RESULT" == skipped ]] ;; + *) exit 1 ;; + esac diff --git a/.github/workflows/code-checks.yml b/.github/workflows/code-checks.yml index 1b2b429b..130e6158 100644 --- a/.github/workflows/code-checks.yml +++ b/.github/workflows/code-checks.yml @@ -35,7 +35,7 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: repository: reallyme/release-readiness - ref: e323ea52bc1f76e67df03fc95e19d596fb54bd03 + ref: 16aab5287de498e858ff3b85d9e66d7c9f7ebb74 path: .release-readiness persist-credentials: false diff --git a/.github/workflows/crates-package-preflight.yml b/.github/workflows/crates-package-preflight.yml index 8909d76e..b54113e2 100644 --- a/.github/workflows/crates-package-preflight.yml +++ b/.github/workflows/crates-package-preflight.yml @@ -64,7 +64,7 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: repository: reallyme/release-readiness - ref: e323ea52bc1f76e67df03fc95e19d596fb54bd03 + ref: 16aab5287de498e858ff3b85d9e66d7c9f7ebb74 path: .release-readiness persist-credentials: false @@ -78,6 +78,12 @@ jobs: with: toolchain: 1.100.0 + - name: Install dependency maintenance tools + uses: taiki-e/install-action@75a7c0f87bd666af3cdb75c5b9e9d03ab6044e6f # v2.90.6 + with: + tool: cargo-audit@0.23.0,cargo-outdated@0.19.0 + fallback: none + - name: Authenticate release-readiness package run: node scripts/run_pinned_release_readiness.mjs --check-pins @@ -128,7 +134,7 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: repository: reallyme/release-readiness - ref: e323ea52bc1f76e67df03fc95e19d596fb54bd03 + ref: 16aab5287de498e858ff3b85d9e66d7c9f7ebb74 path: .release-readiness persist-credentials: false diff --git a/.github/workflows/crates-release.yml b/.github/workflows/crates-release.yml index 19ed78cd..32ffa552 100644 --- a/.github/workflows/crates-release.yml +++ b/.github/workflows/crates-release.yml @@ -71,7 +71,7 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: repository: reallyme/release-readiness - ref: e323ea52bc1f76e67df03fc95e19d596fb54bd03 + ref: 16aab5287de498e858ff3b85d9e66d7c9f7ebb74 path: .release-readiness persist-credentials: false @@ -118,7 +118,7 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: repository: reallyme/release-readiness - ref: e323ea52bc1f76e67df03fc95e19d596fb54bd03 + ref: 16aab5287de498e858ff3b85d9e66d7c9f7ebb74 path: .release-readiness persist-credentials: false diff --git a/.github/workflows/kotlin-android-package-preflight.yml b/.github/workflows/kotlin-android-package-preflight.yml index eeb04cde..217cd183 100644 --- a/.github/workflows/kotlin-android-package-preflight.yml +++ b/.github/workflows/kotlin-android-package-preflight.yml @@ -66,7 +66,7 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: repository: reallyme/release-readiness - ref: e323ea52bc1f76e67df03fc95e19d596fb54bd03 + ref: 16aab5287de498e858ff3b85d9e66d7c9f7ebb74 path: .release-readiness persist-credentials: false @@ -80,6 +80,12 @@ jobs: with: toolchain: 1.100.0 + - name: Install dependency maintenance tools + uses: taiki-e/install-action@75a7c0f87bd666af3cdb75c5b9e9d03ab6044e6f # v2.90.6 + with: + tool: cargo-audit@0.23.0,cargo-outdated@0.19.0 + fallback: none + - name: Authenticate release-readiness package run: node scripts/run_pinned_release_readiness.mjs --check-pins @@ -150,7 +156,7 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: repository: reallyme/release-readiness - ref: e323ea52bc1f76e67df03fc95e19d596fb54bd03 + ref: 16aab5287de498e858ff3b85d9e66d7c9f7ebb74 path: .release-readiness persist-credentials: false @@ -214,7 +220,7 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: repository: reallyme/release-readiness - ref: e323ea52bc1f76e67df03fc95e19d596fb54bd03 + ref: 16aab5287de498e858ff3b85d9e66d7c9f7ebb74 path: .release-readiness persist-credentials: false @@ -306,7 +312,7 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: repository: reallyme/release-readiness - ref: e323ea52bc1f76e67df03fc95e19d596fb54bd03 + ref: 16aab5287de498e858ff3b85d9e66d7c9f7ebb74 path: .release-readiness persist-credentials: false diff --git a/.github/workflows/kotlin-android-package-release.yml b/.github/workflows/kotlin-android-package-release.yml index 43dc81f8..3341516c 100644 --- a/.github/workflows/kotlin-android-package-release.yml +++ b/.github/workflows/kotlin-android-package-release.yml @@ -71,7 +71,7 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: repository: reallyme/release-readiness - ref: e323ea52bc1f76e67df03fc95e19d596fb54bd03 + ref: 16aab5287de498e858ff3b85d9e66d7c9f7ebb74 path: .release-readiness persist-credentials: false @@ -119,7 +119,7 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: repository: reallyme/release-readiness - ref: e323ea52bc1f76e67df03fc95e19d596fb54bd03 + ref: 16aab5287de498e858ff3b85d9e66d7c9f7ebb74 path: .release-readiness persist-credentials: false diff --git a/.github/workflows/npm-package-preflight.yml b/.github/workflows/npm-package-preflight.yml index c22b0502..c2f4840f 100644 --- a/.github/workflows/npm-package-preflight.yml +++ b/.github/workflows/npm-package-preflight.yml @@ -64,7 +64,7 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: repository: reallyme/release-readiness - ref: e323ea52bc1f76e67df03fc95e19d596fb54bd03 + ref: 16aab5287de498e858ff3b85d9e66d7c9f7ebb74 path: .release-readiness persist-credentials: false @@ -78,6 +78,12 @@ jobs: with: toolchain: 1.100.0 + - name: Install dependency maintenance tools + uses: taiki-e/install-action@75a7c0f87bd666af3cdb75c5b9e9d03ab6044e6f # v2.90.6 + with: + tool: cargo-audit@0.23.0,cargo-outdated@0.19.0 + fallback: none + - name: Authenticate release-readiness package run: node scripts/run_pinned_release_readiness.mjs --check-pins @@ -134,7 +140,7 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: repository: reallyme/release-readiness - ref: e323ea52bc1f76e67df03fc95e19d596fb54bd03 + ref: 16aab5287de498e858ff3b85d9e66d7c9f7ebb74 path: .release-readiness persist-credentials: false diff --git a/.github/workflows/npm-package-release.yml b/.github/workflows/npm-package-release.yml index 05053e4c..08ed6ccc 100644 --- a/.github/workflows/npm-package-release.yml +++ b/.github/workflows/npm-package-release.yml @@ -71,7 +71,7 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: repository: reallyme/release-readiness - ref: e323ea52bc1f76e67df03fc95e19d596fb54bd03 + ref: 16aab5287de498e858ff3b85d9e66d7c9f7ebb74 path: .release-readiness persist-credentials: false @@ -119,7 +119,7 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: repository: reallyme/release-readiness - ref: e323ea52bc1f76e67df03fc95e19d596fb54bd03 + ref: 16aab5287de498e858ff3b85d9e66d7c9f7ebb74 path: .release-readiness persist-credentials: false diff --git a/.github/workflows/release-readiness.yml b/.github/workflows/release-readiness.yml index f9eb8bf4..7a7938e6 100644 --- a/.github/workflows/release-readiness.yml +++ b/.github/workflows/release-readiness.yml @@ -34,7 +34,7 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: repository: reallyme/release-readiness - ref: e323ea52bc1f76e67df03fc95e19d596fb54bd03 + ref: 16aab5287de498e858ff3b85d9e66d7c9f7ebb74 path: .release-readiness persist-credentials: false diff --git a/.github/workflows/swift-package-preflight.yml b/.github/workflows/swift-package-preflight.yml index 3bcd3b35..85b8add5 100644 --- a/.github/workflows/swift-package-preflight.yml +++ b/.github/workflows/swift-package-preflight.yml @@ -64,7 +64,7 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: repository: reallyme/release-readiness - ref: e323ea52bc1f76e67df03fc95e19d596fb54bd03 + ref: 16aab5287de498e858ff3b85d9e66d7c9f7ebb74 path: .release-readiness persist-credentials: false @@ -78,6 +78,12 @@ jobs: with: toolchain: 1.100.0 + - name: Install dependency maintenance tools + uses: taiki-e/install-action@75a7c0f87bd666af3cdb75c5b9e9d03ab6044e6f # v2.90.6 + with: + tool: cargo-audit@0.23.0,cargo-outdated@0.19.0 + fallback: none + - name: Authenticate release-readiness package run: node scripts/run_pinned_release_readiness.mjs --check-pins @@ -134,7 +140,7 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: repository: reallyme/release-readiness - ref: e323ea52bc1f76e67df03fc95e19d596fb54bd03 + ref: 16aab5287de498e858ff3b85d9e66d7c9f7ebb74 path: .release-readiness persist-credentials: false diff --git a/.github/workflows/swift-package-release.yml b/.github/workflows/swift-package-release.yml index 4c0717e3..9166e003 100644 --- a/.github/workflows/swift-package-release.yml +++ b/.github/workflows/swift-package-release.yml @@ -71,7 +71,7 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: repository: reallyme/release-readiness - ref: e323ea52bc1f76e67df03fc95e19d596fb54bd03 + ref: 16aab5287de498e858ff3b85d9e66d7c9f7ebb74 path: .release-readiness persist-credentials: false @@ -118,7 +118,7 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: repository: reallyme/release-readiness - ref: e323ea52bc1f76e67df03fc95e19d596fb54bd03 + ref: 16aab5287de498e858ff3b85d9e66d7c9f7ebb74 path: .release-readiness persist-credentials: false @@ -183,7 +183,7 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: repository: reallyme/release-readiness - ref: e323ea52bc1f76e67df03fc95e19d596fb54bd03 + ref: 16aab5287de498e858ff3b85d9e66d7c9f7ebb74 path: .release-readiness persist-credentials: false diff --git a/scripts/check_ignored_files.mjs b/scripts/check_ignored_files.mjs index 72f45ea9..ac46dcf3 100644 --- a/scripts/check_ignored_files.mjs +++ b/scripts/check_ignored_files.mjs @@ -65,6 +65,8 @@ try { } const { assertRepositoryPrivacy, assertPushPrivacy } = await import("../.release-readiness/scripts/repository-privacy.mjs"); + const { assertDocumentationPolicy } = + await import("../.release-readiness/scripts/documentation-policy.mjs"); if (args[0] === "--pre-push") { assertPushPrivacy({ updates: readInput() }); } else if (args[0] === "--history") { @@ -77,6 +79,9 @@ try { assertPushPrivacy({ updates: `HEAD ${tip} refs/heads/main ${"0".repeat(tip.length)}\n` }); } else { assertRepositoryPrivacy(); + // Match the exact staged bytes that Git will commit, including policy + // declarations; unstaged edits must not hide a staged work report. + assertDocumentationPolicy({ staged: true }); } console.log("tracked files respect committed ignore rules"); } catch (error) { diff --git a/scripts/check_ignored_files.test.mjs b/scripts/check_ignored_files.test.mjs index 8ea9fb0d..fba14676 100644 --- a/scripts/check_ignored_files.test.mjs +++ b/scripts/check_ignored_files.test.mjs @@ -67,6 +67,32 @@ test("clean index passes and explicit negations remain supported", (t) => { assert.equal(check().status, 0); }); +test("staged work reports fail even when unstaged bytes look like a README", (t) => { + const { git, write, check } = fixture(t); + write("README.md", "# Task summary\n\nPrivate working notes.\n"); + git("add", "README.md"); + write("README.md", "# Public package\n"); + const result = check(); + assert.equal(result.status, 1); + assert.match(result.stderr, /TRANSIENT_DOCUMENTATION_CONTENT/u); +}); + +test("custom public guides require a staged declaration", (t) => { + const { git, write, check } = fixture(t); + write("docs/api.md", "# Public API\n"); + git("add", "docs/api.md"); + write(".github/documentation-policy.json", JSON.stringify({ + schema: 1, + documents: [{ + path: "docs/api.md", kind: "reference", + purpose: "Describe the supported public API and compatibility guarantees.", + }], + })); + assert.equal(check().status, 1); + git("add", ".github/documentation-policy.json"); + assert.equal(check().status, 0); +}); + test("force-added ignored files fail including newline paths", (t) => { const { git, write, check } = fixture(t); write(".gitignore", "*.env\n"); @@ -189,6 +215,19 @@ test("history rejects ignored files even when a later commit removes them", (t) assert.match(result.stderr, /"private\\nvalue\.env"/u); }); +test("history rejects work reports deleted before the pushed tip", (t) => { + const { git, write, check } = fixture(t); + write("README.md", "# Task summary\n\nPrivate working notes.\n"); + git("add", "README.md"); + git("-c", "commit.gpgsign=false", "commit", "--quiet", "-m", "Add fixture files"); + git("rm", "README.md"); + git("-c", "commit.gpgsign=false", "commit", "--quiet", "-m", "Update fixture files"); + assert.equal(check().status, 0); + const result = check("--history"); + assert.equal(result.status, 1); + assert.match(result.stderr, /TRANSIENT_DOCUMENTATION_CONTENT/u); +}); + test("clean complete history passes while shallow history fails closed", (t) => { const { root, git, write, check } = fixture(t); write(".gitignore", "*.env\n"); diff --git a/scripts/check_release_readiness.mjs b/scripts/check_release_readiness.mjs index 69c58ecc..6dfc2ea8 100644 --- a/scripts/check_release_readiness.mjs +++ b/scripts/check_release_readiness.mjs @@ -324,7 +324,7 @@ const assertTypescriptProtoFacadeCompleteness = ({ facadePath, generatedPath }) }); }; -assertReallyMeReleasePackagePolicy({ version: "0.9.7" }); +assertReallyMeReleasePackagePolicy({ version: "0.9.9" }); const rustChecks = ".github/workflows/code-checks.yml"; assertRustReleasePolicy({ release: { workflow: rustChecks, job: "rust", step: "Test on the release toolchain" }, @@ -875,11 +875,11 @@ assertContains( ); assertContains( "scripts/run_pinned_release_readiness.mjs", - 'const RELEASE_READINESS_COMMIT = "e323ea52bc1f76e67df03fc95e19d596fb54bd03"', + 'const RELEASE_READINESS_COMMIT = "16aab5287de498e858ff3b85d9e66d7c9f7ebb74"', ); assertContains( "scripts/run_pinned_release_readiness.mjs", - '"825ebca65a1324ea7cf42713ca5c4c67b0d929444d24dcaf7500fc9fa0ca7e20"', + '"56ae3823215f5bca908d2fce3c9304d4ea6bab0334038f37ebe33023dadb8594"', ); assertContains( "scripts/run_pinned_release_readiness.mjs", @@ -2003,7 +2003,12 @@ assertWorkflowPermissionsPolicy({ }); assertWorkflowPermissionsPolicy({ path: ".github/workflows/cla.yaml", - workflow: { actions: "write", checks: "read", contents: "write", "pull-requests": "write", statuses: "write" }, + workflow: { contents: "read" }, + jobs: { + "cla-signatures": { actions: "write", contents: "write", "pull-requests": "write" }, + "cla-merge-queue": { actions: "read", contents: "read", "pull-requests": "read" }, + CLAAssistant: { contents: "none" }, + }, }); const readOnlyWorkflowPaths = [ ".github/workflows/ci.yml", @@ -2979,7 +2984,9 @@ assertContains("packages/kotlin-android/settings.gradle.kts", "exclusiveContent" assertContains("packages/kotlin-android/consumer-r8-runtime/build.gradle.kts", "me.really:codec-android:${rootProject.version}"); assertContains("scripts/stage-android-publication.sh", "verifyReleaseAarContainsJniLibs"); assertContains("scripts/test-android-runtime.sh", 'ANDROID_R8_PAGE_SIZE_BYTES="16384"'); -assertContains("scripts/prepare-android-runtime.sh", "google_apis_ps16k"); +assertContains("scripts/prepare-android-runtime.sh", 'bash "$REPO_ROOT/scripts/prepare-android-avd.sh" "$AVD_NAME"'); +assertContains("scripts/prepare-android-avd.sh", "google_apis_ps16k"); +assertContains("scripts/prepare-android-avd.sh", 'COMMAND_LINE_TOOLS_VERSION="23.0"'); assertSubstringsInOrder(".github/workflows/kotlin-android-package-preflight.yml", [ "Download tested Android publication", "Verify tested Android publication", "Upload tested Android publication", ]); diff --git a/scripts/pinned_release_readiness.test.mjs b/scripts/pinned_release_readiness.test.mjs index 012fd968..d3150899 100644 --- a/scripts/pinned_release_readiness.test.mjs +++ b/scripts/pinned_release_readiness.test.mjs @@ -242,16 +242,22 @@ for (const [extension, language] of [["rs", "rust"], ["ts", "typescript"], ["swi }); } -test("a tampered module imported by the official runner fails authentication before execution", (t) => { - const f = fixture(t); - const module = "scripts/public-ci.mjs"; - const path = join(f.root, ".release-readiness", module); - writeFileSync(path, `${readFileSync(path, "utf8")}\nprocess.exit(94);\n`); - const result = f.run(); - assert.equal(result.status, 1); - assert.match(result.stderr, /package scripts\/public-ci\.mjs does not match the reviewed upstream pin/u); - assert.equal(existsSync(join(f.root, "checker-executed")), false); -}); +for (const module of [ + "scripts/public-ci.mjs", + "scripts/dependency-maintenance.mjs", + "scripts/dependency-versions.mjs", + "scripts/documentation-policy.mjs", +]) { + test(`tampered ${module} fails authentication before execution`, (t) => { + const f = fixture(t); + const path = join(f.root, ".release-readiness", module); + writeFileSync(path, `${readFileSync(path, "utf8")}\nprocess.exit(94);\n`); + const result = f.run(); + assert.equal(result.status, 1); + assert.ok(result.stderr.includes(`package ${module} does not match the reviewed upstream pin`)); + assert.equal(existsSync(join(f.root, "checker-executed")), false); + }); +} test("pin-only verification does not execute the checker", (t) => { const f = fixture(t); diff --git a/scripts/prepare-android-avd.sh b/scripts/prepare-android-avd.sh new file mode 100755 index 00000000..0f68175c --- /dev/null +++ b/scripts/prepare-android-avd.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash +# SPDX-FileCopyrightText: 2026 ReallyMe Technologies Limited +# +# SPDX-License-Identifier: MIT OR Apache-2.0 + +set -euo pipefail + +if [[ $# != 1 || ! "$1" =~ ^[a-zA-Z0-9_-]+$ ]]; then + printf 'usage: %s avd-name\n' "$0" >&2 + exit 2 +fi +readonly AVD_NAME="$1" +readonly ANDROID_HOME_VALUE="${ANDROID_HOME:?Android SDK path is required}" +export ANDROID_AVD_HOME="${ANDROID_AVD_HOME:?isolated Android AVD home is required}" +if [[ "$ANDROID_HOME_VALUE" != /* || "$ANDROID_AVD_HOME" != /* ]]; then + printf 'Android SDK and AVD directories must be absolute\n' >&2 + exit 2 +fi +readonly COMMAND_LINE_TOOLS_VERSION="23.0" +readonly TOOL_PROPERTIES="$ANDROID_HOME_VALUE/cmdline-tools/$COMMAND_LINE_TOOLS_VERSION/source.properties" +readonly SDKMANAGER="$ANDROID_HOME_VALUE/cmdline-tools/$COMMAND_LINE_TOOLS_VERSION/bin/sdkmanager" +readonly AVDMANAGER="$ANDROID_HOME_VALUE/cmdline-tools/$COMMAND_LINE_TOOLS_VERSION/bin/avdmanager" +readonly ANDROID_R8_PLATFORM="platforms;android-37.0" +readonly ANDROID_R8_IMAGE_TARGET="android-37.1" +readonly ANDROID_R8_SYSTEM_IMAGE="system-images;$ANDROID_R8_IMAGE_TARGET;google_apis_ps16k;x86_64" + +# Older hosted tools silently write android-0 for minor-version images, which +# disables emulator graphics features and can crash SurfaceFlinger. Install +# beside the hosted tools and select the reviewed version by its explicit path. +if [[ ! -x "$SDKMANAGER" || ! -x "$AVDMANAGER" ]]; then + { yes 2>/dev/null || true; } | + "$ANDROID_HOME_VALUE/cmdline-tools/latest/bin/sdkmanager" --install "cmdline-tools;$COMMAND_LINE_TOOLS_VERSION" +fi +if [[ ! -x "$SDKMANAGER" || ! -x "$AVDMANAGER" ]]; then + printf 'Pinned Android command-line tools are unavailable\n' >&2 + exit 1 +fi +# sdkmanager now delegates to Android CLI, whose --version identifies that +# CLI rather than this SDK bundle. Check the installed package revision. +if ! tool_version="$(LC_ALL=C sed -n 's/^Pkg\.Revision=//p' "$TOOL_PROPERTIES" 2>/dev/null)" || + [[ "$tool_version" != "$COMMAND_LINE_TOOLS_VERSION" ]]; then + printf 'Pinned Android command-line tools have an unexpected version\n' >&2 + exit 1 +fi + +mkdir -p "$ANDROID_AVD_HOME" +{ yes 2>/dev/null || true; } | "$SDKMANAGER" "emulator" "$ANDROID_R8_PLATFORM" "$ANDROID_R8_SYSTEM_IMAGE" +printf 'no\n' | "$AVDMANAGER" create avd --force -n "$AVD_NAME" -k "$ANDROID_R8_SYSTEM_IMAGE" --device pixel + +# Reject a silently misparsed target before spending the boot budget on an +# emulator whose metadata cannot represent the system image being tested. +if ! LC_ALL=C grep -Fxq -- "target=$ANDROID_R8_IMAGE_TARGET" "$ANDROID_AVD_HOME/$AVD_NAME.ini"; then + printf 'Android AVD target does not match the pinned system image\n' >&2 + exit 1 +fi diff --git a/scripts/prepare-android-runtime.sh b/scripts/prepare-android-runtime.sh index 811fc6dc..e30a4d8c 100755 --- a/scripts/prepare-android-runtime.sh +++ b/scripts/prepare-android-runtime.sh @@ -14,17 +14,7 @@ fi readonly APK_PATH="$1" readonly AVD_NAME="$2" readonly MAVEN_REPOSITORY="$3" -readonly ANDROID_HOME_VALUE="${ANDROID_HOME:?Android SDK path is required}" -readonly SDKMANAGER="$ANDROID_HOME_VALUE/cmdline-tools/latest/bin/sdkmanager" -readonly AVDMANAGER="$ANDROID_HOME_VALUE/cmdline-tools/latest/bin/avdmanager" -readonly ANDROID_R8_PLATFORM="platforms;android-37.0" -readonly ANDROID_R8_SYSTEM_IMAGE="system-images;android-37.1;google_apis_ps16k;x86_64" -export ANDROID_AVD_HOME="${ANDROID_AVD_HOME:?isolated Android AVD home is required}" -mkdir -p "$ANDROID_AVD_HOME" - -{ yes 2>/dev/null || true; } | "$SDKMANAGER" "emulator" "$ANDROID_R8_PLATFORM" "$ANDROID_R8_SYSTEM_IMAGE" -# Use the same hardware profile as the Android R8 runtime workflow. -printf 'no\n' | "$AVDMANAGER" create avd --force -n "$AVD_NAME" -k "$ANDROID_R8_SYSTEM_IMAGE" --device pixel +bash "$REPO_ROOT/scripts/prepare-android-avd.sh" "$AVD_NAME" # The published AAR is a new dependency on every CI candidate. Bind its # sealed bytes into an isolated copy of the consumer's strict verification diff --git a/scripts/prepare_android_avd.test.mjs b/scripts/prepare_android_avd.test.mjs new file mode 100644 index 00000000..871be2e0 --- /dev/null +++ b/scripts/prepare_android_avd.test.mjs @@ -0,0 +1,138 @@ +// SPDX-FileCopyrightText: 2026 ReallyMe Technologies Limited +// +// SPDX-License-Identifier: MIT OR Apache-2.0 + +import assert from "node:assert/strict"; +import { spawnSync } from "node:child_process"; +import { cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { dirname, join } from "node:path"; +import test from "node:test"; +import { fileURLToPath } from "node:url"; + +const script = fileURLToPath(new URL("./prepare-android-avd.sh", import.meta.url)); + +function fixture(t, { installed = false } = {}) { + const root = mkdtempSync(join(tmpdir(), "codec Android tools # ")); + t.after(() => rmSync(root, { recursive: true, force: true })); + const writeTool = (path, source) => { + const destination = join(root, path); + mkdirSync(dirname(destination), { recursive: true }); + writeFileSync(destination, `#!/usr/bin/env node\n${source}`, { mode: 0o700 }); + }; + writeTool("tools/sdkmanager", ` + import assert from "node:assert/strict"; + import { appendFileSync } from "node:fs"; + const args = process.argv.slice(2); + const event = (value) => appendFileSync(process.env.FIXTURE_ROOT + "/events", value + "\\n"); + if (args[0] === "--version") { + event("version"); + console.log("1.0.16111833"); + process.exit(0); + } + assert.deepEqual(args, ["emulator", "platforms;android-37.0", "system-images;android-37.1;google_apis_ps16k;x86_64"]); + event("packages"); + process.exit(Number(process.env.FIXTURE_PACKAGES_EXIT ?? "0")); + `); + writeFileSync(join(root, "tools/source.properties"), "Pkg.Revision=23.0\nPkg.Path=cmdline-tools;23.0\n"); + writeTool("tools/avdmanager", ` + import assert from "node:assert/strict"; + import { appendFileSync, writeFileSync } from "node:fs"; + import { join } from "node:path"; + assert.deepEqual(process.argv.slice(2), ["create", "avd", "--force", "-n", "consumer-test", "-k", + "system-images;android-37.1;google_apis_ps16k;x86_64", "--device", "pixel"]); + appendFileSync(process.env.FIXTURE_ROOT + "/events", "avd\\n"); + if (process.env.FIXTURE_TARGET !== "missing") { + writeFileSync(join(process.env.ANDROID_AVD_HOME, "consumer-test.ini"), + "target=" + (process.env.FIXTURE_TARGET ?? "android-37.1") + "\\n"); + } + `); + writeTool("sdk/cmdline-tools/latest/bin/sdkmanager", ` + import assert from "node:assert/strict"; + import { appendFileSync, cpSync, mkdirSync } from "node:fs"; + import { join } from "node:path"; + assert.deepEqual(process.argv.slice(2), ["--install", "cmdline-tools;23.0"]); + const root = process.env.FIXTURE_ROOT; + appendFileSync(root + "/events", "install\\n"); + if (process.env.FIXTURE_INSTALL_EXIT !== undefined) process.exit(Number(process.env.FIXTURE_INSTALL_EXIT)); + const destination = join(process.env.ANDROID_HOME, "cmdline-tools/23.0/bin"); + mkdirSync(destination, { recursive: true }); + for (const tool of ["sdkmanager", "avdmanager"]) cpSync(join(root, "tools", tool), join(destination, tool)); + cpSync(join(root, "tools/source.properties"), join(destination, "../source.properties")); + `); + if (installed) { + mkdirSync(join(root, "sdk/cmdline-tools/23.0/bin"), { recursive: true }); + for (const tool of ["sdkmanager", "avdmanager"]) { + cpSync(join(root, "tools", tool), join(root, "sdk/cmdline-tools/23.0/bin", tool)); + } + cpSync(join(root, "tools/source.properties"), join(root, "sdk/cmdline-tools/23.0/source.properties")); + } + const run = (overrides = {}, args = ["consumer-test"]) => spawnSync("bash", [script, ...args], { + encoding: "utf8", timeout: 30_000, + env: { + ...process.env, FIXTURE_ROOT: root, + ANDROID_HOME: join(root, "sdk"), ANDROID_AVD_HOME: join(root, "avd"), ...overrides, + }, + }); + const events = () => existsSync(join(root, "events")) ? readFileSync(join(root, "events"), "utf8").trim().split("\n") : []; + const metadata = (contents) => { + const path = join(root, "sdk/cmdline-tools/23.0/source.properties"); + if (contents === undefined) rmSync(path); + else writeFileSync(path, contents); + }; + return { run, events, metadata }; +} + +test("AVD creation installs and selects pinned tools before validating the image target", (t) => { + const { run, events } = fixture(t); + const result = run(); + assert.equal(result.status, 0, result.stderr); + assert.deepEqual(events(), ["install", "packages", "avd"]); +}); + +test("installed bundle metadata is checked independently of the delegated CLI version", (t) => { + const { run, events } = fixture(t, { installed: true }); + const result = run({ FIXTURE_INSTALL_EXIT: "37" }); + assert.equal(result.status, 0, result.stderr); + assert.deepEqual(events(), ["packages", "avd"]); +}); + +test("a failed pinned tools installation cannot fall back to the hosted tools", (t) => { + const { run, events } = fixture(t); + assert.equal(run({ FIXTURE_INSTALL_EXIT: "37" }).status, 37); + assert.deepEqual(events(), ["install"]); +}); + +test("wrong, ambiguous and missing bundle revisions stop before invoking tools", (t) => { + for (const contents of ["Pkg.Revision=12.0\n", "Pkg.Revision=23.0\nPkg.Revision=12.0\n", undefined]) { + const { run, events, metadata } = fixture(t, { installed: true }); + metadata(contents); + const result = run(); + assert.equal(result.status, 1); + assert.match(result.stderr, /unexpected version/u); + assert.deepEqual(events(), []); + } +}); + +test("failed image installation stops before AVD creation", (t) => { + const { run, events } = fixture(t, { installed: true }); + assert.equal(run({ FIXTURE_PACKAGES_EXIT: "39" }).status, 39); + assert.deepEqual(events(), ["packages"]); +}); + +test("android-0, other image targets and missing metadata fail before emulator boot", (t) => { + for (const target of ["android-0", "android-37.0", "missing"]) { + const { run } = fixture(t, { installed: true }); + const result = run({ FIXTURE_TARGET: target }); + assert.equal(result.status, 1); + assert.match(result.stderr, /target does not match/u); + } +}); + +test("unsafe AVD names and relative SDK paths fail before invoking tools", (t) => { + const { run, events } = fixture(t); + for (const args of [[], ["../escape"], ["bad;name"]]) assert.equal(run({}, args).status, 2); + assert.equal(run({ ANDROID_HOME: "relative/sdk" }).status, 2); + assert.equal(run({ ANDROID_AVD_HOME: "relative/avd" }).status, 2); + assert.deepEqual(events(), []); +}); diff --git a/scripts/repository_privacy_workflows.test.mjs b/scripts/repository_privacy_workflows.test.mjs index 2672caaf..c0dd13b5 100644 --- a/scripts/repository_privacy_workflows.test.mjs +++ b/scripts/repository_privacy_workflows.test.mjs @@ -27,6 +27,13 @@ for (const [name, packageBoundaries] of workflows) { const history = source.indexOf("run: node scripts/check_ignored_files.mjs --history"); const admission = source.indexOf(" - name: Verify release candidate\n"); assert.ok(history > runner && history < admission); + if (name.includes("preflight")) { + const maintenanceTools = source.indexOf(" - name: Install dependency maintenance tools\n"); + assert.ok(maintenanceTools > runner && maintenanceTools < admission); + const verificationJob = source.slice(maintenanceTools, admission); + assert.match(verificationJob, /tool: cargo-audit@0\.23\.0,cargo-outdated@0\.19\.0/u); + assert.match(verificationJob, /fallback: none/u); + } const checks = source.match(/- name: Verify publication privacy/gu) ?? []; assert.equal(checks.length, packageBoundaries + (name.includes("preflight") ? 1 : 0)); for (const step of source.split(" - name: ").slice(1)) { diff --git a/scripts/run_pinned_release_readiness.mjs b/scripts/run_pinned_release_readiness.mjs index a75b1924..7b20cd35 100644 --- a/scripts/run_pinned_release_readiness.mjs +++ b/scripts/run_pinned_release_readiness.mjs @@ -12,26 +12,29 @@ import { resolve, sep } from "node:path"; // Verify the immutable official package before executing its runner. Local // checker/module digests remain review tripwires; the package runner supplies // the core and enforces proof that every applicable source policy was invoked. -const RELEASE_READINESS_COMMIT = "e323ea52bc1f76e67df03fc95e19d596fb54bd03"; +const RELEASE_READINESS_COMMIT = "16aab5287de498e858ff3b85d9e66d7c9f7ebb74"; const RELEASE_READINESS_CORE_SHA256 = - "825ebca65a1324ea7cf42713ca5c4c67b0d929444d24dcaf7500fc9fa0ca7e20"; + "56ae3823215f5bca908d2fce3c9304d4ea6bab0334038f37ebe33023dadb8594"; const LOCAL_CHECKER_SHA256 = - "def0bc8edb898cb1fe18aa9c6dd5801d4ecce618a72623c391b980882600c1f9"; + "9e4ea61218581b336506f27595a0ba0c947aaca5e086d8c66beedc06468b3236"; const RELEASE_READINESS_CORE_URL = `https://raw.githubusercontent.com/reallyme/release-readiness/${RELEASE_READINESS_COMMIT}/core.mjs`; const RELEASE_READINESS_RUNNER_SHA256 = - "3486696ab93190b627438a6aa7248e972872c83b4efc62286aecb1f60ee3783c"; + "952e4770e7380269e497b9700c48766ec614f250b53ca8f4773cc16842d445b4"; const RELEASE_READINESS_PACKAGE_SHA256 = - "c5de23339bcd17107f63a2b467c1c0441a2695f0c12a786ced2b491d7c7a425f"; + "6ad52751e8bdecb5fe6298f399201dacf2b4146e1c500f5c1f00a4436ab085df"; const RELEASE_READINESS_SUPPORT_FILES = [ - ["scripts/publication-paths.py", "45d3485bc03f4a73f955942648b13e5fba8f06d450326eb13c7b0df2ad518caf"], - ["scripts/repository-privacy.mjs", "6c8f44bf810e947fcbe3e0a9e45cdaac007009a5fe719f0ca928bc5bbd04c346"], + ["scripts/publication-paths.py", "34de1a347aae95feb873f978ccf1357e5c9ee0d668965c669f636163c6eabe18"], + ["scripts/repository-privacy.mjs", "545d02c0bfb5a50623c7439761fb329c2eb0299ee3d182ea1c14f6078a85faa8"], ["scripts/public-ci.mjs", "9b64390152f9b440f2045a6f2bd91965ce7c09c12b5b0eb41e20298bbab22686"], ["scripts/public-release.mjs", "187ac87a288d14bdfaec38a2e22a547dcda8fa7df8f3a8701063306ea2bd78e0"], ["scripts/public-repo-policy.mjs", "fdad8fe9c0e85043b764a0321558af7a85324bceb7724c693a2824d955b0a204"], ["scripts/android-runtime.mjs", "5e80d5dee4a1ac225dfe155dd6d5477e1c52bc18be103f7b6fef181a0d4cb3c9"], ["scripts/android-publication.mjs", "539660a91b7b9150a9d85cafff35c5bbefd97a57541d2343f55f1d1243e3be7b"], - ["templates/cla.yaml", "3c5e89c5753d128643e5862e6baeb6b97c4f0ce1d6ef158cf46db3deeec6b955"], + ["templates/cla.yaml", "7330ffa42b9a514642b4c59755164fe8d612661d4c216590fc24d991f80c045b"], + ["scripts/dependency-maintenance.mjs", "3c715b69db5012675f5ed84c149da4b9289effac0e35cd021a62cc9809249723"], + ["scripts/dependency-versions.mjs", "56c2a16283aceb05121d1038bdf9e1d99de130d1d24d296ec2eb544847a07003"], + ["scripts/documentation-policy.mjs", "c9cc9393cd8e3c93a5e835841e4d34c5837ca8858a27e8b717c00ce9ea6b5301"], ]; const LOCAL_CHECKER_PATH = "scripts/check_release_readiness.mjs"; const MAX_CORE_BYTES = 262_144;