From 66b07a4b46617166b0ffc2bceef051024d204f19 Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Tue, 22 Sep 2026 01:10:41 +1000 Subject: [PATCH] fix(build): rebuild when the embedded dashboard changes The build task's only sources were **/*.go, go.mod and go.sum, while ui/embed.go embeds the committed bundle with //go:embed all:dist. Task's up-to-date check is a content checksum over files, so a change to ui/dist -- including the one `task ui` writes in place -- left the task "up to date" and the previously embedded dashboard in every binary. Measured on this worktree, appending a byte to ui/dist/index.html: git status M ui/dist/index.html task build task: Task "build" is up to date grep bin/archied 0 <- stale asset shipped With ui/dist/** listed, the same probe rebuilds all six binaries and the marker is present; a nested asset (ui/dist/assets/index.css) does too. Reverting the probe rebuilds again, and a second build with nothing changed still reports "up to date", so the content cache is intact. touch-only changes do not retrigger, confirming the check is on content rather than mtime. deployment_contract_test.go gains a bounded test over the build task's sources block, the shape the neighbouring fmt assertion already uses. The version stamps in the same task stay out of reach of a file checksum: git describe moves with HEAD while no file content does, and the git metadata is not addressable from a worktree, where .git is a file. That needs a status/stamp design decision, so it is split to archie-core-pdq2. --- Taskfile.yml | 3 +++ deployment_contract_test.go | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/Taskfile.yml b/Taskfile.yml index ffefc3ec2..11a6c66b2 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -375,6 +375,9 @@ tasks: - "**/*.go" - go.mod - go.sum + # ui/dist is committed and embedded by ui/embed.go (//go:embed all:dist), + # so it is a build input even though no .go file names it. + - "ui/dist/**" generates: - "{{.BIN_DIR}}/archied" - "{{.BIN_DIR}}/archie-gateway" diff --git a/deployment_contract_test.go b/deployment_contract_test.go index 38704457f..9cdd32fd6 100644 --- a/deployment_contract_test.go +++ b/deployment_contract_test.go @@ -108,6 +108,38 @@ func TestFormattingUsesOneConfiguredWriter(t *testing.T) { } } +func TestBuildTaskSourcesTrackEmbeddedAssets(t *testing.T) { + taskfile := readDeploymentFile(t, "Taskfile.yml") + start := strings.Index(taskfile, "\n build:\n") + end := strings.Index(taskfile, "\n test:\n") + if start < 0 || end < start { + t.Fatal("Taskfile has no bounded build task") + } + build := taskfile[start:end] + sourcesAt := strings.Index(build, "sources:") + generatesAt := strings.Index(build, "generates:") + if sourcesAt < 0 || generatesAt < sourcesAt { + t.Fatal("build task has no bounded sources block") + } + sources := build[sourcesAt:generatesAt] + + for _, tc := range []struct { + name string + path string + reason string + }{ + { + name: "embedded dashboard", + path: "ui/dist/**", + reason: "ui/embed.go embeds it with //go:embed all:dist, so a dashboard changing with no .go file changing must still rebuild the binaries", + }, + } { + if !strings.Contains(sources, tc.path) { + t.Errorf("build sources do not track %s: %s", tc.name, tc.reason) + } + } +} + func TestFormattersExcludeInterpretedSecretEngines(t *testing.T) { config := readDeploymentFile(t, ".golangci.yml") if !strings.Contains(config, `^examples/secret-engines/(age|sops|vault)\.go$`) {