Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Run frontend unit and runtime proof as independent required jobs

pulse-triage[bot]b9c611d521ec
diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml
index 11e0602277..dcb6208a9a 100644
--- a/.github/workflows/build-and-test.yml
+++ b/.github/workflows/build-and-test.yml
@@ -255,16 +255,17 @@ jobs:
grep -q '^--- PASS: TestIntegrationProviderPairNetworkIsolation ' \
"$RUNNER_TEMP/provider-pair-network-test.log"
- frontend-checks:
- name: Frontend build and runtime
+ frontend-build:
+ name: Frontend build and audit
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: ubuntu-24.04
- # Keep the original bounded audit and build/runtime deadline. Unit proof
- # follows in isolated file shards instead of one 650-second serial step.
+ # Fail type/build/size admission before spending on unit or runtime jobs.
+ # Their independent work can then overlap without repeating this build.
timeout-minutes: 30
outputs:
unit_admitted: ${{ steps.unit-admission.outputs.admitted }}
+ embed_sha256: ${{ steps.embed-packet.outputs.sha256 }}
env:
FRONTEND_DIR: frontend-modern
@@ -347,7 +348,99 @@ jobs:
working-directory: frontend-modern
run: npm run check:bundlesize
- # Use this checkout's production assets, not another job's embed stub.
+ # Transfer exactly this checked build, never a second build or a stub.
+ # The consumer verifies the producer digest before safe extraction.
+ - name: Bind the validated frontend embed
+ id: embed-packet
+ env:
+ EXPECTED_SOURCE_SHA: ${{ github.sha }}
+ run: |
+ set -euo pipefail
+ test "$(git rev-parse HEAD)" = "$EXPECTED_SOURCE_SHA"
+ test -s frontend-modern/dist/index.html
+ test -d frontend-modern/dist/assets
+ diff -qr --no-dereference frontend-modern/dist internal/api/frontend-modern/dist
+ tar -cf "$RUNNER_TEMP/frontend-embed.tar" frontend-modern/dist internal/api/frontend-modern/dist
+ digest=$(sha256sum "$RUNNER_TEMP/frontend-embed.tar")
+ echo "sha256=${digest%% *}" >> "$GITHUB_OUTPUT"
+ printf 'CI_FRONTEND_EMBED_SOURCE=%s SHA256=%s\n' "$EXPECTED_SOURCE_SHA" "${digest%% *}"
+
+ - name: Transfer the validated frontend embed
+ uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
+ with:
+ name: ci-frontend-embed-${{ github.sha }}-${{ github.run_attempt }}
+ path: ${{ runner.temp }}/frontend-embed.tar
+ if-no-files-found: error
+ retention-days: 1
+ compression-level: 0
+
+ # A failed audit must still permit unit proof, as in the serial job.
+ # Only successful type/build/size/packet phases admit these jobs.
+ # Runtime proof is independently required by the final Frontend verdict.
+ # A missing output never grants admission.
+ - name: Admit frontend unit shards
+ id: unit-admission
+ run: echo 'admitted=true' >> "$GITHUB_OUTPUT"
+
+ # An audit service failure or real advisory stays gating, but it must not
+ # suppress formatting, tests, type-checking, or production-build proof.
+ - name: Require frontend dependency audit
+ if: ${{ !cancelled() }}
+ env:
+ COMPLETE_AUDIT_RESULT: ${{ steps.audit-complete.outcome }}
+ run: |
+ if [ "${COMPLETE_AUDIT_RESULT}" != success ]; then
+ echo "::error::The frontend dependency audit failed."
+ exit 1
+ fi
+
+ frontend-checks:
+ name: Frontend backend and runtime
+ needs: [changes, frontend-build]
+ if: ${{ !cancelled() && needs.changes.outputs.code == 'true' && needs.frontend-build.outputs.unit_admitted == 'true' }}
+ runs-on: ubuntu-24.04
+ timeout-minutes: 30
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ persist-credentials: false
+
+ - name: Download this run's validated frontend embed
+ uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
+ with:
+ name: ci-frontend-embed-${{ github.sha }}-${{ github.run_attempt }}
+ path: ${{ runner.temp }}/frontend-embed
+
+ - name: Verify and restore the validated frontend embed
+ env:
+ EXPECTED_EMBED_SHA256: ${{ needs.frontend-build.outputs.embed_sha256 }}
+ EXPECTED_SOURCE_SHA: ${{ github.sha }}
+ run: |
+ set -euo pipefail
+ test "$(git rev-parse HEAD)" = "$EXPECTED_SOURCE_SHA"
+ [[ "$EXPECTED_EMBED_SHA256" =~ ^[a-f0-9]{64}$ ]]
+ packet="$RUNNER_TEMP/frontend-embed/frontend-embed.tar"
+ printf '%s %s\n' "$EXPECTED_EMBED_SHA256" "$packet" | sha256sum --check --strict
+ python3 -I - "$packet" <<'PY_EMBED'
+ from pathlib import PurePosixPath
+ import sys
+ import tarfile
+
+ roots = ("frontend-modern/dist", "internal/api/frontend-modern/dist")
+ with tarfile.open(sys.argv[1], "r:") as packet:
+ for member in packet.getmembers():
+ if (not (member.isfile() or member.isdir())
+ or ".." in PurePosixPath(member.name).parts
+ or not any(member.name == root or member.name.startswith(root + "/") for root in roots)):
+ raise ValueError("unexpected frontend embed archive member")
+ packet.extractall(filter="data")
+ PY_EMBED
+ test -s frontend-modern/dist/index.html
+ test -d frontend-modern/dist/assets
+ diff -qr --no-dereference frontend-modern/dist internal/api/frontend-modern/dist
+
+ # Use the hash-bound production assets from this run, never an embed stub.
# Keep the existing job deadline, audit and full frontend tests gating.
- name: Set up Go for real-embed verification
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
@@ -417,29 +510,10 @@ jobs:
if-no-files-found: warn
retention-days: 7
- # A failed audit must still permit unit proof, as in the serial job.
- # Only the unchanged build/size/real-embed/native/runtime gates admit
- # these shards. A missing output never grants admission.
- - name: Admit frontend unit shards
- id: unit-admission
- run: echo 'admitted=true' >> "$GITHUB_OUTPUT"
-
- # An audit service failure or real advisory stays gating, but it must not
- # suppress formatting, tests, type-checking, or production-build proof.
- - name: Require frontend dependency audit
- if: ${{ !cancelled() }}
- env:
- COMPLETE_AUDIT_RESULT: ${{ steps.audit-complete.outcome }}
- run: |
- if [ "${COMPLETE_AUDIT_RESULT}" != success ]; then
- echo "::error::The frontend dependency audit failed."
- exit 1
- fi
-
frontend-unit:
name: Frontend unit tests (${{ matrix.shard }}/4)
- needs: [changes, frontend-checks]
- if: ${{ !cancelled() && needs.changes.outputs.code == 'true' && needs.frontend-checks.outputs.unit_admitted == 'true' }}
+ needs: [changes, frontend-build]
+ if: ${{ !cancelled() && needs.changes.outputs.code == 'true' && needs.frontend-build.outputs.unit_admitted == 'true' }}
runs-on: ubuntu-24.04
timeout-minutes: 30
strategy:
@@ -461,7 +535,7 @@ jobs:
- name: Install frontend dependencies
working-directory: frontend-modern
- # The unchanged complete audit in frontend-checks owns its verdict.
+ # The unchanged complete audit in frontend-build owns its verdict.
run: npm ci --no-audit
# Vitest partitions its complete file inventory, preserving the existing
@@ -475,7 +549,7 @@ jobs:
# failed audit/build/runtime check must never produce a green Frontend.
frontend:
name: Frontend
- needs: [changes, frontend-checks, frontend-unit]
+ needs: [changes, frontend-build, frontend-checks, frontend-unit]
if: always()
runs-on: ubuntu-24.04
timeout-minutes: 5
@@ -484,13 +558,14 @@ jobs:
env:
CHANGE_RESULT: ${{ needs.changes.result }}
CODE_CHANGED: ${{ needs.changes.outputs.code }}
+ BUILD_RESULT: ${{ needs.frontend-build.result }}
CHECKS_RESULT: ${{ needs.frontend-checks.result }}
UNIT_RESULT: ${{ needs.frontend-unit.result }}
run: |
- case "$CHANGE_RESULT:$CODE_CHANGED:$CHECKS_RESULT:$UNIT_RESULT" in
- success:true:success:success)
+ case "$CHANGE_RESULT:$CODE_CHANGED:$BUILD_RESULT:$CHECKS_RESULT:$UNIT_RESULT" in
+ success:true:success:success:success)
echo "Frontend build, complete audit, runtime and every unit shard passed." ;;
- success:false:skipped:skipped)
+ success:false:skipped:skipped:skipped)
echo "Application runtime checks are not applicable to this classified change; no frontend tests ran." ;;
*)
echo "::error::Frontend proof is incomplete or failed. Inspect changed-area classification, build/audit/runtime and all four unit shards."
diff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.md
index 70a88a0c16..68fad9f206 100644
--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md
+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md
@@ -822,32 +822,44 @@ candidate commit; an unowned or unreachable route is not proof coverage.
### Ordinary CI compiles the backend with the same checkout's real frontend
-The required `Frontend` check aggregates the complete build/audit/runtime job
-and every one of four isolated Vitest file shards. Missing, failed, cancelled
-or skipped proof fails that check; only an explicit, consistent non-runtime
-classification admits inapplicable checks. Each execution job retains the
-30-minute ceiling; the aggregate has a five-minute orchestration deadline.
-
-Before admitting unit shards, `frontend-checks` builds and size-checks the
-production frontend, selects Go from `go.mod`,
-requires a nonempty built index/assets tree and compares the complete generated
-frontend and embed copy before backend compilation and server/API vet. Missing,
-extra or changed embedded files stop the phase; it never creates a placeholder
-or imports assets from another job/source. Build and vet use the read-only Go
-graph and two workers; the binary stays in the runner's temporary directory.
-The log records the checkout and binary digest without publishing an artifact.
-The same job retains native updater and ordinary notification/restart proof.
-Only successful build/size/runtime phases emit the explicit unit-admission
-output. The complete dependency audit still reports its own terminal verdict
-after that output: an audit failure does not suppress unit proof, but always
-fails the required aggregate. Shards use the same lock, configuration and
-assertions with only Vitest's built-in file partition; no maintained file list,
+The required `Frontend` check aggregates the complete build/audit job, the
+backend/runtime job and every one of four isolated Vitest file shards. Missing,
+failed, cancelled or skipped proof fails that check; only an explicit, consistent
+non-runtime classification admits inapplicable checks. Each execution job retains
+the 30-minute ceiling; the aggregate has a five-minute orchestration deadline.
+
+`frontend-build` installs the locked graph, performs the unchanged formatting,
+lint and type checks, then builds and size-checks the production frontend. It
+requires a nonempty index/assets tree and compares the complete generated
+frontend and embed copy. Only that successful checkout-bound build is packed
+and transferred as an immutable, one-day artifact named for this run's source
+and attempt, with its SHA256 separately exported by the producer. Successful
+build/size/transfer phases emit the explicit admission output. Unit shards and
+`frontend-checks` then run independently, rather than making every unit shard
+wait for backend compilation and runtime checks. An audit failure still permits
+that diagnostic proof but always fails the required aggregate.
+
+The runtime job downloads only the same run/source/attempt artifact. It verifies
+the checkout and producer digest before opening the archive, rejects entries
+outside the two fixed dist trees, traversal and non-file/non-directory entries,
+and safely restores the complete built bytes. Missing, extra or changed embedded
+files stop the phase; it never creates a placeholder or rebuilds a different
+bundle. Go comes from `go.mod`; build and server/API vet retain the read-only
+graph and two workers. The log records the checkout and binary digest; the
+binary stays in the runner's temporary directory. Native updater and ordinary
+notification/restart proof remain required with their unchanged commands and
+bounded receipts. Shards retain the same lock, configuration and assertions,
+using only Vitest's complete file partition. No maintained file list,
changed-file filter, shared mutable runner or extra in-runner concurrency is
introduced. Type/build/size failure still stops the expensive suite early.
`TestFrontendCIRequiresSameCheckoutRealEmbedBackend` executes the exact phase
with private assets and Git/compiler doubles, covering mismatch refusal,
-declared command/ordering checks and terminal compiler/vet failures. These
+declared command/ordering checks and terminal compiler/vet failures. Its transfer
+controls also execute the actual pack/restore shells, verify byte-for-byte
+round trips and reject source, digest, missing-packet and unsafe-member controls.
+`TestFrontendCIBuildTransferIsSourceBound` runs those transfer controls explicitly
+in the Go install-test suite, separately from compiler/asset admission. These
controls are not real compilation. `TestFrontendCIRequiresCompleteIsolatedUnitProof`
executes the workflow-order, complete-shard and actual fail-closed audit/verdict
controls in `scripts/tests/test_frontend_workflow_order.py`. Actual containing CI checkout/phase logs
diff --git a/scripts/installtests/build_release_assets_test.go b/scripts/installtests/build_release_assets_test.go
index 9982868d4b..ff89ac279c 100644
--- a/scripts/installtests/build_release_assets_test.go
+++ b/scripts/installtests/build_release_assets_test.go
@@ -4513,7 +4513,7 @@ func assertInternalAPIShardSelectionExhaustive(t *testing.T, workflowShards int)
func TestFrontendCIRequiresSameCheckoutRealEmbedBackend(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 45*time.Second)
defer cancel()
- cmd := exec.CommandContext(ctx, "python3", repoFile("scripts", "tests", "test_frontend_real_embed.py"), "-v")
+ cmd := exec.CommandContext(ctx, "python3", repoFile("scripts", "tests", "test_frontend_real_embed.py"), "FrontendRealEmbed", "-v")
cmd.Env = append(os.Environ(), "PULSE_BUILD_WORKFLOW_UNDER_TEST="+repoFile(".github", "workflows", "build-and-test.yml"))
out, err := cmd.CombinedOutput()
if err != nil {
@@ -4521,6 +4521,19 @@ func TestFrontendCIRequiresSameCheckoutRealEmbedBackend(t *testing.T) {
}
}
+// Execute the exact producer/consumer shells, including every-byte round trips
+// and source, digest and unsafe-member refusals before any asset extraction.
+// Artifact transport and hosted overlap still need containing CI observations.
+func TestFrontendCIBuildTransferIsSourceBound(t *testing.T) {
+ ctx, cancel := context.WithTimeout(context.Background(), 45*time.Second)
+ defer cancel()
+ cmd := exec.CommandContext(ctx, "python3", repoFile("scripts", "tests", "test_frontend_real_embed.py"), "FrontendEmbedTransfer", "-v")
+ cmd.Env = append(os.Environ(), "PULSE_BUILD_WORKFLOW_UNDER_TEST="+repoFile(".github", "workflows", "build-and-test.yml"))
+ if out, err := cmd.CombinedOutput(); err != nil {
+ t.Fatalf("source-bound frontend build transfer controls: %v\n%s", err, out)
+ }
+}
+
// Keep the registered frontend security-proof route bound to the actual
// workflow's complete inventory, runtime admission and audit/shard verdicts.
func TestFrontendCIRequiresCompleteIsolatedUnitProof(t *testing.T) {
diff --git a/scripts/tests/test_auto_update_systemd.py b/scripts/tests/test_auto_update_systemd.py
index b62e43b856..aeab068449 100644
--- a/scripts/tests/test_auto_update_systemd.py
+++ b/scripts/tests/test_auto_update_systemd.py
@@ -39,7 +39,7 @@ def recipe(source):
job = re.search(r"(?ms)^ frontend-checks:\n(.*?)(?=^ [a-z][a-z0-9-]*:|\Z)", source)[1]
steps = dict(re.findall(r"(?ms)^ - name: ([^\n]+)\n(.*?)(?=^ - name:|\Z)", job))
order = list(steps)
- assert order.index("Verify backend with real frontend embed") < order.index(STEP) < order.index("Require frontend dependency audit")
+ assert order.index("Verify backend with real frontend embed") < order.index(STEP) < order.index("Check ordinary notification policy and restart")
step = steps[STEP]
assert not re.search(r"^ (if|continue-on-error|working-directory):", step, re.M)
assert "runs-on: ubuntu-24.04" in job and "timeout-minutes: 30" in job
diff --git a/scripts/tests/test_dependency_advisory_watch.py b/scripts/tests/test_dependency_advisory_watch.py
index 370ba57836..42464765af 100644
--- a/scripts/tests/test_dependency_advisory_watch.py
+++ b/scripts/tests/test_dependency_advisory_watch.py
@@ -202,7 +202,7 @@ class WorkflowContractTest(unittest.TestCase):
def test_audit_matches_the_required_build_and_test_audit(self) -> None:
build = yaml.safe_load(BUILD_AND_TEST.read_text(encoding="utf-8"))
- frontend = build["jobs"]["frontend-checks"]["steps"]
+ frontend = build["jobs"]["frontend-build"]["steps"]
audit = self.workflow["jobs"]["audit"]["steps"]
def step(steps: list[dict], name: str) -> dict:
diff --git a/scripts/tests/test_frontend_real_embed.py b/scripts/tests/test_frontend_real_embed.py
index abd7a47a7e..c9c3a64e4c 100644
--- a/scripts/tests/test_frontend_real_embed.py
+++ b/scripts/tests/test_frontend_real_embed.py
@@ -5,14 +5,19 @@ The exact workflow shell runs with private asset fixtures and compiler/Git
doubles. This is recipe/admission proof, not real frontend/backend acceptance.
"""
+import hashlib
+import io
import json
import os
from pathlib import Path
import re
import subprocess
import tempfile
+import tarfile
import unittest
+import yaml
+
ROOT = Path(__file__).resolve().parents[2]
WORKFLOW = Path(os.environ.get("PULSE_BUILD_WORKFLOW_UNDER_TEST", ROOT / ".github/workflows/build-and-test.yml")).resolve()
@@ -20,36 +25,36 @@ GO_SETUP = "Set up Go for real-embed verification"
VERIFY = "Verify backend with real frontend embed"
-def recipe(source):
- job = re.search(r"(?ms)^ frontend-checks:\n(.*?)(?=^ [a-z][a-z0-9-]*:|\Z)", source)
- if not job:
- raise AssertionError("frontend job missing")
- job = job[1]
- if "timeout-minutes: 30" not in job or "if: needs.changes.outputs.code == 'true'" not in job:
- raise AssertionError("ordinary frontend admission/deadline changed")
- parsed = re.findall(r"(?ms)^ - name: ([^\n]+)\n(.*?)(?=^ - name:|\Z)", job)
- steps = dict(parsed)
- if len(parsed) != len(steps):
+def workflow_steps(source, job_name):
+ job = yaml.safe_load(source)["jobs"][job_name]
+ steps = {step["name"]: step for step in job["steps"]}
+ if len(steps) != len(job["steps"]):
raise AssertionError("duplicate named frontend step")
+ return job, steps
+
+
+def recipe(source):
+ build, producer = workflow_steps(source, "frontend-build")
+ job, steps = workflow_steps(source, "frontend-checks")
order = list(steps)
- required = ["Checkout repository", "Build frontend bundle (with embed copy)",
- "Check frontend bundle size budget", GO_SETUP, VERIFY,
- "Require frontend dependency audit"]
+ required = ["Checkout repository", "Download this run's validated frontend embed",
+ "Verify and restore the validated frontend embed", GO_SETUP, VERIFY]
if any(name not in order for name in required) or [order.index(name) for name in required] != sorted(order.index(name) for name in required):
- raise AssertionError("same-checkout real build, compiler or audit ordering missing")
- if sum("uses: actions/checkout@" in step for step in steps.values()) != 1 or "run: make frontend" not in steps[required[1]]:
- raise AssertionError("must use this checkout's production frontend build")
- if re.search(r"^ (ref|repository):", steps[required[0]], re.M):
- raise AssertionError("frontend proof must use the ordinary exact checkout")
- if "go-version-file: go.mod" not in steps[GO_SETUP] or "actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e" not in steps[GO_SETUP]:
+ raise AssertionError("same-run build transfer or real-embed ordering missing")
+ if job["needs"] != ["changes", "frontend-build"] or job["timeout-minutes"] != 30:
+ raise AssertionError("ordinary runtime admission/deadline changed")
+ if producer["Build frontend bundle (with embed copy)"]["run"] != "make frontend":
+ raise AssertionError("must use the producer's production frontend build")
+ for checkout in (producer["Checkout repository"], steps["Checkout repository"]):
+ if checkout["with"] != {"persist-credentials": False}:
+ raise AssertionError("frontend proof must use the ordinary exact checkout")
+ setup = steps[GO_SETUP]
+ if setup["with"].get("go-version-file") != "go.mod" or setup["uses"] != "actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e":
raise AssertionError("declared compiler setup missing")
for name in (GO_SETUP, VERIFY):
- if re.search(r"^ (if|continue-on-error|working-directory):", steps[name], re.M):
+ if any(field in steps[name] for field in ("if", "continue-on-error", "working-directory")):
raise AssertionError("real-embed verification must run at root and retain failure")
- run = re.search(r"(?ms)^ run: \|\n((?: [^\n]*\n)+)", steps[VERIFY])
- if not run:
- raise AssertionError("real-embed shell missing")
- shell = "\n".join(line[10:] for line in run[1].splitlines()) + "\n"
+ shell = steps[VERIFY]["run"]
for command in ("set -euo pipefail", "checkout_sha=$(git rev-parse HEAD)", "test -s frontend-modern/dist/index.html",
"test -d frontend-modern/dist/assets",
"diff -qr --no-dereference frontend-modern/dist internal/api/frontend-modern/dist",
@@ -150,5 +155,110 @@ class FrontendRealEmbed(unittest.TestCase):
with self.assertRaises(AssertionError): recipe(source.replace(before, after))
+class FrontendEmbedTransfer(unittest.TestCase):
+ SHA = "0123456789012345678901234567890123456789"
+
+ def setUp(self):
+ self.source = WORKFLOW.read_text()
+ _, self.producer = workflow_steps(self.source, "frontend-build")
+ _, self.consumer = workflow_steps(self.source, "frontend-checks")
+
+ def test_transfer_is_fixed_to_this_run_source_and_attempt(self):
+ upload = self.producer["Transfer the validated frontend embed"]
+ download = self.consumer["Download this run's validated frontend embed"]
+ self.assertEqual(upload["uses"], "actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9")
+ self.assertEqual(upload["with"], {
+ "name": "ci-frontend-embed-${{ github.sha }}-${{ github.run_attempt }}",
+ "path": "${{ runner.temp }}/frontend-embed.tar", "if-no-files-found": "error",
+ "retention-days": 1, "compression-level": 0,
+ })
+ self.assertEqual(download["uses"], "actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333")
+ self.assertEqual(download["with"], {
+ "name": upload["with"]["name"], "path": "${{ runner.temp }}/frontend-embed",
+ })
+ self.assertEqual(self.producer["Bind the validated frontend embed"]["env"], {"EXPECTED_SOURCE_SHA": "${{ github.sha }}"})
+ self.assertEqual(self.consumer["Verify and restore the validated frontend embed"]["env"], {
+ "EXPECTED_EMBED_SHA256": "${{ needs.frontend-build.outputs.embed_sha256 }}",
+ "EXPECTED_SOURCE_SHA": "${{ github.sha }}",
+ })
+
+ def transfer(self, mutation=""):
+ with tempfile.TemporaryDirectory(prefix="pulse-embed-transfer-") as directory:
+ base = Path(directory)
+ producer, consumer = base / "producer", base / "consumer"
+ producer.mkdir(); consumer.mkdir()
+ tools = base / "tools"; tools.mkdir()
+ git = tools / "git"
+ git.write_text('#!/bin/sh\n[ "$*" = "rev-parse HEAD" ] || exit 97\necho ' + self.SHA + '\n')
+ git.chmod(0o700)
+ for tree in ("frontend-modern/dist", "internal/api/frontend-modern/dist"):
+ (producer / tree / "assets").mkdir(parents=True)
+ (producer / tree / "index.html").write_bytes(b"<html>real build fixture</html>\n")
+ (producer / tree / "assets/app.js").write_bytes(b"fixture application bytes\n")
+ runner = base / "runner"; runner.mkdir()
+ env = dict(os.environ, PATH=str(tools) + os.pathsep + os.environ["PATH"],
+ RUNNER_TEMP=str(runner), EXPECTED_SOURCE_SHA=self.SHA,
+ GITHUB_OUTPUT=str(base / "outputs"))
+ if mutation == "producer source": env["EXPECTED_SOURCE_SHA"] = "a" * 40
+ if mutation == "producer mismatch":
+ (producer / "internal/api/frontend-modern/dist/assets/app.js").write_bytes(b"changed\n")
+ bound = subprocess.run(["bash", "-c", self.producer["Bind the validated frontend embed"]["run"]],
+ cwd=producer, env=env, capture_output=True, text=True, timeout=10)
+ packet = runner / "frontend-embed.tar"
+ if mutation.startswith("producer "):
+ self.assertNotEqual(bound.returncode, 0)
+ self.assertFalse(packet.exists())
+ self.assertFalse((base / "outputs").exists())
+ return
+ self.assertEqual(bound.returncode, 0, bound.stdout + bound.stderr)
+ digest = (base / "outputs").read_text().strip().removeprefix("sha256=")
+ self.assertEqual(digest, hashlib.sha256(packet.read_bytes()).hexdigest())
+ if mutation.startswith("member:"):
+ kind = mutation.removeprefix("member:")
+ with tarfile.open(packet, "a") as archive:
+ member = tarfile.TarInfo({"parent": "frontend-modern/dist/../../../outside",
+ "foreign": "Makefile", "absolute": "/tmp/outside"}.get(kind, "frontend-modern/dist/assets/link"))
+ if kind == "symlink": member.type = tarfile.SYMTYPE; member.linkname = "/tmp/outside"
+ if kind == "hardlink": member.type = tarfile.LNKTYPE; member.linkname = "frontend-modern/dist/index.html"
+ if kind == "fifo": member.type = tarfile.FIFOTYPE
+ archive.addfile(member, io.BytesIO())
+ digest = hashlib.sha256(packet.read_bytes()).hexdigest()
+ if mutation == "empty archive":
+ with tarfile.open(packet, "w"): pass
+ digest = hashlib.sha256(packet.read_bytes()).hexdigest()
+ if mutation == "corrupt bytes":
+ packet.write_bytes(packet.read_bytes() + b"unexpected bytes")
+ if mutation == "wrong digest": digest = "f" * 64
+ if mutation == "missing digest": digest = ""
+ if mutation == "malformed digest": digest = "not-a-digest"
+ target = runner / "frontend-embed"; target.mkdir()
+ packet.rename(target / packet.name)
+ if mutation == "missing packet": (target / packet.name).unlink()
+ env["EXPECTED_EMBED_SHA256"] = digest
+ if mutation == "consumer source": env["EXPECTED_SOURCE_SHA"] = "b" * 40
+ restored = subprocess.run(["bash", "-c", self.consumer["Verify and restore the validated frontend embed"]["run"]],
+ cwd=consumer, env=env, capture_output=True, text=True, timeout=10)
+ if mutation:
+ self.assertNotEqual(restored.returncode, 0, mutation)
+ self.assertFalse((consumer / "frontend-modern/dist/index.html").exists())
+ else:
+ self.assertEqual(restored.returncode, 0, restored.stdout + restored.stderr)
+ expected = {p.relative_to(producer).as_posix(): p.read_bytes() for p in producer.rglob("*") if p.is_file()}
+ actual = {p.relative_to(consumer).as_posix(): p.read_bytes() for p in consumer.rglob("*") if p.is_file()}
+ self.assertEqual(actual, expected)
+
+ def test_actual_producer_and_consumer_preserve_every_built_byte(self):
+ self.transfer()
+
+ def test_source_or_content_uncertainty_never_restores_assets(self):
+ for mutation in ("producer source", "producer mismatch", "consumer source", "corrupt bytes",
+ "wrong digest", "missing digest", "malformed digest", "missing packet", "empty archive"):
+ with self.subTest(mutation=mutation): self.transfer(mutation)
+
+ def test_archive_members_are_validated_before_any_extraction(self):
+ for kind in ("parent", "foreign", "absolute", "symlink", "hardlink", "fifo"):
+ with self.subTest(kind=kind): self.transfer("member:" + kind)
+
+
if __name__ == "__main__":
unittest.main()
diff --git a/scripts/tests/test_frontend_workflow_order.py b/scripts/tests/test_frontend_workflow_order.py
index 41add8544e..a7e8b1cb5c 100644
--- a/scripts/tests/test_frontend_workflow_order.py
+++ b/scripts/tests/test_frontend_workflow_order.py
@@ -17,7 +17,7 @@ class FrontendWorkflowOrderTest(unittest.TestCase):
def setUp(self):
self.workflow = yaml.safe_load(WORKFLOW.read_text())
self.jobs = self.workflow["jobs"]
- self.job = self.jobs["frontend-checks"]
+ self.job = self.jobs["frontend-build"]
self.steps = self.job["steps"]
def step(self, name):
@@ -32,9 +32,8 @@ class FrontendWorkflowOrderTest(unittest.TestCase):
"Type-check frontend",
"Build frontend bundle (with embed copy)",
"Check frontend bundle size budget",
- "Verify backend with real frontend embed",
- "Check current-source unattended recovery on native systemd",
- "Check ordinary notification policy and restart",
+ "Bind the validated frontend embed",
+ "Transfer the validated frontend embed",
"Admit frontend unit shards",
"Require frontend dependency audit",
]
@@ -74,7 +73,7 @@ class FrontendWorkflowOrderTest(unittest.TestCase):
self.assertIn('if [ "${COMPLETE_AUDIT_RESULT}" != success ]; then', required["run"])
self.assertIn("exit 1", required["run"])
- def test_unit_admission_is_after_runtime_but_before_the_audit_verdict(self):
+ def test_unit_admission_is_after_bundle_transfer_but_before_the_audit_verdict(self):
admission = self.step("Admit frontend unit shards")
self.assertEqual(admission, {
"name": "Admit frontend unit shards", "id": "unit-admission",
@@ -82,11 +81,12 @@ class FrontendWorkflowOrderTest(unittest.TestCase):
})
self.assertEqual(self.job["outputs"], {
"unit_admitted": "${{ steps.unit-admission.outputs.admitted }}",
+ "embed_sha256": "${{ steps.embed-packet.outputs.sha256 }}",
})
self.assertEqual(self.job["needs"], "changes")
self.assertEqual(self.job["if"], "needs.changes.outputs.code == 'true'")
self.assertEqual(self.job["timeout-minutes"], 30)
- # GitHub's default success() is essential: a failed/hidden runtime
+ # GitHub's default success() is essential: a failed/hidden build or transfer
# phase must never produce the output admitting expensive unit shards.
for step in self.steps:
if step["name"].startswith("Retain bounded "):
@@ -99,8 +99,8 @@ class FrontendWorkflowOrderTest(unittest.TestCase):
def test_four_isolated_shards_use_complete_vitest_inventory(self):
unit = self.jobs["frontend-unit"]
- self.assertEqual(unit["needs"], ["changes", "frontend-checks"])
- self.assertEqual(unit["if"], "${{ !cancelled() && needs.changes.outputs.code == 'true' && needs.frontend-checks.outputs.unit_admitted == 'true' }}")
+ self.assertEqual(unit["needs"], ["changes", "frontend-build"])
+ self.assertEqual(unit["if"], "${{ !cancelled() && needs.changes.outputs.code == 'true' && needs.frontend-build.outputs.unit_admitted == 'true' }}")
self.assertEqual(unit["strategy"], {
"fail-fast": False, "matrix": {"shard": [1, 2, 3, 4]},
})
@@ -123,10 +123,32 @@ class FrontendWorkflowOrderTest(unittest.TestCase):
})
self.assertEqual(self.workflow["permissions"], {"contents": "read"})
+ def test_runtime_and_units_are_independent_required_siblings(self):
+ runtime = self.jobs["frontend-checks"]
+ unit = self.jobs["frontend-unit"]
+ self.assertEqual(runtime["needs"], ["changes", "frontend-build"])
+ self.assertEqual(runtime["if"], unit["if"])
+ self.assertEqual(runtime["runs-on"], "ubuntu-24.04")
+ self.assertEqual(runtime["timeout-minutes"], 30)
+ self.assertNotIn("continue-on-error", runtime)
+ names = [step["name"] for step in runtime["steps"]]
+ ordered = ["Download this run's validated frontend embed",
+ "Verify and restore the validated frontend embed",
+ "Set up Go for real-embed verification", "Verify backend with real frontend embed",
+ "Check current-source unattended recovery on native systemd",
+ "Check ordinary notification policy and restart"]
+ self.assertEqual([names.index(name) for name in ordered], sorted(names.index(name) for name in ordered))
+ for step in runtime["steps"]:
+ self.assertNotIn("continue-on-error", step)
+ if step["name"].startswith("Retain bounded "):
+ self.assertEqual(step["if"], "always()")
+ else:
+ self.assertNotIn("if", step)
+
def verdict(self, **values):
step = self.jobs["frontend"]["steps"][0]
env = dict(os.environ, CHANGE_RESULT="success", CODE_CHANGED="true",
- CHECKS_RESULT="success", UNIT_RESULT="success")
+ BUILD_RESULT="success", CHECKS_RESULT="success", UNIT_RESULT="success")
env.update(values)
return subprocess.run(["bash", "-e", "-u", "-o", "pipefail", "-c", step["run"]],
env=env, text=True, capture_output=True, timeout=5)
@@ -135,7 +157,7 @@ class FrontendWorkflowOrderTest(unittest.TestCase):
verdict = self.jobs["frontend"]
self.assertEqual(verdict["name"], "Frontend")
self.assertEqual(sum(job.get("name") == "Frontend" for job in self.jobs.values()), 1)
- self.assertEqual(verdict["needs"], ["changes", "frontend-checks", "frontend-unit"])
+ self.assertEqual(verdict["needs"], ["changes", "frontend-build", "frontend-checks", "frontend-unit"])
self.assertEqual(verdict["if"], "always()")
self.assertNotIn("continue-on-error", verdict)
self.assertEqual(len(verdict["steps"]), 1)
@@ -145,13 +167,14 @@ class FrontendWorkflowOrderTest(unittest.TestCase):
self.assertEqual(step["env"], {
"CHANGE_RESULT": "${{ needs.changes.result }}",
"CODE_CHANGED": "${{ needs.changes.outputs.code }}",
+ "BUILD_RESULT": "${{ needs.frontend-build.result }}",
"CHECKS_RESULT": "${{ needs.frontend-checks.result }}",
"UNIT_RESULT": "${{ needs.frontend-unit.result }}",
})
result = self.verdict()
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
self.assertIn("every unit shard passed", result.stdout)
- for name in ("CHANGE_RESULT", "CHECKS_RESULT", "UNIT_RESULT"):
+ for name in ("CHANGE_RESULT", "BUILD_RESULT", "CHECKS_RESULT", "UNIT_RESULT"):
for state in ("failure", "cancelled", "skipped", "", "unknown", "pending", "SUCCESS"):
with self.subTest(name=name, state=state):
result = self.verdict(**{name: state})
@@ -162,19 +185,19 @@ class FrontendWorkflowOrderTest(unittest.TestCase):
self.assertNotEqual(self.verdict(CODE_CHANGED=state).returncode, 0)
def test_only_consistent_inapplicable_proof_can_skip_the_unit_inventory(self):
- values = dict(CODE_CHANGED="false", CHECKS_RESULT="skipped", UNIT_RESULT="skipped")
+ values = dict(CODE_CHANGED="false", BUILD_RESULT="skipped", CHECKS_RESULT="skipped", UNIT_RESULT="skipped")
result = self.verdict(**values)
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
self.assertIn("no frontend tests ran", result.stdout)
- for name in ("CHANGE_RESULT", "CHECKS_RESULT", "UNIT_RESULT", "CODE_CHANGED"):
+ for name in ("CHANGE_RESULT", "BUILD_RESULT", "CHECKS_RESULT", "UNIT_RESULT", "CODE_CHANGED"):
states = ("failure", "cancelled", "", "unknown")
- if name in ("CHECKS_RESULT", "UNIT_RESULT"):
+ if name in ("BUILD_RESULT", "CHECKS_RESULT", "UNIT_RESULT"):
states += ("success",)
for state in states:
with self.subTest(name=name, state=state):
self.assertNotEqual(self.verdict(**{**values, name: state}).returncode, 0)
- def test_complete_audit_failure_still_fails_after_runtime_admits_units(self):
+ def test_complete_audit_failure_still_fails_after_build_admits_units(self):
required = self.step("Require frontend dependency audit")
for state in ("success", "failure", "cancelled", "skipped", "", "unknown"):
with self.subTest(state=state):
diff --git a/scripts/tests/test_go_test_compilation.py b/scripts/tests/test_go_test_compilation.py
index 7af6d8c2c5..03f823f93d 100644
--- a/scripts/tests/test_go_test_compilation.py
+++ b/scripts/tests/test_go_test_compilation.py
@@ -143,9 +143,9 @@ func TestStaleFixture(t *testing.T) { _ = api.Resource{Alerts: []api.ResourceAle
self.assertIn("if: needs.changes.outputs.go_compile == 'true'", compile_job)
self.assertIn("go test -race -vet=off -count=1 -exec /bin/true ./...", COMPILER.read_text())
# Frontend work does not wait for the Go-only gate.
- self.assertIn("needs: changes", job(source, "frontend-checks"))
- self.assertIn("needs: [changes, frontend-checks]", job(source, "frontend-unit"))
- self.assertIn("needs: [changes, frontend-checks, frontend-unit]", job(source, "frontend"))
+ self.assertIn("needs: changes", job(source, "frontend-build"))
+ self.assertIn("needs: [changes, frontend-build]", job(source, "frontend-unit"))
+ self.assertIn("needs: [changes, frontend-build, frontend-checks, frontend-unit]", job(source, "frontend"))
def test_required_checks_admit_only_explicit_consistent_results(self):
source = WORKFLOW.read_text()
diff --git a/scripts/tests/test_notification_runtime.py b/scripts/tests/test_notification_runtime.py
index 3eb2f7ac1e..1b9b5ba40a 100644
--- a/scripts/tests/test_notification_runtime.py
+++ b/scripts/tests/test_notification_runtime.py
@@ -179,7 +179,7 @@ class NotificationRuntimeControls(unittest.TestCase):
def test_ci_reuses_the_real_embed_with_exact_source_and_attempt_receipt(self):
workflow = (ROOT / '.github/workflows/build-and-test.yml').read_text()
section = workflow.split('- name: Check ordinary notification policy and restart', 1)[1]
- section = section.split('# An audit service failure', 1)[0]
+ section = section.split('\n frontend-unit:', 1)[0]
self.assertIn('timeout-minutes: 3', section)
self.assertIn('--binary "$RUNNER_TEMP/pulse-real-embed"', section)
self.assertIn('--expected-source-sha "${{ github.sha }}"', section)
diff --git a/scripts/tests/test_npm_audit_retry.py b/scripts/tests/test_npm_audit_retry.py
index 1ddc99fea3..595a164d9e 100755
--- a/scripts/tests/test_npm_audit_retry.py
+++ b/scripts/tests/test_npm_audit_retry.py
@@ -721,7 +721,7 @@ class NpmAuditRetryTest(unittest.TestCase):
def test_all_workflow_audits_use_the_retry_boundary(self) -> None:
expected = {
".github/workflows/build-and-test.yml": {
- "job": "frontend-checks",
+ "job": "frontend-build",
"runs": [
'bash "$GITHUB_WORKSPACE/scripts/npm-audit-retry.sh" all',
],