apify-test-tools 0.10.2-beta.4 → 0.10.2-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/.github/actions/checkout-restore-dependencies/action.yaml +43 -3
  2. package/.github/cli/apify-test-tools.mjs +125 -127
  3. package/.github/scripts/run-with-apify-tokens.mjs +1 -1
  4. package/.github/workflows/public_platform-tests-claude-investigate-and-fix.yaml +7 -0
  5. package/CHANGELOG.md +7 -0
  6. package/CONTRIBUTING.md +4 -1
  7. package/README.md +72 -73
  8. package/bin/affected-actors.ts +132 -91
  9. package/bin/build.ts +0 -2
  10. package/bin/diff-changes.ts +7 -6
  11. package/bin/diff-json-schema.ts +5 -6
  12. package/bin/git.ts +21 -55
  13. package/bin/main.ts +7 -97
  14. package/bin/slack.ts +14 -27
  15. package/bin/types.ts +6 -0
  16. package/dist/bin/affected-actors.d.ts +23 -22
  17. package/dist/bin/affected-actors.d.ts.map +1 -1
  18. package/dist/bin/affected-actors.js +108 -60
  19. package/dist/bin/affected-actors.js.map +1 -1
  20. package/dist/bin/build.d.ts +0 -1
  21. package/dist/bin/build.d.ts.map +1 -1
  22. package/dist/bin/build.js +0 -2
  23. package/dist/bin/build.js.map +1 -1
  24. package/dist/bin/diff-changes.d.ts +4 -3
  25. package/dist/bin/diff-changes.d.ts.map +1 -1
  26. package/dist/bin/diff-changes.js +4 -4
  27. package/dist/bin/diff-changes.js.map +1 -1
  28. package/dist/bin/diff-json-schema.d.ts +2 -2
  29. package/dist/bin/diff-json-schema.d.ts.map +1 -1
  30. package/dist/bin/diff-json-schema.js +1 -4
  31. package/dist/bin/diff-json-schema.js.map +1 -1
  32. package/dist/bin/git.d.ts +6 -9
  33. package/dist/bin/git.d.ts.map +1 -1
  34. package/dist/bin/git.js +20 -48
  35. package/dist/bin/git.js.map +1 -1
  36. package/dist/bin/main.js +7 -77
  37. package/dist/bin/main.js.map +1 -1
  38. package/dist/bin/slack.d.ts +2 -7
  39. package/dist/bin/slack.d.ts.map +1 -1
  40. package/dist/bin/slack.js +12 -18
  41. package/dist/bin/slack.js.map +1 -1
  42. package/dist/bin/types.d.ts +5 -0
  43. package/dist/bin/types.d.ts.map +1 -1
  44. package/dist/test/bundle/cli-bundle.test.js +14 -16
  45. package/dist/test/bundle/cli-bundle.test.js.map +1 -1
  46. package/dist/test/e2e/cli-bundle.e2e.test.js +22 -63
  47. package/dist/test/e2e/cli-bundle.e2e.test.js.map +1 -1
  48. package/dist/test/e2e/git-build-release.e2e.test.d.ts +2 -0
  49. package/dist/test/e2e/git-build-release.e2e.test.d.ts.map +1 -0
  50. package/dist/test/e2e/git-build-release.e2e.test.js +87 -0
  51. package/dist/test/e2e/git-build-release.e2e.test.js.map +1 -0
  52. package/dist/test/e2e/helpers.d.ts +37 -0
  53. package/dist/test/e2e/helpers.d.ts.map +1 -0
  54. package/dist/test/e2e/helpers.js +57 -0
  55. package/dist/test/e2e/helpers.js.map +1 -0
  56. package/dist/test/unit/bin/affected-actors-cli.test.d.ts +2 -0
  57. package/dist/test/unit/bin/affected-actors-cli.test.d.ts.map +1 -0
  58. package/dist/test/unit/bin/affected-actors-cli.test.js +161 -0
  59. package/dist/test/unit/bin/affected-actors-cli.test.js.map +1 -0
  60. package/dist/test/unit/bin/affected-actors.test.js +65 -78
  61. package/dist/test/unit/bin/affected-actors.test.js.map +1 -1
  62. package/dist/test/unit/bin/build-cli.test.js +5 -13
  63. package/dist/test/unit/bin/build-cli.test.js.map +1 -1
  64. package/dist/test/unit/bin/compiled-cli.d.ts +6 -0
  65. package/dist/test/unit/bin/compiled-cli.d.ts.map +1 -0
  66. package/dist/test/unit/bin/compiled-cli.js +16 -0
  67. package/dist/test/unit/bin/compiled-cli.js.map +1 -0
  68. package/dist/test/unit/bin/diff-changes.test.js +55 -55
  69. package/dist/test/unit/bin/diff-changes.test.js.map +1 -1
  70. package/dist/test/unit/bin/diff.test.js +25 -28
  71. package/dist/test/unit/bin/diff.test.js.map +1 -1
  72. package/dist/test/unit/bin/git.test.js +29 -97
  73. package/dist/test/unit/bin/git.test.js.map +1 -1
  74. package/dist/test/unit/bin/slack.test.js +6 -27
  75. package/dist/test/unit/bin/slack.test.js.map +1 -1
  76. package/dist/test/unit/should-built-and-test.test.js +18 -21
  77. package/dist/test/unit/should-built-and-test.test.js.map +1 -1
  78. package/dist/tsconfig.tsbuildinfo +1 -1
  79. package/package.json +1 -1
  80. package/test/bundle/cli-bundle.test.ts +14 -24
  81. package/test/e2e/cli-bundle.e2e.test.ts +39 -84
  82. package/test/e2e/git-build-release.e2e.test.ts +113 -0
  83. package/test/e2e/helpers.ts +82 -0
  84. package/test/unit/bin/affected-actors-cli.test.ts +193 -0
  85. package/test/unit/bin/affected-actors.test.ts +83 -85
  86. package/test/unit/bin/build-cli.test.ts +6 -12
  87. package/test/unit/bin/compiled-cli.ts +17 -0
  88. package/test/unit/bin/diff-changes.test.ts +55 -55
  89. package/test/unit/bin/diff.test.ts +25 -28
  90. package/test/unit/bin/git.test.ts +37 -120
  91. package/test/unit/bin/slack.test.ts +6 -30
  92. package/test/unit/should-built-and-test.test.ts +19 -22
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  // Runs apify-test-tools and passes it only secrets needed for the Actors, no other secrets are leaked.
3
3
  //
4
- // node .github/scripts/run-with-apify-tokens.mjs apify-test-tools build-for-test --target-branch ...
4
+ // jq ... | node .github/scripts/run-with-apify-tokens.mjs apify-test-tools build --version-number 0.99
5
5
  //
6
6
  // The step passes the whole secrets map as ALL_SECRETS. The token names come from `tokenEnvVar` in
7
7
  // the repo's apify-test-tools.config.json, which is the same file apify-test-tools itself reads, so
@@ -39,6 +39,11 @@ on:
39
39
  type: string
40
40
  default: sonnet
41
41
  description: Claude model to use for investigation and fix
42
+ effort:
43
+ required: false
44
+ type: string
45
+ default: ''
46
+ description: Claude effort level (low, medium, high, xhigh, max) to use for investigation and fix. Uses the Claude Code default when empty.
42
47
  max_flakiness_runs:
43
48
  required: false
44
49
  type: number
@@ -115,6 +120,7 @@ jobs:
115
120
  claude_args: |
116
121
  --mcp-config '{"mcpServers":{"apify":{"type":"http","url":"https://mcp.apify.com/?tools=get-actor-run,get-actor-run-log,get-dataset-list,get-dataset,get-dataset-items,get-key-value-store-list,get-key-value-store,get-key-value-store-keys,get-key-value-store-record","headers":{"Authorization":"Bearer ${TESTER_APIFY_TOKEN}"}}}}'
117
122
  --model ${{ inputs.model }}
123
+ ${{ inputs.effort && format('--effort {0}', inputs.effort) || '' }}
118
124
  --dangerously-skip-permissions
119
125
 
120
126
  - name: Upload Claude output (for debugging)
@@ -190,6 +196,7 @@ jobs:
190
196
  prompt: 'Open a pull request to address GitHub issue #${{ needs.investigate.outputs.issue_number }}. Use `gh issue view ${{ needs.investigate.outputs.issue_number }}` to read the issue details first, then implement the fix and create a PR.'
191
197
  claude_args: |
192
198
  --model ${{ inputs.model }}
199
+ ${{ inputs.effort && format('--effort {0}', inputs.effort) || '' }}
193
200
  --dangerously-skip-permissions
194
201
 
195
202
  - name: Upload Claude output (for debugging)
package/CHANGELOG.md CHANGED
@@ -10,12 +10,19 @@ All notable changes to this project will be documented in this file.
10
10
  - **ci:** Ship the workflows' CLI as a bundle in the action instead of installing it ([#200](https://github.com/apify/apify-test-tools/pull/200)) ([a0ef975](https://github.com/apify/apify-test-tools/commit/a0ef9756123a30a8210590b080a2a289c6a9c17c)) by [@metalwarrior665](https://github.com/metalwarrior665)
11
11
  - [**breaking**] Revamp get-affected-actors to be a core logic command ([#190](https://github.com/apify/apify-test-tools/pull/190)) ([ea5f244](https://github.com/apify/apify-test-tools/commit/ea5f244cfd42bf3fa9ffd38cd2ad499dde2e83f8)) by [@metalwarrior665](https://github.com/metalwarrior665)
12
12
  - [**breaking**] Add logic-less build command and use command chaining in workflows ([#193](https://github.com/apify/apify-test-tools/pull/193)) ([e5b0b86](https://github.com/apify/apify-test-tools/commit/e5b0b86ee06fca51d4be0ddc81b0a4a469d31603)) by [@metalwarrior665](https://github.com/metalwarrior665)
13
+ - **get-affected-actors:** Three-dot diff, narrowed per Actor with --since ([#204](https://github.com/apify/apify-test-tools/pull/204)) ([fa9a0e7](https://github.com/apify/apify-test-tools/commit/fa9a0e7518764dd4722ec9ecbf67b2a26a5a062e)) by [@metalwarrior665](https://github.com/metalwarrior665)
14
+ - Add effort input to Claude investigate-and-fix workflow ([#221](https://github.com/apify/apify-test-tools/pull/221)) ([c2ac078](https://github.com/apify/apify-test-tools/commit/c2ac078aec9ef02337af0e5c06db1b947b6c969b)) by [@foxt451](https://github.com/foxt451)
15
+ - **ci:** Support pnpm ([#214](https://github.com/apify/apify-test-tools/pull/214)) ([ee7d734](https://github.com/apify/apify-test-tools/commit/ee7d7340564c5b8657a8a1f0cf920d67b40ae013)) by [@ruocco-l](https://github.com/ruocco-l)
13
16
 
14
17
  ### 🐛 Bug Fixes
15
18
 
16
19
  - **toBeObject:** Reject null ([#191](https://github.com/apify/apify-test-tools/pull/191)) ([6bdae49](https://github.com/apify/apify-test-tools/commit/6bdae4905756e0ae8dd6146942e6fc04dbead48e)) by [@JuanGalilea](https://github.com/JuanGalilea), closes [#88](https://github.com/apify/apify-test-tools/issues/88)
17
20
  - Build and test on test-only changes even when .dockerignore lists the tests ([#177](https://github.com/apify/apify-test-tools/pull/177)) ([5cb1b5a](https://github.com/apify/apify-test-tools/commit/5cb1b5ab5f6f43ec279f9624b402e73d55a5974a)) by [@artogahr](https://github.com/artogahr), closes [#145](https://github.com/apify/apify-test-tools/issues/145)
18
21
 
22
+ ### 🚜 Refactor
23
+
24
+ - [**breaking**] Remove build-for-test and release composite commands ([#203](https://github.com/apify/apify-test-tools/pull/203)) ([85efc54](https://github.com/apify/apify-test-tools/commit/85efc54697e98208c827c4f450906e00eebcd9ca)) by [@metalwarrior665](https://github.com/metalwarrior665)
25
+
19
26
 
20
27
  <!-- git-cliff-unreleased-end -->
21
28
  ## [0.10.1](https://github.com/apify/apify-test-tools/releases/tag/v0.10.1) (2026-10-13)
package/CONTRIBUTING.md CHANGED
@@ -94,9 +94,12 @@ npm release relate — the short version:
94
94
  - the CLI runs from `.github/cli/apify-test-tools.mjs`, a bundle the pre-commit hook rebuilds with
95
95
  `npm run bundle`. If you commit with `--no-verify`, run it yourself: the `CLI bundle` check fails
96
96
  on a stale bundle, and a stale bundle would hold the tag.
97
- - `npm test` covers the bundle without network (`test/bundle/`). `npm run test:e2e` runs it against two
97
+ - `npm test` covers the bundle without network (`test/bundle/`). `npm run test:e2e` runs it against
98
98
  dummy Actors in an isolated sandbox account (`test/e2e/`) and skips itself unless
99
99
  `E2E_TEST_APIFY_TOKEN_DBYPODOIHUZABNQTR` is set. CI passes that secret only to the `E2E tests` job.
100
+ The git `build` and release pipeline tests clone
101
+ [testing-repo-for-github-actions](https://github.com/apify-store/testing-repo-for-github-actions) and
102
+ use its `e2e/base` and `e2e/feature` branches as fixtures, so never rebase or delete those.
100
103
 
101
104
  `npm run lint` and `actionlint` (via the `Code checks` workflow) both gate master, so run them before
102
105
  pushing workflow changes.
package/README.md CHANGED
@@ -57,7 +57,7 @@ When a PR is opened or code is pushed, the tool determines which actors need to
57
57
  2. **CHANGELOG classification** — a `CHANGELOG.md` file is always `cosmetic` (only triggers a release build, not tests), for every actor, regardless of context or folder. (See [issue #106](https://github.com/apify/apify-test-tools/issues/106).)
58
58
  3. **Context matching** — the file must fall within one of the actor's context paths (`dockerContextDir` from `actor.json` by default, or `overrideActorContext` from config if set). Files outside every context path are skipped.
59
59
  4. **Hardcoded ignore list, context-aware** — the file path is first "hoisted" relative to the context path it matched (e.g. a standalone actor's own `.eslintrc` is checked as just `.eslintrc`, not the full repo-root-relative path), then checked against repo-level dev file patterns (`.vscode/`, `.gitignore`, `.husky/`, `.eslintrc`, `eslint.config.mjs`, `.prettierrc`, `.editorconfig`). There's no hardcoded special-casing for legacy `code/`/`shared/` layouts — repos that need those directories treated as top-level must list them explicitly in `overrideActorContext`.
60
- 5. **`.dockerignore` filtering** — if a `.dockerignore` exists at the root of the actor's `dockerContextDir`, matching files are ignored. Patterns are resolved relative to `dockerContextDir`, matching Docker's own behavior. Test files are the exception: `build-for-test --test-files-glob <glob>` (relative to the repo root, also taken by `get-affected-actors`) skips this check for matching files, so a changed test triggers a build, and with it its tests, even when `.dockerignore` lists it. The PR workflow passes `test/platform/**`. Context matching still applies, so tests outside an actor's `dockerContextDir` (e.g. a root `test/` with standalone actors) need to be listed in its `overrideActorContext`; `build-for-test` logs a warning for changed test files outside every actor's context.
60
+ 5. **`.dockerignore` filtering** — if a `.dockerignore` exists at the root of the actor's `dockerContextDir`, matching files are ignored. Patterns are resolved relative to `dockerContextDir`, matching Docker's own behavior. Test files are the exception: `get-affected-actors --test-files-glob <glob>` (relative to the repo root) skips this check for matching files, so a changed test triggers a build, and with it its tests, even when `.dockerignore` lists it. The PR workflow passes `test/platform/**`. Context matching still applies, so tests outside an actor's `dockerContextDir` (e.g. a root `test/` with standalone actors) need to be listed in its `overrideActorContext`; `get-affected-actors` logs a warning for changed test files outside every actor's context.
61
61
  6. **README classification** — a `README.md` file is `cosmetic` (only triggers a release build, not tests) if it lives inside the actor's own `folder`; otherwise it's ignored entirely, since it isn't documentation for this actor.
62
62
  7. **Cosmetic JSON classification** — `.json` files inside the actor's own `.actor/` directory with only cosmetic schema changes (whitespace, key ordering) only trigger a release build.
63
63
  8. **Functional** — everything else triggers both build and tests.
@@ -226,9 +226,8 @@ jobs:
226
226
  secrets: inherit
227
227
  ```
228
228
 
229
- This workflow does what `apify-test-tools release --base-commit ${{ github.event.before }}` does, one
230
- step per command: `get-affected-actors --since ${{ github.event.before }}`, then `build --version-number default`
231
- on every changed Actor, then `notify-release`. See [Releasing Actors](#releasing-actors-release) for how the
229
+ This workflow runs one step per command: `get-affected-actors --since ${{ github.event.before }}`, then
230
+ `build --version-number default` on every changed Actor, then `notify-release`. See [Releasing Actors](#releasing-actors) for how the
232
231
  released range is determined and what to pass if you call the CLI from somewhere else.
233
232
 
234
233
  ### `claude-review.yaml`
@@ -274,11 +273,13 @@ secrets to pass on:
274
273
 
275
274
  ```yaml
276
275
  - name: Build
276
+ shell: bash
277
277
  env:
278
278
  ALL_SECRETS: ${{ toJSON(secrets) }}
279
279
  run: |
280
- node "${{ steps.setup.outputs.scripts-path }}/run-with-apify-tokens.mjs" \
281
- npx apify-test-tools build-for-test --target-branch ...
280
+ jq '{ actors: .functionallyChangedActors }' affected.json \
281
+ | node "${{ steps.setup.outputs.scripts-path }}/run-with-apify-tokens.mjs" \
282
+ npx apify-test-tools build --version-number 0.99
282
283
  ```
283
284
 
284
285
  The wrapper passes only the tokens the config declares and drops `ALL_SECRETS`, so neither `npx` nor
@@ -304,8 +305,9 @@ Two tidier-looking alternatives don't work, so don't reach for them:
304
305
  an output whose value contains a registered secret. It logs `Skip output <name> since it may
305
306
  contain secret` and leaves the output empty, so anything reading it downstream gets nothing.
306
307
 
307
- The `unitTest` job runs static checks and needs `NPM_TOKEN` only. No job runs `npm ci` with Apify or
308
- Slack credentials in scope, so a postinstall script in the dependency tree cannot read them.
308
+ The `unitTest` job runs static checks and needs `NPM_TOKEN` only. No job runs `npm ci` or
309
+ `pnpm install` with Apify or Slack credentials in scope, so a postinstall script in the dependency
310
+ tree cannot read them.
309
311
 
310
312
  ## Versioning and releases
311
313
 
@@ -569,12 +571,12 @@ The package includes a CLI binary used by CI workflows to build Actors, detect c
569
571
 
570
572
  ### Dry runs (`--dry-run`)
571
573
 
572
- Every command that changes something (`build`, `build-for-test`, `build-from-local`, `release`, `notify-release`, `delete-old-builds`, `report-tests`) takes `--dry-run`. A dry run:
574
+ Every command that changes something (`build`, `build-from-local`, `notify-release`, `delete-old-builds`, `report-tests`) takes `--dry-run`. A dry run:
573
575
 
574
576
  - **Changes nothing.** No versions or builds are created, nothing is uploaded or deleted, and no Slack message is posted.
575
577
  - **Does every read and check the real run does**, so it fails wherever the real run would: change detection, the Apify token and Actor lookup, the [repository check](#repository-check), collecting and zipping local sources, and the Slack token (verified with Slack's read-only `auth.test`).
576
578
  - **Needs the same tokens as the real run.** Read-only tokens are enough, since nothing is written. A dry run can't tell whether a token is also allowed to write, because the Apify API has no dry-run mode of its own.
577
- - **Prints a plan, not results.** Logs start with `[DRY RUN] Would …`. `build`, `build-for-test` and `build-from-local` write `{ "dryRun": true, "builds": [...] }` to stdout instead of the build array, so the plan can't be passed to tests as `ACTOR_BUILDS` by mistake.
579
+ - **Prints a plan, not results.** Logs start with `[DRY RUN] Would …`. `build` and `build-from-local` write `{ "dryRun": true, "builds": [...] }` to stdout instead of the build array, so the plan can't be passed to tests as `ACTOR_BUILDS` by mistake.
578
580
 
579
581
  ### Running locally
580
582
 
@@ -599,16 +601,15 @@ If you want to test vs existing src code, you can skip this and instead construc
599
601
  Requires `APIFY_TOKEN_<USERNAME>` for all Apify users that own your Actors (e.g. `apify`, `compass`, `lukaskrivka` users). The username is derived from the actor name — uppercased with non-word chars replaced by `_` (e.g. Actor `john.doe/my-actor` needs `APIFY_TOKEN_JOHN_DOE`).
600
602
 
601
603
  ```bash
602
- APIFY_TOKEN_JOHN_DOE=<token> \
603
- npx apify-test-tools build-for-test \
604
- --target-branch origin/master \
605
- --dry-run
604
+ npx apify-test-tools get-affected-actors --base origin/master \
605
+ | jq '{ actors: .functionallyChangedActors }' \
606
+ | APIFY_TOKEN_JOHN_DOE=<token> npx apify-test-tools build --version-number 0.99 --dry-run
606
607
  ```
607
608
 
608
- Run it with your dummy branch checked out: it builds the Actors that branch changed, from the branch as it is on
609
- the remote. With `--dry-run`, it prints the plan (the version and Git URL each Actor would be built from). Remove
610
- `--dry-run` to actually trigger builds and update the target branch name. The command outputs a JSON array of build
611
- objects to stdout:
609
+ Run it with your dummy branch checked out: it builds the Actors that branch changed functionally, from the branch
610
+ as it is on the remote, into the test version `0.99`. With `--dry-run`, it prints the plan (the version and Git URL
611
+ each Actor would be built from). Remove `--dry-run` to actually trigger builds, and update `--base` to the branch
612
+ you compare against. `build` outputs a JSON array of build objects to stdout:
612
613
 
613
614
  ```json
614
615
  [{ "buildId": "...", "actorRawId": "...", "buildNumber": "...", "actorFullName": "john.doe/my-actor" }]
@@ -647,14 +648,13 @@ TESTER_APIFY_TOKEN=<token> \
647
648
 
648
649
  #### Full example
649
650
 
650
- Tests only run for Actors in `ACTOR_BUILDS`, so a custom workflow has to build (and pass) the Actors even when only tests changed. Pass `--test-files-glob` so test changes count even when `.dockerignore` lists them.
651
+ Tests only run for Actors in `ACTOR_BUILDS`, so a custom workflow has to build (and pass) the Actors even when only tests changed. Pass `--test-files-glob` to `get-affected-actors` so test changes count even when `.dockerignore` lists them.
651
652
 
652
653
  ```bash
653
654
  # Build and capture output
654
- BUILDS=$(APIFY_TOKEN_JOHN_DOE=apify_api_xxx \
655
- npx apify-test-tools build-for-test \
656
- --target-branch origin/master \
657
- --test-files-glob 'test/platform/**')
655
+ BUILDS=$(npx apify-test-tools get-affected-actors --base origin/master --test-files-glob 'test/platform/**' \
656
+ | jq '{ actors: .functionallyChangedActors }' \
657
+ | APIFY_TOKEN_JOHN_DOE=apify_api_xxx npx apify-test-tools build --version-number 0.99)
658
658
 
659
659
  # Run tests with the builds
660
660
  ACTOR_BUILDS="$BUILDS" \
@@ -669,7 +669,7 @@ TESTER_APIFY_TOKEN=apify_api_yyy \
669
669
  The range always ends at the checked-out `HEAD`, so check out the branch you want to inspect first.
670
670
 
671
671
  ```bash
672
- # A PR: the branch's own commits, after its last validated commit
672
+ # A PR: the branch's own changes, narrowed to the Actors that changed since its last validated commit
673
673
  npx apify-test-tools get-affected-actors --base origin/master --since <sha>
674
674
 
675
675
  # A release: everything after the last released commit
@@ -678,23 +678,31 @@ npx apify-test-tools get-affected-actors --since <sha>
678
678
 
679
679
  | Flag | Default | Meaning |
680
680
  | ------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
681
- | `--base` | | Only commits on `HEAD` that are not on this branch count |
682
- | `--since` | | Only commits after this one count (see below) |
681
+ | `--base` | | Only what `HEAD` changes compared to this branch counts, like `git diff <base>...HEAD` |
682
+ | `--since` | | Only changes after this commit count (see below) |
683
683
  | `--test-files-glob` | | Test files (glob from the repo root) that count as changes even when `.dockerignore` lists them, see [Change detection](#change-detection) |
684
684
  | `--actors` | all | Only report these Actors |
685
685
  | `--ignore` | none | Never report these Actors |
686
686
 
687
687
  Pass `--base`, `--since`, or both:
688
688
 
689
- - **`--base` only** inspects the whole branch. If the branch merged `--base` in and has no functional changes
690
- of its own, no Actor is reported as functional, since `--base` is already validated (and none as cosmetic
691
- either, if the branch has no changes of its own at all).
692
- - **`--base` and `--since`** inspects the branch after its last validated commit. If `--since` is not on the
693
- branch (force-push), or it is the head (a rerun), the whole branch is inspected instead.
689
+ - **`--base` only** inspects what the branch changes, the same files GitHub's "Files changed" tab shows: the diff
690
+ from where the branch forked from `--base`, or the last commit of `--base` it merged in. What it merged in from
691
+ `--base` is already validated there, so it doesn't count.
692
+ - **`--base` and `--since`** also inspects what changed after the branch's last validated commit, and reports only
693
+ the Actors that changed in both. An Actor in only one of them is already validated, by this branch or on `--base`.
694
+ When both changed an Actor, the changes can interact, so it is reported, but as functional only when both changes
695
+ are functional. A validated functional change followed by README edits is cosmetic, and so is a functional
696
+ change merged in from `--base` that meets only cosmetic changes of the branch. `--since` doesn't have to be on
697
+ the branch, so a rebase only re-checks the Actors that `--base` changed too. If `--since` is not in the local
698
+ history (a force-push), or it is `HEAD` (a rerun), it is ignored and the whole branch is checked.
694
699
  - **`--since` only** inspects everything after it up to `HEAD`. It must be an ancestor of `HEAD` and fails
695
- otherwise, exactly like [`--base-commit` of `release`](#--base-commit). If `HEAD` is `--since`, nothing is
700
+ otherwise, see [Releasing Actors](#releasing-actors). If `HEAD` is `--since`, nothing is
696
701
  reported.
697
702
 
703
+ `commits`, `changedFiles` and `changelog` describe the whole range, `--base...HEAD` or `--since..HEAD`: `--since`
704
+ together with `--base` only narrows the Actor lists.
705
+
698
706
  The output is a JSON document:
699
707
 
700
708
  ```json
@@ -711,25 +719,23 @@ The output is a JSON document:
711
719
 
712
720
  Each changed Actor is in exactly one of the lists. `functionallyChangedActors` have at least one functional change, so
713
721
  they need a new build and tests. `cosmeticallyChangedActors` only have cosmetic changes (see
714
- [Change detection](#change-detection)), so they need a new build only when released: `build-for-test` builds
715
- `functionallyChangedActors`, `release` builds both.
716
-
717
- `build-for-test` and `release` use the same detection internally.
722
+ [Change detection](#change-detection)), so they need a new build only when released: the PR workflow builds
723
+ `functionallyChangedActors`, the release workflow builds both.
718
724
 
719
725
  ### Building Actors (`build`)
720
726
 
721
727
  `build` builds exactly the Actors it is given on stdin, from the checked-out branch as it is on the remote, and
722
- prints the builds as the same JSON array `build-for-test` and `build-from-local` print. A detached HEAD is an
728
+ prints the builds as the same JSON array `build-from-local` prints. A detached HEAD is an
723
729
  error, since there is no branch to build from. It doesn't look at git history: which Actors to build is
724
730
  up to you, usually picked from the output of [`get-affected-actors`](#finding-affected-actors-get-affected-actors).
725
731
 
726
732
  ```bash
727
- # What build-for-test does: the Actors a branch changed functionally, built into the test version
733
+ # A PR: the Actors a branch changed functionally, built into the test version
728
734
  npx apify-test-tools get-affected-actors --base origin/master \
729
735
  | jq '{ actors: .functionallyChangedActors }' \
730
736
  | npx apify-test-tools build --version-number 0.99
731
737
 
732
- # What release builds: every Actor changed since the last release, into the version users run
738
+ # A release: every Actor changed since the last release, into the version users run
733
739
  npx apify-test-tools get-affected-actors --since <sha> \
734
740
  | jq '{ actors: (.functionallyChangedActors + .cosmeticallyChangedActors) }' \
735
741
  | npx apify-test-tools build --version-number default
@@ -751,39 +757,33 @@ Actions, give such a step `shell: bash` so the pipe also fails on its own (the d
751
757
  so building the default version moves its tag (usually `latest`) to the new build, and building a version
752
758
  without a tag leaves every tag where it is. Builds always use the Docker cache.
753
759
 
754
- `build-for-test` and `release` are shortcuts for the two pipelines above, with the flags they always had.
755
- `build-for-test` takes `--target-branch`, `--base-commit` and `--test-files-glob`, inspects and builds the
756
- checked-out branch, and builds into version `0.99`. `release` takes `--base-commit`, and announces the release on Slack after building, the same
757
- way `notify-release` does.
760
+ ### Releasing Actors
758
761
 
759
- ### Releasing Actors (`release`)
760
-
761
- `release` builds the `latest` (default) version of every Actor changed since the last release and
762
- posts release notes to Slack. It reads everything else from git: the branch from the checked-out
763
- `HEAD`, the commits and changed files from the range `<base-commit>..HEAD`, and the repository from
764
- the `origin` remote.
762
+ A release is three commands: find what changed since the last released commit, build those Actors into
763
+ their default version (the one users run), and announce it.
765
764
 
766
765
  ```bash
767
- npx apify-test-tools release --base-commit <sha> --release-slack-channel "#releases" --dry-run
768
- ```
766
+ npx apify-test-tools get-affected-actors --since <sha> > affected.json
769
767
 
770
- The announcement is also its own command, `notify-release`, which reads the output of `get-affected-actors` on
771
- stdin. It posts the changelog additions to `--release-slack-channel` and the commits and changed files to
772
- `--report-slack-channel`, and posts nothing when there are no new commits. It needs `SLACK_TOKEN_RELEASES_BOT`.
768
+ jq '{ actors: (.functionallyChangedActors + .cosmeticallyChangedActors) }' affected.json \
769
+ | npx apify-test-tools build --version-number default --dry-run
773
770
 
774
- ```bash
775
- npx apify-test-tools get-affected-actors --since <sha> \
776
- | npx apify-test-tools notify-release --release-slack-channel "#releases" --dry-run
771
+ npx apify-test-tools notify-release --release-slack-channel "#releases" --dry-run < affected.json
777
772
  ```
778
773
 
779
- #### `--base-commit`
774
+ `notify-release` reads the output of `get-affected-actors` on stdin. It posts the changelog additions to
775
+ `--release-slack-channel` and the commits and changed files to `--report-slack-channel`, and posts nothing when
776
+ there are no new commits. It names the release after the `origin` remote (or `--repo-url`) and the author of the
777
+ newest commit, and needs `SLACK_TOKEN_RELEASES_BOT`.
778
+
779
+ #### The last released commit (`--since`)
780
780
 
781
- The last commit that is **already released**. Everything after it, up to `HEAD`, is released. It is
782
- required: git alone can't tell which commits a push brought, and guessing wrong silently leaves Actors
783
- on old code.
781
+ The last commit that is **already released**. Everything after it, up to `HEAD`, is released. Git alone
782
+ can't tell which commits a push brought, and guessing wrong silently leaves Actors on old code, so it has
783
+ to be passed.
784
784
 
785
- The changed files come from diffing `<base-commit>` and `HEAD` directly, so this works for every
786
- merge strategy as long as the base commit is the branch tip from **before** the push:
785
+ The changed files come from diffing `--since` and `HEAD` directly, so this works for every merge strategy as
786
+ long as `--since` is the branch tip from **before** the push:
787
787
 
788
788
  | Merge strategy | What lands on the branch | What to pass |
789
789
  | ------------------------------ | --------------------------------- | ---------------------------------------------------------------------- |
@@ -793,26 +793,25 @@ merge strategy as long as the base commit is the branch tip from **before** the
793
793
 
794
794
  On GitHub, the push's "before" commit is `${{ github.event.before }}`, which the reusable workflow
795
795
  passes for you. On other CIs use the equivalent, e.g. `$CI_COMMIT_BEFORE_SHA` on GitLab. The checkout
796
- needs the full history (`fetch-depth: 0` in `actions/checkout`) so the base commit is available locally.
796
+ needs the full history (`fetch-depth: 0` in `actions/checkout`) so the commit is available locally.
797
797
 
798
- `release` fails instead of guessing when:
798
+ `get-affected-actors --since` without `--base` fails instead of guessing when:
799
799
 
800
- - the base commit is all zeros (GitHub sends this for a push that created the branch)
801
- - the base commit isn't in the local history (shallow checkout) or isn't an ancestor of `HEAD`
800
+ - the commit is all zeros (GitHub sends this for a push that created the branch)
801
+ - the commit isn't in the local history (shallow checkout) or isn't an ancestor of `HEAD`
802
802
  (the branch was force-pushed)
803
803
 
804
- In those cases, rerun `release` with a `--base-commit` you pick yourself: an ancestor of `HEAD` from
805
- before the changes you want to release (for a shallow checkout, fetch the full history instead).
806
- `--actors` only narrows which of the changed Actors get released; it never forces a build, so on its
807
- own it doesn't get past these errors.
808
- If `HEAD` is the base commit, there is nothing to release and the command exits successfully.
804
+ In those cases, rerun it with a `--since` you pick yourself: an ancestor of `HEAD` from before the changes
805
+ you want to release (for a shallow checkout, fetch the full history instead). `--actors` only narrows which
806
+ of the changed Actors are reported; it never forces a build, so on its own it doesn't get past these errors.
807
+ If `HEAD` is `--since`, nothing is reported, so nothing is built or announced.
809
808
 
810
809
  A failed release isn't retried by the next push: that push's base commit is the failed one's head, so
811
810
  its changes are skipped. Re-run the failed workflow run, or release the Actors manually.
812
811
 
813
812
  #### Repository check
814
813
 
815
- `release` and `build` point each Actor's version at the `origin` remote. Because a build overwrites the
814
+ `build` points each Actor's version at the `origin` remote. Because a build overwrites the
816
815
  version's Git URL, building from a fork or a mirror would repoint the Actor. So, before building, the
817
816
  remote is compared with the Git URL of the Actor's default version (the one its default build tag
818
817
  points to), and the command fails if they differ or if the default version isn't built from a Git