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.

Share source-aware race build objects with backend CI

pulse-triage[bot]32db234756e2
diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml
index 1c4b866366..0bbdbf47ad 100644
--- a/.github/workflows/build-and-test.yml
+++ b/.github/workflows/build-and-test.yml
@@ -509,11 +509,29 @@ jobs:
fetch-depth: 2
- name: Set up Go
+ id: go-setup
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
cache: true
+ # setup-go's immutable module key can keep restoring objects from an old
+ # tree forever. Reuse the successful compile gate's current-source objects
+ # before falling back to the same runner/toolchain/module graph. Go still
+ # checks content identities; no cache result admits or replaces a test.
+ - name: Locate backend Go build cache
+ id: go-build-cache
+ run: echo "path=$(go env GOCACHE)" >> "$GITHUB_OUTPUT"
+
+ - name: Restore backend race build objects
+ id: race-cache
+ continue-on-error: true
+ uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
+ with:
+ path: ${{ steps.go-build-cache.outputs.path }}
+ key: backend-race-objects-v1-${{ runner.os }}-${{ runner.arch }}-ubuntu24-${{ steps.go-setup.outputs.go-version }}-${{ hashFiles('go.mod', 'go.sum') }}-${{ github.sha }}
+ restore-keys: backend-race-objects-v1-${{ runner.os }}-${{ runner.arch }}-ubuntu24-${{ steps.go-setup.outputs.go-version }}-${{ hashFiles('go.mod', 'go.sum') }}-
+
- name: Provide frontend test embed stub
run: bash scripts/ensure_test_assets.sh
@@ -523,6 +541,17 @@ jobs:
PULSE_GO_COMPILE_HEAD: ${{ github.sha }}
run: bash scripts/compile-go-tests.sh
+ # Save before dependent runners start, even when setup-go restored its
+ # older module-key cache. Only a successful real compilation gets here.
+ # Cache transport is optional; compilation and runtime are never optional.
+ - name: Save backend race build objects
+ if: steps.race-cache.outputs.cache-hit != 'true'
+ continue-on-error: true
+ uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
+ with:
+ path: ${{ steps.go-build-cache.outputs.path }}
+ key: ${{ steps.race-cache.outputs.cache-primary-key }}
+
backend:
name: Backend tests (${{ matrix.shard }})
needs: [changes, test-compile]
@@ -568,6 +597,7 @@ jobs:
persist-credentials: false
- name: Set up Go
+ id: go-setup
if: needs.changes.outputs.code == 'true'
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
@@ -578,6 +608,25 @@ jobs:
# not assert on real bundle content, so a stub file satisfies the embed
# without the ~5 minute frontend build; the real bundle is built and
# size-gated by the frontend job, and release artifacts always build it.
+ # setup-go's immutable module key can keep restoring objects from an old
+ # tree forever. Reuse the successful compile gate's current-source objects
+ # before falling back to the same runner/toolchain/module graph. Go still
+ # checks content identities; no cache result admits or replaces a test.
+ - name: Locate backend Go build cache
+ if: needs.changes.outputs.code == 'true'
+ id: go-build-cache
+ run: echo "path=$(go env GOCACHE)" >> "$GITHUB_OUTPUT"
+
+ - name: Restore backend race build objects
+ if: needs.changes.outputs.code == 'true'
+ id: race-cache
+ continue-on-error: true
+ uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
+ with:
+ path: ${{ steps.go-build-cache.outputs.path }}
+ key: backend-race-objects-v1-${{ runner.os }}-${{ runner.arch }}-ubuntu24-${{ steps.go-setup.outputs.go-version }}-${{ hashFiles('go.mod', 'go.sum') }}-${{ github.sha }}
+ restore-keys: backend-race-objects-v1-${{ runner.os }}-${{ runner.arch }}-ubuntu24-${{ steps.go-setup.outputs.go-version }}-${{ hashFiles('go.mod', 'go.sum') }}-
+
- name: Provide frontend embed stub
if: needs.changes.outputs.code == 'true'
run: |
@@ -681,12 +730,32 @@ jobs:
persist-credentials: false
- name: Set up Go
+ id: go-setup
if: needs.changes.outputs.code == 'true'
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
cache: true
+ # setup-go's immutable module key can keep restoring objects from an old
+ # tree forever. Reuse the successful compile gate's current-source objects
+ # before falling back to the same runner/toolchain/module graph. Go still
+ # checks content identities; no cache result admits or replaces a test.
+ - name: Locate backend Go build cache
+ if: needs.changes.outputs.code == 'true'
+ id: go-build-cache
+ run: echo "path=$(go env GOCACHE)" >> "$GITHUB_OUTPUT"
+
+ - name: Restore backend race build objects
+ if: needs.changes.outputs.code == 'true'
+ id: race-cache
+ continue-on-error: true
+ uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
+ with:
+ path: ${{ steps.go-build-cache.outputs.path }}
+ key: backend-race-objects-v1-${{ runner.os }}-${{ runner.arch }}-ubuntu24-${{ steps.go-setup.outputs.go-version }}-${{ hashFiles('go.mod', 'go.sum') }}-${{ github.sha }}
+ restore-keys: backend-race-objects-v1-${{ runner.os }}-${{ runner.arch }}-ubuntu24-${{ steps.go-setup.outputs.go-version }}-${{ hashFiles('go.mod', 'go.sum') }}-
+
- name: Provide frontend embed stub
if: needs.changes.outputs.code == 'true'
run: |
diff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.md
index bb4f8a3132..857436e082 100644
--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md
+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md
@@ -9092,6 +9092,33 @@ dependency audit.
These proofs establish CI source admission, not hosted queue-time relief.
+### Source-aware backend race build cache (31 October 2026)
+
+The compile-only gate and both backend matrices restore Go build objects after
+setup-go's module cache. The primary key binds the source SHA, Ubuntu 24 runner
+OS/architecture, declared Go version and both module manifests. A fallback is
+limited to that same runner/toolchain/module graph; Go's own content identities
+still decide which objects are reusable. Only `go env GOCACHE` is shared, not
+source, credentials, module downloads or an application/test-binary artifact.
+
+The successful compile gate saves its source key before dependent jobs start.
+An existing setup-go module-key hit must not suppress this save: that immutable
+key can otherwise restore old objects on every source change. Backend runtime
+jobs are readers, not competing writers. GitHub's existing branch-scoped cache
+access remains unchanged; there is no cross-ref or credential override.
+
+Cache misses, evictions and transport failures degrade to normal compilation.
+Only the pinned restore/save actions may continue after a cache failure; all
+source/compile/runtime admissions, required names, race commands, inventory,
+vet, deadlines and frontend/native checks remain mandatory. The compiler still
+uses `-count=1 -exec /bin/true`: its cache is not a passing runtime result.
+`scripts/tests/test_backend_build_cache.py` checks the actual workflow keys,
+paths, producer/consumer order, optional-cache-only boundary and path command;
+`test_go_test_compilation.py` retains the executable fail-closed admission and
+no-runtime controls. Hosted cache transfer cost and overall throughput are
+post-landing observations, not established by these contract tests.
+
+
### Exhaustive native Unix installer process budgets (18 October 2026)
`scripts/installtests/run_unix_contracts.py` belongs to deployment installability.
diff --git a/scripts/tests/test_backend_build_cache.py b/scripts/tests/test_backend_build_cache.py
new file mode 100644
index 0000000000..1619cc3d59
--- /dev/null
+++ b/scripts/tests/test_backend_build_cache.py
@@ -0,0 +1,126 @@
+#!/usr/bin/env python3
+"""Build objects accelerate CI; they must never become a test verdict."""
+
+import os
+from pathlib import Path
+import subprocess
+import tempfile
+import unittest
+
+import yaml
+
+
+ROOT = Path(__file__).resolve().parents[2]
+WORKFLOW = ROOT / ".github/workflows/build-and-test.yml"
+CACHE_ACTION = "55cc8345863c7cc4c66a329aec7e433d2d1c52a9"
+CACHE_PREFIX = (
+ "backend-race-objects-v1-${{ runner.os }}-${{ runner.arch }}-ubuntu24-"
+ "${{ steps.go-setup.outputs.go-version }}-${{ hashFiles('go.mod', 'go.sum') }}-"
+)
+CACHE_PATH = "${{ steps.go-build-cache.outputs.path }}"
+RESTORE = "Restore backend race build objects"
+SAVE = "Save backend race build objects"
+COMPILE = "Compile affected Go race-test binaries without executing them"
+
+
+class BackendBuildCacheTest(unittest.TestCase):
+ def setUp(self):
+ self.workflow = yaml.safe_load(WORKFLOW.read_text())
+ self.jobs = self.workflow["jobs"]
+
+ def step(self, job, name):
+ found = [step for step in self.jobs[job]["steps"] if step.get("name") == name]
+ self.assertEqual(len(found), 1, (job, name))
+ return found[0]
+
+ def test_same_source_is_preferred_before_same_graph_build_objects(self):
+ for job in ("test-compile", "backend", "backend-api"):
+ with self.subTest(job=job):
+ setup = self.step(job, "Set up Go")
+ self.assertEqual(setup["id"], "go-setup")
+ self.assertEqual(setup["with"], {"go-version-file": "go.mod", "cache": True})
+ restore = self.step(job, RESTORE)
+ self.assertEqual(restore["uses"], f"actions/cache/restore@{CACHE_ACTION}")
+ self.assertEqual(restore["id"], "race-cache")
+ self.assertEqual(restore["with"], {
+ "path": CACHE_PATH,
+ "key": CACHE_PREFIX + "${{ github.sha }}",
+ "restore-keys": CACHE_PREFIX,
+ })
+ # No module tree, source, binary, credentials or alternate ref
+ # is exported. The Go tool validates each restored build object.
+ locate = self.step(job, "Locate backend Go build cache")
+ self.assertEqual(locate["id"], "go-build-cache")
+ self.assertEqual(locate["run"], 'echo "path=$(go env GOCACHE)" >> "$GITHUB_OUTPUT"')
+ names = [step["name"] for step in self.jobs[job]["steps"]]
+ self.assertLess(names.index("Set up Go"), names.index(locate["name"]))
+ self.assertLess(names.index(locate["name"]), names.index(RESTORE))
+ next_step = "Provide frontend test embed stub" if job == "test-compile" else "Provide frontend embed stub"
+ self.assertLess(names.index(RESTORE), names.index(next_step))
+ for step in (setup, locate, restore):
+ if job == "test-compile":
+ self.assertNotIn("if", step)
+ else:
+ self.assertEqual(step["if"], "needs.changes.outputs.code == 'true'")
+
+ def test_only_successful_compiler_writes_before_dependent_tests_start(self):
+ job = self.jobs["test-compile"]
+ self.assertEqual(job["needs"], "changes")
+ self.assertEqual(job["if"], "needs.changes.outputs.go_compile == 'true'")
+ compile_step = self.step("test-compile", COMPILE)
+ self.assertEqual(compile_step["run"], "bash scripts/compile-go-tests.sh")
+ self.assertNotIn("if", compile_step)
+ self.assertNotIn("continue-on-error", compile_step)
+ save = self.step("test-compile", SAVE)
+ self.assertEqual(save, {
+ "name": SAVE,
+ # GitHub's implicit success() must remain in effect. A failed or
+ # cancelled compiler must never publish a newly prepared cache.
+ "if": "steps.race-cache.outputs.cache-hit != 'true'",
+ "continue-on-error": True,
+ "uses": f"actions/cache/save@{CACHE_ACTION}",
+ "with": {"path": CACHE_PATH, "key": "${{ steps.race-cache.outputs.cache-primary-key }}"},
+ })
+ self.assertEqual(job["steps"][-2:], [compile_step, save])
+ for name in ("backend", "backend-api"):
+ self.assertEqual(self.jobs[name]["needs"], ["changes", "test-compile"])
+ self.assertFalse(any("actions/cache/save@" in step.get("uses", "")
+ for step in self.jobs[name]["steps"]))
+
+ def test_cache_failure_or_miss_cannot_skip_validation_or_grant_admission(self):
+ for name in ("test-compile", "backend", "backend-api"):
+ job = self.jobs[name]
+ self.assertNotIn("continue-on-error", job)
+ for step in job["steps"]:
+ optional = step.get("name") in (RESTORE, SAVE)
+ self.assertEqual(step.get("continue-on-error", False), optional, step["name"])
+ if not optional:
+ self.assertNotIn("race-cache", str(step))
+ self.assertNotIn("cache-hit", str(step))
+ # A cache success/failure is not an output of a validation job.
+ self.assertNotIn("outputs", job)
+ compiler = (ROOT / "scripts/compile-go-tests.sh").read_text()
+ self.assertIn("go test -race -vet=off -count=1 -exec /bin/true ./...", compiler)
+ self.assertEqual(self.workflow["permissions"], {"contents": "read"})
+
+ def test_cache_path_command_uses_actual_tool_and_quotes_spaced_paths(self):
+ for name in ("test-compile", "backend", "backend-api"):
+ with self.subTest(job=name), tempfile.TemporaryDirectory() as temporary:
+ root = Path(temporary)
+ go = root / "go"
+ go.write_text('#!/bin/sh\n[ "$*" = "env GOCACHE" ] || exit 91\nprintf "%s\\n" "$FIXTURE_CACHE"\n')
+ go.chmod(0o700)
+ output = root / "output with spaces"
+ cache = root / "only build objects"
+ result = subprocess.run(
+ ["bash", "-euo", "pipefail", "-c", self.step(name, "Locate backend Go build cache")["run"]],
+ env={**os.environ, "PATH": f"{root}:{os.environ['PATH']}",
+ "GITHUB_OUTPUT": str(output), "FIXTURE_CACHE": str(cache)},
+ capture_output=True, text=True, timeout=5,
+ )
+ self.assertEqual(result.returncode, 0, result.stderr)
+ self.assertEqual(output.read_text(), f"path={cache}\n")
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/scripts/tests/test_go_test_compilation.py b/scripts/tests/test_go_test_compilation.py
index 81242982bc..7af6d8c2c5 100644
--- a/scripts/tests/test_go_test_compilation.py
+++ b/scripts/tests/test_go_test_compilation.py
@@ -135,7 +135,11 @@ func TestStaleFixture(t *testing.T) { _ = api.Resource{Alerts: []api.ResourceAle
):
self.assertIn(expected, compile_job)
self.assertLess(compile_job.index("ensure_test_assets.sh"), compile_job.index("compile-go-tests.sh"))
- self.assertNotIn("continue-on-error:", compile_job)
+ for step in re.split(r"(?m)^ - name: ", compile_job)[1:]:
+ if "continue-on-error:" in step:
+ self.assertTrue(step.startswith(("Restore backend race build objects\n",
+ "Save backend race build objects\n")))
+ self.assertIn("uses: actions/cache/", step)
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.