diff --git a/CHANGELOG.md b/CHANGELOG.md index a608d59..fb39c4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ Each release's section is published as its GitHub release notes (see [RUNBOOK.md](RUNBOOK.md#releasing)). +## Unreleased + +### Added + +- The cache server serves the cache service v2 API used by `actions/cache@v4`, on by default for jobs (`ACTIONS_CACHE_SERVICE_V2=true`), from the same store as the v1 API. BuildKit's `type=gha` cache (`docker/build-push-action`) goes through v2 as well; that path is built from its client's source and not yet confirmed with a real BuildKit run. A job-level `env: { ACTIONS_CACHE_SERVICE_V2: "" }` keeps that job on v1. + ## 0.3.0 ### Added diff --git a/CLAUDE.md b/CLAUDE.md index fa2ff48..1dde45a 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -46,7 +46,7 @@ Pipeline: `main.rs` (CLI + config assembly) → `workflow.rs` (load YAML) → `f - **`context.rs`**: `RepoInfo::detect` shells out to `git` to fill the `github` context (repo slug from `--remote-name`, sha, ref, default branch); `host` (`--github-instance`) drives the server/API URLs. `event_ref_and_sha` then overrides ref/sha from the event payload the way GitHub does (`refs/pull/N/merge`, release tags, push `ref`/`after`, …), and `GITHUB_*_URL` from the caller's environment win. - **`history.rs`**: `Recorder` (in `Config.history`, unless `--no-history` or `--insecure-secrets`) writes each run to `/runs//`: `meta.json` from `main.rs` (masked argv, repo, event, jobs by stage, and `config`: env/vars/inputs masked, secret names, platforms), every `Logger::line` after masking into `log.jsonl`, and `result.json` at the end. `Summary` / `Job::feed` rebuild jobs and steps from the log's status lines (`⭐`, `✅`/`❌`/`⚠️`/`🛑`, `⏭️`, `🚀`/`🏁`, `ℹ️` notes on what a local run does not reproduce) and keeps step summaries recorded beside them, formatted and parsed by `markers.rs`, whose tests check each line parses back. - **`dashboard.rs`**: `--dashboard` serves `dashboard.html` (one self-contained page, no build step) and a JSON API (`/api/runs`, `/api/runs/`, `/api/runs//job?workflow=&job=`) through `servers::serve`. -- **`servers.rs`**: std-only HTTP/1.1 servers jobs reach through `ACTIONS_CACHE_URL` (`@actions/cache` v1 API, on by default, entries persisted in `index.json`) and `ACTIONS_RESULTS_URL` (`@actions/artifact` v2 Twirp API plus Azure-blob-style block uploads, with `--artifact-server-path`; the toolkit sends proto field names such as `workflow_run_backend_id`) plus `ACTIONS_RUNTIME_URL` (the v1 API of the v3 actions, files under `v3//`, gzipped chunks stored with a `.gz__` suffix). `ACTIONS_RUNTIME_TOKEN` is a JWT signed with a per-run key (`RuntimeAuth`, or the caller's own token) whose `scp` claim carries the run/job IDs the toolkit parses; the artifact API refuses calls without it, except the signed block URLs. The cache API lives under a random per-run prefix (`cache_token`), lowercases keys, and garbage-collects entries (`CacheStore::gc`) on start and after each upload. They bind `127.0.0.1`, or `0.0.0.0` for Apple containers (reached via the vmnet gateway); a failure to start the cache server only disables it. +- **`servers.rs`**: std-only HTTP/1.1 servers jobs reach through `ACTIONS_CACHE_URL` (`@actions/cache` v1 API, on by default, entries persisted in `index.json`) and `ACTIONS_RESULTS_URL` (`@actions/artifact` v2 Twirp API plus Azure-blob-style block uploads, with `--artifact-server-path`; the toolkit sends proto field names such as `workflow_run_backend_id`) plus `ACTIONS_RUNTIME_URL` (the v1 API of the v3 actions, files under `v3//`, gzipped chunks stored with a `.gz__` suffix). `ACTIONS_RUNTIME_TOKEN` is a JWT signed with a per-run key (`RuntimeAuth`, or the caller's own token) whose `scp` claim carries the run/job IDs the toolkit parses; the artifact API refuses calls without it, except the signed block URLs. The cache v1 API lives under a random per-run prefix (`cache_token`), lowercases keys, and garbage-collects entries (`CacheStore::gc`) on start and after each upload. They bind `127.0.0.1`, or `0.0.0.0` for Apple containers (reached via the vmnet gateway); a failure to start the cache server only disables it. The cache v2 API (`ACTIONS_CACHE_SERVICE_V2`: `actions/cache@v4`, and BuildKit's `type=gha` when it is `true`) is the Twirp `CacheService` at the root of the cache port, or forwarded from the artifact port, over the same store; Twirp responses use proto snake_case names (`signed_upload_url`, `signed_download_url`, `matched_key`, `entry_id`: the toolkit masks the signed URLs only under those names). Its blobs sit at signed `/cache-v2/upload|download/` URLs (own per-run key, kinds `cache-upload` / `cache-download`): uploads are staged (`CacheStore::staging`) and only `FinalizeCacheEntryUpload` publishes them as the blob; downloads serve byte ranges (`x-ms-range` / `Range`) and `HEAD` for BuildKit's Go client (`docs/specs/cache-v2.md` section 5; not confirmed with a real BuildKit run). A second `CreateCacheEntry` for a key and version being uploaded (or complete) gets 409 `already_exists`; a reservation belongs to the token that made it (`CacheStore.owners`; tokens runthrough signs are unique per job leg through the `jti` claim, while under the caller's token all jobs share one); the v1 routes refuse upload, commit and download of a v2 reservation's id (`reserved_by_v2`), but a new v1 reservation of the same key and version still replaces a pending v2 one. Twirp calls need the run's `ACTIONS_RUNTIME_TOKEN`, which carries the job's cache-mode as the `runthrough_cache_mode` claim; a caller's own token carries none (v2 takes it as `write`), so `job_env` then sets `ACTIONS_CACHE_SERVICE_V2` to the empty string for non-`write` jobs, keeping them on v1 by default (a workflow or job that sets the variable itself overrides it, and v2 then treats the job as `write`). The toolkit drops the path of `ACTIONS_RESULTS_URL`, so with the cache server only it points at the cache origin (with `--cache-server-external-url`, that URL's origin, which the signed blob URLs use too), and with `--artifact-server-path` it stays at the artifact port. Parity with act is measured by `scripts/act_suite.py`, which runs act's runner integration tests (`TestRunEvent`, `TestRunEventHostEnvironment` and the single-workflow tests in `pkg/runner/runner_test.go`) through runthrough; see `docs/act-parity.md`, sixth pass, for the command and the last result. diff --git a/README.md b/README.md index c4b4e66..78a2210 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ Every run is recorded (with secrets masked) under `~/.cache/runthrough/runs`, an - `run` steps with `bash`, `sh`, `python`, `pwsh`, `node`, or custom `{0}` shells - `uses`: local and remote (`owner/repo[/path]@ref`) **composite**, **node** and **docker** actions, including `pre`/`post`, and `docker://image` steps; `--local-repository owner/repo@ref=PATH` substitutes a local folder - `actions/checkout` is emulated by copying the local repo (`--bind` mounts it instead, `--no-skip-checkout` runs the real action); other repositories are cloned -- A cache server for `actions/cache` (on by default; it also serves BuildKit's `type=gha` cache for `docker/build-push-action`) and, with `--artifact-server-path`, an artifact server for `upload-artifact` / `download-artifact` v3 and v4 (it only answers the run's own jobs, which carry its `ACTIONS_RUNTIME_TOKEN`) +- A cache server for `actions/cache` (on by default; it serves the v1 API (`ACTIONS_CACHE_URL`) and the v2 API (`ACTIONS_CACHE_SERVICE_V2`) from one store, and `cache-mode` holds on both, except that under the caller's own `ACTIONS_RUNTIME_TOKEN` only `write` jobs get v2 by default and the others are pointed at v1; BuildKit's `type=gha` cache for `docker/build-push-action` goes through v2 as well, built from its client's source but not yet confirmed with a real BuildKit run; a job's `env: { ACTIONS_CACHE_SERVICE_V2: "" }` keeps it on v1) and, with `--artifact-server-path`, an artifact server for `upload-artifact` / `download-artifact` v3 and v4 (it only answers the run's own jobs, which carry its `ACTIONS_RUNTIME_TOKEN`) - `GITHUB_OUTPUT`, `GITHUB_ENV`, `GITHUB_PATH`, `GITHUB_STATE`, `GITHUB_STEP_SUMMARY`, and `::set-output`, `::add-mask::`, `::group::`, `::error::`… commands, and problem matchers (`::add-matcher::`, `::remove-matcher::`); secrets are masked - `workflow_dispatch` inputs are checked before a run: `required`, `choice` `options`, `boolean` / `number` values @@ -78,7 +78,7 @@ Steps see `RUNTHROUGH=true` and `ACT=true` (also in the `env` context, so workfl ## Not supported -A job using one of these logs a note (`ℹ️`) when it starts. The cache service v2 API (`ACTIONS_CACHE_SERVICE_V2`). `permissions` and `jobs..snapshot` are validated but have no local effect; `environment` is reported (name and `url`) without environment secrets or protection rules. `concurrency` groups span one `runthrough` invocation, and a job cancelled by `cancel-in-progress` stops before its next step. +A job using one of these logs a note (`ℹ️`) when it starts. `permissions` and `jobs..snapshot` are validated but have no local effect; `environment` is reported (name and `url`) without environment secrets or protection rules. `concurrency` groups span one `runthrough` invocation, and a job cancelled by `cancel-in-progress` stops before its next step. ## Platforms diff --git a/docs/act-parity.md b/docs/act-parity.md index d2c3cdc..0745a94 100644 --- a/docs/act-parity.md +++ b/docs/act-parity.md @@ -16,7 +16,7 @@ sandbox) covers the servers, Docker and Apple `container`. - [x] Reusable workflows (`jobs..uses`) — local and `owner/repo/path@ref`, typed `with` inputs and defaults, `secrets` mapping or `inherit`, `on.workflow_call.outputs`, matrix callers *(act support unverified)* - [x] `actions/checkout` of another repository — shallow clone of `repository` at `ref` into `path`, with `token` passed as a header - [x] Artifact server (`--artifact-server-path`, `--artifact-server-addr`, `--artifact-server-port`) — the `@actions/artifact` v2 API used by `upload-artifact@v4` / `download-artifact@v4`; the v3 actions' API is not served -- [x] Cache server for `actions/cache` (`--no-cache-server`, `--cache-server-path`, `--cache-server-external-url`, `--cache-server-addr`, `--cache-server-port`) — the `@actions/cache` v1 API (`ACTIONS_CACHE_URL`), on by default and persisted under `~/.cache/runthrough/cache` +- [x] Cache server for `actions/cache` (`--no-cache-server`, `--cache-server-path`, `--cache-server-external-url`, `--cache-server-addr`, `--cache-server-port`) — the `@actions/cache` v1 API (`ACTIONS_CACHE_URL`) and the v2 API used by `actions/cache@v4` (`ACTIONS_CACHE_SERVICE_V2`), sharing one store, on by default and persisted under `~/.cache/runthrough/cache`. v2 details: the toolkit uses v2 only when the job's `GITHUB_SERVER_URL` host is `github.com`, `*.ghe.com` or `*.localhost`, and v1 otherwise; jobs get `ACTIONS_CACHE_SERVICE_V2=true` while the cache server runs, except that when runthrough's own environment sets a non-empty `ACTIONS_RUNTIME_TOKEN` (every job then gets that token, which carries no cache-mode, so the v2 server takes it as `write`), jobs whose `cache-mode` is not `write` get `ACTIONS_CACHE_SERVICE_V2` set to the empty string, which overrides a value inherited from runthrough's environment and by default keeps them on v1, whose URL carries their mode (a workflow or job that sets `ACTIONS_CACHE_SERVICE_V2` itself overrides it, and v2 then treats the job as `write`; an empty caller token counts as none: runthrough signs its own); the injected value is overridden by a workflow, job or step `env:` and by `--env`, so a job-level `env: { ACTIONS_CACHE_SERVICE_V2: "" }` keeps one job on v1; the Twirp calls need the run's `ACTIONS_RUNTIME_TOKEN`, while blob uploads and downloads are authorized by their signed URLs alone; the toolkit drops the path of `ACTIONS_RESULTS_URL`, so with the cache server only it points at the cache server's origin (with `--cache-server-external-url`, that URL's origin; a proxy must forward `/twirp/` and `/cache-v2/` at its root), and with `--artifact-server-path` it stays at the artifact port, which forwards the cache calls; `--no-cache-server` sets neither `ACTIONS_CACHE_SERVICE_V2` nor a cache-derived `ACTIONS_RESULTS_URL`. BuildKit's `type=gha` cache (`docker/build-push-action`, buildx; Go client `tonistiigi/go-actions-cache`) switches to the v2 API too when the job has `ACTIONS_CACHE_SERVICE_V2=true`; the v2 routes serve what that client needs: byte-range downloads (`x-ms-range` or `Range`, `bytes=N-` / `bytes=N-M`, answered `206` when the range has data and `416` when it starts at or beyond the end), `HEAD` on the signed download URL, an `x-ms-request-id` header on every answer, and a 409 `already_exists` answer to a `CreateCacheEntry` for a key and version that exist or are being uploaded, which the client takes as "already exists". This is built from the client's source and tested at the handler level, not confirmed with a real BuildKit run (see `docs/specs/cache-v2.md`, section 5) ## Run control @@ -262,7 +262,7 @@ Keys runthrough accepted but did not act on, or did not know: - [x] `on.` filters (`branches`, `branches-ignore`, `tags`, `tags-ignore`, `paths`, `paths-ignore`, `types`, `workflow_run.workflows`) decide whether a workflow runs, as on GitHub. **Differs from act**, which selects by event name only; `-j` or a single workflow file still bypasses them. Changed files come from the payload's `commits` or `before`..`after` (`pull_request`: `base.sha...head.sha`); without them `paths` passes. Without `-e`, a `push` payload's `before` is `/` when HEAD is ahead of it (what pushing now would send), so `paths` and actions such as `dorny/paths-filter` see the unpushed commits; an up-to-date, behind or new branch gets no `before`, and the checkout's `origin/` points at the commit being run, as after the push on GitHub - [x] `steps[*].background`, `wait`, `wait-all`, `cancel`, `parallel`: background steps run on their own threads (at most 10 at once), their outputs, `GITHUB_ENV` / `GITHUB_PATH` additions and post steps apply when waited for, an implicit `wait-all` precedes the post steps, and `cancel` (or the job being cancelled, also while it waits for them) sends SIGTERM to the step's process group, then SIGKILL after 5s (a timeout kills the group; on Windows the process tree is ended with `taskkill`); on the host that group also ends when runthrough exits; `parallel` children's `pre` hooks run in the job's pre phase; rejected inside composite actions - [x] `concurrency` (workflow and job): one holder per group (case-insensitive), the default queue replaces the pending run, `queue: max` keeps up to 100 in order, `cancel-in-progress` cancels the holder; a group an enclosing workflow or calling job already holds is cancelled as a deadlock (as GitHub does), and a called workflow's own `concurrency` applies (inside it `github.workflow` is the caller's, as on GitHub); `queue: max` with `cancel-in-progress` is a validation error. Groups span one runthrough invocation, and a cancelled holder stops before its next step -- [x] `cache-mode` (workflow and job: `read`, `write`, `write-only`, `none`) is enforced by the cache server: a denied restore is a miss, a denied save gets 403, which `@actions/cache` logs as "Failed to save" without failing the step; the upload, commit and download endpoints check the mode too, and only a pending reservation takes data +- [x] `cache-mode` (workflow and job: `read`, `write`, `write-only`, `none`) is enforced by the cache server: a denied restore is a miss, a denied save gets 403, which `@actions/cache` logs as "Failed to save" without failing the step; the upload, commit and download endpoints check the mode too, and only a pending reservation takes data. The v2 API is limited the same way for jobs that carry a token runthrough signed, which names the job's mode: a denied restore is a miss, a denied save is `ok: false` with a message, which `@actions/cache` logs as a warning without failing the step. The caller's own `ACTIONS_RUNTIME_TOKEN` names no mode, so the v2 server cannot tell the jobs apart and treats every call as `write`; non-`write` jobs are then kept on the v1 API by default, which enforces their mode (see the cache server above) - [x] `jobs..environment`: the name is reported at job start and `url` after the steps (it may use `steps`); no deployments, environment secrets or protection rules - [x] `services..command` and `entrypoint` - [x] `run-name` is evaluated and printed diff --git a/docs/index.html b/docs/index.html index 28065eb..7011b78 100644 --- a/docs/index.html +++ b/docs/index.html @@ -347,7 +347,7 @@

Expressions

Props backstage