artifacts: archive non-report dirs at their own paths, list them on the artifact page

Every artifactDir landed below reports/ — the legacy
archived_artefact_dir_path layout — which mislabeled non-report outputs
(reports/werkdock/dist/werkdock) AND hid them: the artifact page's
report index only scans reports/ for HTML pages, so a built binary was
stored but never shown.

Now build/reports keeps archiving as reports/ (the browsable anchor and
every existing link), every other directory archives at its
workspace-relative path, and the artifact page gains a plain-files list
for everything outside reports/ (log files stay in their own section;
capped at 200 entries). Existing stored artifacts keep their old layout
and remain served; only new builds use the new one.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
mhoennig
2026-09-01 08:51:09 +02:00
co-authored by Claude Fable 5
parent db06d805ec
commit 4cdd5a1986
6 changed files with 68 additions and 8 deletions
@@ -90,9 +90,11 @@ class FileArtifactStoreTest : FunSpec() {
Files.readString(artifactDir.resolve("build.stdout.log")) shouldBe "out"
Files.readString(artifactDir.resolve("build.stderr.log")) shouldBe "err"
Files.readString(artifactDir.resolve("build.log")) shouldBe "live"
// legacy layout: build/reports archives as reports/, other dirs below reports/<dir>
// build/reports archives as reports/ (the artifact page's browsable
// anchor), every other dir at its own workspace-relative path
Files.exists(artifactDir.resolve("reports/tests/index.html")) shouldBe true
Files.exists(artifactDir.resolve("reports/build/doc/readme.txt")) shouldBe true
Files.exists(artifactDir.resolve("build/doc/readme.txt")) shouldBe true
Files.exists(artifactDir.resolve("reports/build")) shouldBe false
Files.exists(staging) shouldBe false
}
@@ -104,8 +106,8 @@ class FileArtifactStoreTest : FunSpec() {
h.store.persist(build, stagingDir(), workspace)
val artifactDir = h.branchesDir().resolve(build.artifactKey)
Files.exists(artifactDir.resolve("reports/build/doc/readme.txt")) shouldBe true
Files.exists(artifactDir.resolve("reports/tests")) shouldBe false
Files.exists(artifactDir.resolve("build/doc/readme.txt")) shouldBe true
Files.exists(artifactDir.resolve("reports")) shouldBe false
}
test("persist without a workspace stores only the logs") {
@@ -291,6 +291,30 @@ class UiControllerTest : FunSpec() {
).andExpect(content().string(not(containsString("reports/tests/test/packages/index.html"))))
}
test("artifact index lists plain files outside reports/ and keeps logs and report files out of that list") {
val artifactDir = Files.createDirectories(tempDir.resolve("files-view-key"))
Files.writeString(artifactDir.resolve("build.stdout.log"), "out")
Files.createDirectories(artifactDir.resolve("werkdock/dist"))
Files.writeString(artifactDir.resolve("werkdock/dist/werkdock"), "elf")
Files.createDirectories(artifactDir.resolve("reports/tests"))
Files.writeString(artifactDir.resolve("reports/tests/index.html"), "<html></html>")
every { repository.history() } returns listOf(successResult)
every { artifactStore.artifactDir("files-view-key") } returns artifactDir
val page =
mockMvc
.perform(get("/builds/files-view-key"))
.andExpect(status().isOk)
.andExpect(
content().string(containsString("""/artifacts/files-view-key/werkdock/dist/werkdock" target="_blank"""")),
).andReturn()
.response.contentAsString
// stored at its own path, not below reports/; the log stays in the
// logs section and is not repeated in the files list
page shouldNotContain "reports/werkdock"
(page.split("/artifacts/files-view-key/build.stdout.log").size - 1) shouldBe 1
}
test("the artifact page shows the command of the build's own definition, not the plain branch command") {
val pitestResult =
successResult.copy(