Skip to content

feat: archive build logs per run under /log/<date>-<run-id>/ - #6

Merged
Iamliuxiaozhen merged 1 commit into
mainfrom
feat/log-run-archive
Dec 1, 2026
Merged

Iamliuxiaozhen merged 1 commit into
mainfrom
feat/log-run-archive

Conversation

@Iamliuxiaozhen

Copy link
Copy Markdown
Member

Build logs used to be published as a single flat set, so each publish overwrote the previous run's logs and only the most recent build of a package was ever available. The package log files are now archived into a directory per workflow run:

/log/2026-12-01-46640252167/zitzhen-patchsplit.log

The run directory is -, so a new publish adds a directory instead of replacing files and older runs stay readable.

Implementation:

  • log-run-dir.sh derives the directory from github.run_started_at and github.run_id. It lives in a script rather than inline in the run: block: shell written into a workflow is only exercised in CI, and a bad substitution there already broke every build once.
  • collect-logs.sh takes the run directory as an optional third argument and writes into log//. It defaults to "latest" for local runs and rejects anything that is not a single safe path component, so a malformed value cannot escape log/.
  • publish-apt.yml passes the run directory when staging, and keeps the existing behaviour of staging logs before publish-repo.sh so log/ stays in the root index.

Two consequences of no longer overwriting, both handled:

  • The /log/ listing is regenerated from the run directories that actually exist in the bucket, not from the staged tree, which only knows the current run. Without this the listing would drop every previous run. stage-log-index.sh builds that index and the workflow unions the bucket's CommonPrefixes with the current run directory.
  • The sync still runs without --delete, so archiving a run never removes an older one. Pruning is left as a manual decision, and the docs say so.

The R2 sync keeps its three content-typed passes. The plain-text pass now uses log/ as its source root instead of a repo-wide 'log/**' include, because that include would also match log//index.html and overwrite the text/html type set by the pass before it.

Tests: script-checks.yml gains the run directory derivation (including rejection of non-numeric ids and path traversal) and the archived layout, asserting logs land under the run directory, that the root and /log/ indexes link to it, and that a /log/ index rebuilt from the bucket lists past runs as well as the current one. Also verified locally by simulating two consecutive publishes, confirming the first run's logs survive the second unchanged.

Build logs used to be published as a single flat set, so each publish
overwrote the previous run's logs and only the most recent build of a package
was ever available. The package log files are now archived into a directory
per workflow run:

  /log/2026-12-01-46640252167/zitzhen-patchsplit.log

The run directory is <UTC date>-<run id>, so a new publish adds a directory
instead of replacing files and older runs stay readable.

Implementation:

- log-run-dir.sh derives the directory from github.run_started_at and
  github.run_id. It lives in a script rather than inline in the run: block:
  shell written into a workflow is only exercised in CI, and a bad
  substitution there already broke every build once.
- collect-logs.sh takes the run directory as an optional third argument and
  writes into log/<run-dir>/. It defaults to "latest" for local runs and
  rejects anything that is not a single safe path component, so a malformed
  value cannot escape log/.
- publish-apt.yml passes the run directory when staging, and keeps the existing
  behaviour of staging logs before publish-repo.sh so log/ stays in the root
  index.

Two consequences of no longer overwriting, both handled:

- The /log/ listing is regenerated from the run directories that actually exist
  in the bucket, not from the staged tree, which only knows the current run.
  Without this the listing would drop every previous run. stage-log-index.sh
  builds that index and the workflow unions the bucket's CommonPrefixes with
  the current run directory.
- The sync still runs without --delete, so archiving a run never removes an
  older one. Pruning is left as a manual decision, and the docs say so.

The R2 sync keeps its three content-typed passes. The plain-text pass now uses
log/ as its source root instead of a repo-wide 'log/**' include, because that
include would also match log/<run>/index.html and overwrite the text/html type
set by the pass before it.

Tests: script-checks.yml gains the run directory derivation (including
rejection of non-numeric ids and path traversal) and the archived layout,
asserting logs land under the run directory, that the root and /log/ indexes
link to it, and that a /log/ index rebuilt from the bucket lists past runs as
well as the current one. Also verified locally by simulating two consecutive
publishes, confirming the first run's logs survive the second unchanged.

Signed-off-by: Oliver Lin <oliver@liuxiaozhen.dev>
@Iamliuxiaozhen
Iamliuxiaozhen merged commit b2efa5d into main Dec 1, 2026
4 checks passed
@Iamliuxiaozhen
Iamliuxiaozhen deleted the feat/log-run-archive branch December 1, 2026 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant