src/actions.ts — downloadRunLogs (ZIP, guarded unzip, cache namespace) #116
Labels
No labels
bug
chore
documentation
enhancement
feature
ready
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
david/pi-extensions-and-skills#116
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
downloadRunLogs()insrc/actions.ts: cache-first download of the run-logs ZIP (GET /repos/{owner}/{repo}/actions/runs/{run_id}/logs), size-guarded extraction into the per-job cache namespace so laterjob_logcalls hit the cache.Background
Part of the Forgejo Actions tooling feature (tracking issue #111 — branch
feature/issue-111/forgejo-actions-tools, commitsissue-111: ...). Depends on the zip-extraction dependency (#112) and the cache module (#113). Powers theforgejo_action_run_logstool. The endpoint returns a ZIP of the run's job logs; Node has no built-in unzip, so extraction uses the library chosen in #112. Baseline: Forgejo v16.Documentation Required
docs/reference/forgejo-actions-api/(same folder as prior steps):read:repositoryscope).GET /repos/{owner}/{repo}/actions/runs/{run_id}/logs(returns a ZIP; response type/layout).docs/reference/adm-zip/ordocs/reference/yauzl/per the #112 decision.A separate process downloads these into
docs/reference/forgejo-actions-api/before this issue is implemented. Check that folder for the actual reference material before starting.Implementation Details
runZipPath()(#113); if it exists and norefresh, reuse it (still extract/return the listing; do not re-download).run.zip, then extract with size guards (protect against zip-bombs):Reject (fail with
ApiError) if any guard trips; do not extract oversized entries.<root>/<owner>/<repo>/<run_id>/<job_id>.log— so laterforgejo_action_job_logcalls hit the cache. Verify the ZIP's internal layout first: if entries don't map cleanly to job ids, fall back to a separate extraction dir (e.g.<run_id>/extracted/) and document which layout was found.{path, cached}for the ZIP itself.Acceptance Criteria
run.zip(exists, norefresh) does not re-download (mocked fetch not invoked for the ZIP).run.zip→ extraction lands files in the per-job cache namespace (or documented fallback dir) with a per-file listing returned.ApiError, leaving no partial extraction behind.readCachedLog()(#113).os.tmpdir()) cover cache hit/miss/refresh, guard rejection, and layout mapping.npm run checkpasses.Test Plan
cd extensions/forgejo && npm test— ZIP cases intests/actions.test.tsusing a fixture archive (create one in the test or commit a tiny fixture).forgejo_action_run_logs run_id=...→ confirmrun.zip+ per-job logs in~/.cache/forgejo-actions/...; thenforgejo_action_job_logfor one of those jobs returnscached: true.pi-loop opened and merged a pull request for this issue: #128