Report the run a workflow dispatch created; hermetic subprocess tests on macOS #330

Merged
stephen merged 3 commits from stephen/peter-swimm-dispatch-run-info into main 2026-11-17 23:18:14 +00:00
Owner

Two commits from Peter Swimm (Toilville LLC), applied unchanged with git am so he stays the author.

  1. The subprocess tests set FJ_CONFIG_DIR, so they are hermetic on macOS (which ignores XDG_CONFIG_HOME).
  2. fj workflow run sends return_run_info and, when Forgejo answers with the run's id, fetches that run (GET /actions/runs/{id}) instead of searching the run list. A 204 or a failed lookup still falls back to the search. Wiremock tests and a CHANGELOG entry are included.

Touches only CHANGELOG.md, src/api/workflow_run.rs, src/cli/workflow_run.rs, src/client/integration_tests.rs, tests/support/account_override.rs and tests/workflow_dispatch_lookup.rs. No build, network or CI changes.

Checked at toolchain 1.95.0: cargo clippy --all-targets -- -D warnings, cargo fmt --check and the full cargo test pass (1457 unit tests plus the integration tests).

Review notes for the maintainer (not changed here, to keep Peter's commits as sent):

  • If the run-id GET fails, the code falls back to the run-list search, which can pick up a concurrent dispatch of the same workflow and ref. Retrying the GET by id, or reporting the dispatch without a run, would keep the identity exact.
  • --watch passes only the run number on, so on a busy repo the watch path can still lose a run that the direct lookup found. The resolved run id could be carried through.
  • The new test returns run 41 for id 900 and checks only the run number; the returned id is not validated.
Two commits from Peter Swimm (Toilville LLC), applied unchanged with `git am` so he stays the author. 1. The subprocess tests set `FJ_CONFIG_DIR`, so they are hermetic on macOS (which ignores `XDG_CONFIG_HOME`). 2. `fj workflow run` sends `return_run_info` and, when Forgejo answers with the run's id, fetches that run (`GET /actions/runs/{id}`) instead of searching the run list. A 204 or a failed lookup still falls back to the search. Wiremock tests and a CHANGELOG entry are included. Touches only CHANGELOG.md, src/api/workflow_run.rs, src/cli/workflow_run.rs, src/client/integration_tests.rs, tests/support/account_override.rs and tests/workflow_dispatch_lookup.rs. No build, network or CI changes. Checked at toolchain 1.95.0: `cargo clippy --all-targets -- -D warnings`, `cargo fmt --check` and the full `cargo test` pass (1457 unit tests plus the integration tests). Review notes for the maintainer (not changed here, to keep Peter's commits as sent): - If the run-id GET fails, the code falls back to the run-list search, which can pick up a concurrent dispatch of the same workflow and ref. Retrying the GET by id, or reporting the dispatch without a run, would keep the identity exact. - `--watch` passes only the run number on, so on a busy repo the watch path can still lose a run that the direct lookup found. The resolved run id could be carried through. - The new test returns run 41 for id 900 and checks only the run number; the returned id is not validated.
macOS ignores XDG_CONFIG_HOME, so the spawned fj read the developer's real
hosts.toml and every account_override and workflow_dispatch_lookup case failed
there without sending a request to its mock.
Report the run a workflow dispatch created instead of searching for it
Some checks failed
ci / check (pull_request) Failing after 24m4s
ci / coverage (pull_request) Has been skipped
ci / live-e2e (pull_request) Has been skipped
f4a215a41e
Send return_run_info with the dispatch and, when Forgejo answers 201 with the
run's id, fetch that run. The run-list search remains for servers that answer
204. The search missed runs on a busy repository and could take another
dispatch of the same workflow for this one.
gerri approved these changes 2026-11-17 21:20:51 +00:00
Dismissed
gerri left a comment

Automated Codex review (read-only) of head f4a215a41e.

  • Low tests/workflow_dispatch_lookup.rs:137: Invariant: a regression test must verify the identity it claims to preserve. The dispatch response names ID 900, but the mocked GET returns a run with a different ID, and the test asserts only its run number. It therefore passes even if the command reports a different run from the one named by the server. Return a fixture with ID 900 and assert the output ID as well as the run number.

  • Low src/cli/workflow_run.rs:227: Invariant: preserve the dispatched run’s identity through lookup and watch. As noted in the PR body, a failed ID lookup falls back to a search that can select a concurrent dispatch, and --watch resolves the run again by number. These are deferred edge cases: retry the lookup by ID or report that the run could not be retrieved, and carry the ID into watch.

BLOCKING: 0

Reviewed head f4a215a41e at 2026-11-17T21:20:50Z by codex exec (read-only sandbox).

Automated Codex review (read-only) of head f4a215a41e4215c1a45a7c5b553a25e912196103. - **Low** `tests/workflow_dispatch_lookup.rs:137`: **Invariant: a regression test must verify the identity it claims to preserve.** The dispatch response names ID 900, but the mocked GET returns a run with a different ID, and the test asserts only its run number. It therefore passes even if the command reports a different run from the one named by the server. Return a fixture with ID 900 and assert the output ID as well as the run number. - **Low** `src/cli/workflow_run.rs:227`: **Invariant: preserve the dispatched run’s identity through lookup and watch.** As noted in the PR body, a failed ID lookup falls back to a search that can select a concurrent dispatch, and `--watch` resolves the run again by number. These are deferred edge cases: retry the lookup by ID or report that the run could not be retrieved, and carry the ID into watch. BLOCKING: 0 --- Reviewed head f4a215a41e4215c1a45a7c5b553a25e912196103 at 2026-11-17T21:20:50Z by codex exec (read-only sandbox).
Merge branch 'main' into stephen/peter-swimm-dispatch-run-info
All checks were successful
ci / check (pull_request) Successful in 37m7s
ci / live-e2e (pull_request) Successful in 5m16s
ci / coverage (pull_request) Successful in 6m16s
1ecb99b44a
gerri approved these changes 2026-11-17 22:32:49 +00:00
gerri left a comment

Automated Codex review (read-only) of head 1ecb99b44a.

  • Low: tests/workflow_dispatch_lookup.rs. Invariant: A test of run identity must verify that the run returned is the one named by the dispatch. The mock dispatch names ID 900, but the GET returns ID 41, and the test checks only the run number. It therefore passes even though the command reports a different ID. Return ID 900 with a distinct run number and assert both fields. This is the test gap already identified in the PR notes.

  • Low: src/cli/workflow_run.rs. Invariant: Preserve the dispatched run’s identity through lookup and watch. As noted in the PR body, a failed direct GET falls back to a search that can select a concurrent dispatch, and --watch resolves the run again by number. These are edge cases; retrying the GET by ID and carrying that ID through watch would preserve identity.

BLOCKING: 0

Reviewed head 1ecb99b44a at 2026-11-17T22:32:49Z by codex exec (read-only sandbox).

Automated Codex review (read-only) of head 1ecb99b44ab810d21e0b5d16809f87a28d86ecb7. - **Low**: [tests/workflow_dispatch_lookup.rs](/home/dev/work/reviews/rasterstate-fj-330/tests/workflow_dispatch_lookup.rs:134). **Invariant:** A test of run identity must verify that the run returned is the one named by the dispatch. The mock dispatch names ID 900, but the GET returns ID 41, and the test checks only the run number. It therefore passes even though the command reports a different ID. Return ID 900 with a distinct run number and assert both fields. This is the test gap already identified in the PR notes. - **Low**: [src/cli/workflow_run.rs](/home/dev/work/reviews/rasterstate-fj-330/src/cli/workflow_run.rs:225). **Invariant:** Preserve the dispatched run’s identity through lookup and watch. As noted in the PR body, a failed direct GET falls back to a search that can select a concurrent dispatch, and `--watch` resolves the run again by number. These are edge cases; retrying the GET by ID and carrying that ID through watch would preserve identity. BLOCKING: 0 --- Reviewed head 1ecb99b44ab810d21e0b5d16809f87a28d86ecb7 at 2026-11-17T22:32:49Z by codex exec (read-only sandbox).
Sign in to join this conversation.
No description provided.