Skip to content

refactor(build): one BuildPlan pipeline for git and local builds - #218

Closed
metalwarrior665 wants to merge 1 commit into
masterfrom
claude/quirky-goldberg-y6ifri
Closed

metalwarrior665 wants to merge 1 commit into
masterfrom
claude/quirky-goldberg-y6ifri

Conversation

@metalwarrior665

Copy link
Copy Markdown
Member

Why

runBuilds (git) and runBuildsFromLocal each had their own copy of "prepare read-only, dry-run cutoff, start, wait, summarize". They were glued together with actorFullName Maps (buildConfigsByActorFullName, preparedByActorFullName, buildersByActorFullName) and a runAndSummarizeBuilds callback API. Every cross-cutting build feature has to be written twice. #217 (env var sync check) already does this: it threads requireEnvVarsInSync through both flows and both option types.

What

  • BuildPlan: one Actor build, fully read and checked, with nothing written yet. It holds the builder, the fetched actorInfo, the version number, the cache flag, the dry-run summary and description, and a lazy toActorVersion(). For local builds that is where the upload happens, so it only runs for real builds.
  • executeBuildPlans(plans, { label, dryRun }) is now the only place that handles dry runs, starts builds, waits for them and prints the summary. A dry run returns the same DryRunPlan object as before.
  • loadActor is the shared first step: build the client and fetch the Actor once.
  • Both flows now only build plans. The Maps, runAndSummarizeBuilds, waitAndSummarizeBuilds (now internal to the executor) and the unused getDefaultVersionAndTag are gone.
  • uploadSourceZip takes the Actor id from the plan's actorInfo instead of fetching the Actor a second time. createVersionAndBuild now requires actorInfo (it was optional only so callers could skip a fetch).

Behaviour is unchanged: same logs, same dry-run JSON, builds returned sorted by Actor, and one builder (token check) per Actor. A dry run still never creates a version, build or upload.

Follow-ups this enables

Not touched on purpose

Testing

Added unit tests for executeBuildPlans: starting and waiting, sorting, failure propagation, the dry run touching nothing, and empty input. The existing build and build-from-local tests pass unchanged. Type-check, lint, prettier and the unit and bundle tests pass, and I rebuilt .github/cli/apify-test-tools.mjs.


Generated by Claude Code

Both builders prepared their plans and then ran a copy of the same
dry-run / start / wait / summarize flow, joined by actorFullName Maps.
They now only produce BuildPlans and executeBuildPlans runs them.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KgNt21yfetatNQnqhwG7hA
metalwarrior665 added a commit that referenced this pull request Nov 4, 2026
…ed-files (#228)

I think this makes sense, users can use `get-affected-actors` to get
changedFiles too.

## AI

`get-affected-actors` (#204) now computes commits, changed files and
changelog in one place from a single diff path. The three older commands
(`get-commits`, `get-latest-commit`, `get-changed-files`) are documented
as "kept for older workflows", but no workflow in this repo uses them.
They still carry a second, parallel git model:

- `getCommits`, which has its own rerun and base-commit heuristics and
duplicates what `since` does in `get-affected-actors`.
- `getChangedFiles`, which is `getChangedFilesBetween` with a `~` hack.
- `parseBaseCommit`, with the "SHA or Commit JSON" overload that only
existed to pipe `get-latest-commit` output back in.
- The `--source-branch`, `--target-branch` and `--base-commit` flags,
the `gitRangeOptions` group and the `Config` type.

#218 left these out on purpose and said the call belongs to the
maintainers. This PR is that proposal.

## What

- Remove the three commands and everything only they used. About 140
lines of source and about 250 lines of tests go away.
- `resolveReleaseBaseCommit` now validates the SHA inline and reuses
`findCommitSha`, instead of a second copy of the "`rev-parse` exit code
1 means missing" handling.
- Drop the "Legacy git commands" section from `docs/cli.md`.
CONTRIBUTING's CLI example now uses `get-affected-actors --base master`.
- Delete `logging.test.ts`. It compiled the whole project with `tsc`
(the cause of #227's timeout) just to check log levels through
`get-commits`. The same check is now two cases in `cli-bundle.test.ts`
that run `get-affected-actors` against the committed bundle.
- Rebuild the CLI bundle.

## Breaking

Anyone who calls these three commands directly breaks. The
`workflows-v0` reusable workflows don't, so only external users
scripting the CLI are affected. Since we're before v1, this is the
cheapest time to drop them. Whether to do it is the open question for
reviewers.

## Other ideas I considered and left out

Each overlaps an open PR, so it would conflict:

- #218 (build pipeline), #223 (`test` and `notify` commands) and #224
(bundle-based CLI tests) already cover the build and reporting code.
- Filling `lib/` gaps from issues (`fails` modifier #159, standby
without a task #127) are features, not refactors.

## Checks

- [x] `tsc`, eslint, prettier, knip (the unused exports it lists were
already on master) and `npm test` pass: 31 files, 438 tests.

---
_Generated by [Claude
Code](https://claude.ai/code/session_016XtpQvEqmuEhj1cBAaUxML)_

Co-authored-by: Claude <noreply@anthropic.com>
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.

2 participants