apify-test-tools 0.10.2-beta.2 → 0.10.2-beta.21

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 (275) hide show
  1. package/.gitattributes +1 -0
  2. package/.github/actionlint.yaml +11 -0
  3. package/.github/actions/checkout-restore-dependencies/action.yaml +58 -6
  4. package/.github/cli/apify-test-tools.mjs +135 -142
  5. package/.github/scripts/mask-config-secrets.sh +17 -0
  6. package/.github/scripts/run-with-apify-tokens.mjs +63 -103
  7. package/.github/workflows/_check_code.yaml +5 -21
  8. package/.github/workflows/_move_major_tag.yaml +2 -2
  9. package/.github/workflows/public_platform-tests-claude-investigate-and-fix.yaml +89 -8
  10. package/.github/workflows/public_platform-tests.yaml +68 -30
  11. package/.github/workflows/public_pr-build-test.yaml +77 -38
  12. package/.github/workflows/public_push-build-latest.yaml +49 -11
  13. package/.github/workflows/public_review.yaml +5 -4
  14. package/.github/workflows/public_stale-issues.yaml +51 -0
  15. package/.husky/pre-commit +4 -4
  16. package/.prettierignore +2 -1
  17. package/CHANGELOG.md +23 -0
  18. package/CONTRIBUTING.md +117 -17
  19. package/README.md +221 -595
  20. package/bin/actor-ids.ts +41 -0
  21. package/bin/affected-actors.ts +211 -0
  22. package/bin/build-from-local.ts +19 -1
  23. package/bin/build.ts +105 -39
  24. package/bin/diff-changes.ts +69 -36
  25. package/bin/diff-json-schema.ts +5 -6
  26. package/bin/git.ts +73 -175
  27. package/bin/main.ts +142 -189
  28. package/bin/notify.ts +198 -0
  29. package/bin/run-tests.ts +182 -0
  30. package/bin/slack.ts +16 -76
  31. package/bin/stdin-input.ts +156 -0
  32. package/bin/test-files-glob.ts +126 -0
  33. package/bin/test-report.ts +141 -140
  34. package/bin/types.ts +4 -7
  35. package/bin/utils/config/load-config.ts +20 -2
  36. package/bin/utils/config/parser.ts +40 -8
  37. package/bin/utils/config/structures/grouped.ts +2 -2
  38. package/bin/utils/config/structures/legacy.ts +1 -1
  39. package/dist/bin/actor-ids.d.ts +15 -0
  40. package/dist/bin/actor-ids.d.ts.map +1 -0
  41. package/dist/bin/actor-ids.js +30 -0
  42. package/dist/bin/actor-ids.js.map +1 -0
  43. package/dist/bin/affected-actors.d.ts +55 -0
  44. package/dist/bin/affected-actors.d.ts.map +1 -0
  45. package/dist/bin/affected-actors.js +142 -0
  46. package/dist/bin/affected-actors.js.map +1 -0
  47. package/dist/bin/build-from-local.d.ts +2 -1
  48. package/dist/bin/build-from-local.d.ts.map +1 -1
  49. package/dist/bin/build-from-local.js +6 -2
  50. package/dist/bin/build-from-local.js.map +1 -1
  51. package/dist/bin/build.d.ts +18 -5
  52. package/dist/bin/build.d.ts.map +1 -1
  53. package/dist/bin/build.js +74 -24
  54. package/dist/bin/build.js.map +1 -1
  55. package/dist/bin/diff-changes.d.ts +21 -5
  56. package/dist/bin/diff-changes.d.ts.map +1 -1
  57. package/dist/bin/diff-changes.js +41 -28
  58. package/dist/bin/diff-changes.js.map +1 -1
  59. package/dist/bin/diff-json-schema.d.ts +2 -2
  60. package/dist/bin/diff-json-schema.d.ts.map +1 -1
  61. package/dist/bin/diff-json-schema.js +1 -4
  62. package/dist/bin/diff-json-schema.js.map +1 -1
  63. package/dist/bin/git.d.ts +26 -34
  64. package/dist/bin/git.d.ts.map +1 -1
  65. package/dist/bin/git.js +60 -143
  66. package/dist/bin/git.js.map +1 -1
  67. package/dist/bin/main.js +126 -140
  68. package/dist/bin/main.js.map +1 -1
  69. package/dist/bin/notify.d.ts +35 -0
  70. package/dist/bin/notify.d.ts.map +1 -0
  71. package/dist/bin/notify.js +131 -0
  72. package/dist/bin/notify.js.map +1 -0
  73. package/dist/bin/run-tests.d.ts +21 -0
  74. package/dist/bin/run-tests.d.ts.map +1 -0
  75. package/dist/bin/run-tests.js +149 -0
  76. package/dist/bin/run-tests.js.map +1 -0
  77. package/dist/bin/slack.d.ts +2 -14
  78. package/dist/bin/slack.d.ts.map +1 -1
  79. package/dist/bin/slack.js +17 -46
  80. package/dist/bin/slack.js.map +1 -1
  81. package/dist/bin/stdin-input.d.ts +79 -0
  82. package/dist/bin/stdin-input.d.ts.map +1 -0
  83. package/dist/bin/stdin-input.js +124 -0
  84. package/dist/bin/stdin-input.js.map +1 -0
  85. package/dist/bin/test-files-glob.d.ts +18 -0
  86. package/dist/bin/test-files-glob.d.ts.map +1 -0
  87. package/dist/bin/test-files-glob.js +108 -0
  88. package/dist/bin/test-files-glob.js.map +1 -0
  89. package/dist/bin/test-report.d.ts +69 -8
  90. package/dist/bin/test-report.d.ts.map +1 -1
  91. package/dist/bin/test-report.js +76 -67
  92. package/dist/bin/test-report.js.map +1 -1
  93. package/dist/bin/types.d.ts +4 -7
  94. package/dist/bin/types.d.ts.map +1 -1
  95. package/dist/bin/utils/config/load-config.d.ts +8 -0
  96. package/dist/bin/utils/config/load-config.d.ts.map +1 -1
  97. package/dist/bin/utils/config/load-config.js +14 -1
  98. package/dist/bin/utils/config/load-config.js.map +1 -1
  99. package/dist/bin/utils/config/parser.d.ts +15 -2
  100. package/dist/bin/utils/config/parser.d.ts.map +1 -1
  101. package/dist/bin/utils/config/parser.js +29 -8
  102. package/dist/bin/utils/config/parser.js.map +1 -1
  103. package/dist/bin/utils/config/structures/grouped.js +2 -2
  104. package/dist/bin/utils/config/structures/grouped.js.map +1 -1
  105. package/dist/bin/utils/config/structures/legacy.js +1 -1
  106. package/dist/bin/utils/config/structures/legacy.js.map +1 -1
  107. package/dist/lib/extend-expect.d.ts.map +1 -1
  108. package/dist/lib/extend-expect.js +37 -218
  109. package/dist/lib/extend-expect.js.map +1 -1
  110. package/dist/lib/lib.d.ts +1 -5
  111. package/dist/lib/lib.d.ts.map +1 -1
  112. package/dist/lib/lib.js +19 -31
  113. package/dist/lib/lib.js.map +1 -1
  114. package/dist/lib/run-checks.d.ts +14 -0
  115. package/dist/lib/run-checks.d.ts.map +1 -0
  116. package/dist/lib/run-checks.js +82 -0
  117. package/dist/lib/run-checks.js.map +1 -0
  118. package/dist/lib/run-test-result.d.ts +3 -6
  119. package/dist/lib/run-test-result.d.ts.map +1 -1
  120. package/dist/lib/run-test-result.js +41 -54
  121. package/dist/lib/run-test-result.js.map +1 -1
  122. package/dist/test/bundle/cli-bundle.test.js +76 -56
  123. package/dist/test/bundle/cli-bundle.test.js.map +1 -1
  124. package/dist/test/bundle/token-wrapper.test.d.ts +2 -0
  125. package/dist/test/bundle/token-wrapper.test.d.ts.map +1 -0
  126. package/dist/test/bundle/token-wrapper.test.js +80 -0
  127. package/dist/test/bundle/token-wrapper.test.js.map +1 -0
  128. package/dist/test/e2e/cli-bundle.e2e.test.js +33 -68
  129. package/dist/test/e2e/cli-bundle.e2e.test.js.map +1 -1
  130. package/dist/test/e2e/git-build-release.e2e.test.d.ts +2 -0
  131. package/dist/test/e2e/git-build-release.e2e.test.d.ts.map +1 -0
  132. package/dist/test/e2e/git-build-release.e2e.test.js +87 -0
  133. package/dist/test/e2e/git-build-release.e2e.test.js.map +1 -0
  134. package/dist/test/e2e/helpers.d.ts +37 -0
  135. package/dist/test/e2e/helpers.d.ts.map +1 -0
  136. package/dist/test/e2e/helpers.js +57 -0
  137. package/dist/test/e2e/helpers.js.map +1 -0
  138. package/dist/test/unit/bin/actor-filtering.test.js +7 -0
  139. package/dist/test/unit/bin/actor-filtering.test.js.map +1 -1
  140. package/dist/test/unit/bin/actor-ids.test.d.ts +2 -0
  141. package/dist/test/unit/bin/actor-ids.test.d.ts.map +1 -0
  142. package/dist/test/unit/bin/actor-ids.test.js +40 -0
  143. package/dist/test/unit/bin/actor-ids.test.js.map +1 -0
  144. package/dist/test/unit/bin/affected-actors-cli.test.d.ts +2 -0
  145. package/dist/test/unit/bin/affected-actors-cli.test.d.ts.map +1 -0
  146. package/dist/test/unit/bin/affected-actors-cli.test.js +224 -0
  147. package/dist/test/unit/bin/affected-actors-cli.test.js.map +1 -0
  148. package/dist/test/unit/bin/affected-actors.test.d.ts +2 -0
  149. package/dist/test/unit/bin/affected-actors.test.d.ts.map +1 -0
  150. package/dist/test/unit/bin/affected-actors.test.js +153 -0
  151. package/dist/test/unit/bin/affected-actors.test.js.map +1 -0
  152. package/dist/test/unit/bin/build-cli.test.d.ts +2 -0
  153. package/dist/test/unit/bin/build-cli.test.d.ts.map +1 -0
  154. package/dist/test/unit/bin/build-cli.test.js +49 -0
  155. package/dist/test/unit/bin/build-cli.test.js.map +1 -0
  156. package/dist/test/unit/bin/build-from-local.test.js +12 -0
  157. package/dist/test/unit/bin/build-from-local.test.js.map +1 -1
  158. package/dist/test/unit/bin/build.test.js +116 -6
  159. package/dist/test/unit/bin/build.test.js.map +1 -1
  160. package/dist/test/unit/bin/compiled-cli.d.ts +6 -0
  161. package/dist/test/unit/bin/compiled-cli.d.ts.map +1 -0
  162. package/dist/test/unit/bin/compiled-cli.js +23 -0
  163. package/dist/test/unit/bin/compiled-cli.js.map +1 -0
  164. package/dist/test/unit/bin/diff-changes.test.js +168 -114
  165. package/dist/test/unit/bin/diff-changes.test.js.map +1 -1
  166. package/dist/test/unit/bin/diff.test.js +25 -28
  167. package/dist/test/unit/bin/diff.test.js.map +1 -1
  168. package/dist/test/unit/bin/git.test.js +67 -288
  169. package/dist/test/unit/bin/git.test.js.map +1 -1
  170. package/dist/test/unit/bin/notify.test.d.ts +2 -0
  171. package/dist/test/unit/bin/notify.test.d.ts.map +1 -0
  172. package/dist/test/unit/bin/notify.test.js +222 -0
  173. package/dist/test/unit/bin/notify.test.js.map +1 -0
  174. package/dist/test/unit/bin/stdin-input.test.d.ts +2 -0
  175. package/dist/test/unit/bin/stdin-input.test.d.ts.map +1 -0
  176. package/dist/test/unit/bin/stdin-input.test.js +92 -0
  177. package/dist/test/unit/bin/stdin-input.test.js.map +1 -0
  178. package/dist/test/unit/bin/test-cli.test.d.ts +2 -0
  179. package/dist/test/unit/bin/test-cli.test.d.ts.map +1 -0
  180. package/dist/test/unit/bin/test-cli.test.js +165 -0
  181. package/dist/test/unit/bin/test-cli.test.js.map +1 -0
  182. package/dist/test/unit/bin/test-files-glob.test.d.ts +2 -0
  183. package/dist/test/unit/bin/test-files-glob.test.d.ts.map +1 -0
  184. package/dist/test/unit/bin/test-files-glob.test.js +102 -0
  185. package/dist/test/unit/bin/test-files-glob.test.js.map +1 -0
  186. package/dist/test/unit/bin/test-report.test.d.ts +2 -0
  187. package/dist/test/unit/bin/test-report.test.d.ts.map +1 -0
  188. package/dist/test/unit/bin/test-report.test.js +100 -0
  189. package/dist/test/unit/bin/test-report.test.js.map +1 -0
  190. package/dist/test/unit/bin/utils/config/load-config.test.js +19 -1
  191. package/dist/test/unit/bin/utils/config/load-config.test.js.map +1 -1
  192. package/dist/test/unit/bin/utils/config/parser.test.js +36 -4
  193. package/dist/test/unit/bin/utils/config/parser.test.js.map +1 -1
  194. package/dist/test/unit/bin/utils/config/structures/grouped.test.js +6 -0
  195. package/dist/test/unit/bin/utils/config/structures/grouped.test.js.map +1 -1
  196. package/dist/test/unit/bin/utils/config/structures/legacy.test.js +1 -0
  197. package/dist/test/unit/bin/utils/config/structures/legacy.test.js.map +1 -1
  198. package/dist/test/unit/github-scripts/mask-config-secrets.test.d.ts +2 -0
  199. package/dist/test/unit/github-scripts/mask-config-secrets.test.d.ts.map +1 -0
  200. package/dist/test/unit/github-scripts/mask-config-secrets.test.js +50 -0
  201. package/dist/test/unit/github-scripts/mask-config-secrets.test.js.map +1 -0
  202. package/dist/test/unit/github-scripts/run-with-apify-tokens.test.d.ts +2 -0
  203. package/dist/test/unit/github-scripts/run-with-apify-tokens.test.d.ts.map +1 -0
  204. package/dist/test/unit/github-scripts/run-with-apify-tokens.test.js +102 -0
  205. package/dist/test/unit/github-scripts/run-with-apify-tokens.test.js.map +1 -0
  206. package/dist/test/unit/run-checks.test.d.ts +2 -0
  207. package/dist/test/unit/run-checks.test.d.ts.map +1 -0
  208. package/dist/test/unit/run-checks.test.js +62 -0
  209. package/dist/test/unit/run-checks.test.js.map +1 -0
  210. package/dist/test/unit/run-test-result.test.d.ts +2 -0
  211. package/dist/test/unit/run-test-result.test.d.ts.map +1 -0
  212. package/dist/test/unit/run-test-result.test.js +34 -0
  213. package/dist/test/unit/run-test-result.test.js.map +1 -0
  214. package/dist/test/unit/should-built-and-test.test.js +41 -38
  215. package/dist/test/unit/should-built-and-test.test.js.map +1 -1
  216. package/dist/tsconfig.tsbuildinfo +1 -1
  217. package/dist/workflow-scripts-src/run-with-apify-tokens.d.ts +3 -0
  218. package/dist/workflow-scripts-src/run-with-apify-tokens.d.ts.map +1 -0
  219. package/dist/workflow-scripts-src/run-with-apify-tokens.js +100 -0
  220. package/dist/workflow-scripts-src/run-with-apify-tokens.js.map +1 -0
  221. package/docs/cli.md +473 -0
  222. package/docs/lib.md +276 -0
  223. package/docs/workflows.md +455 -0
  224. package/eslint.config.mjs +10 -1
  225. package/lib/extend-expect.ts +48 -258
  226. package/lib/lib.ts +25 -34
  227. package/lib/run-checks.ts +101 -0
  228. package/lib/run-test-result.ts +45 -55
  229. package/package.json +4 -2
  230. package/platform-tests-investigate-and-fix/skills/assess-impact/SKILL.md +42 -0
  231. package/platform-tests-investigate-and-fix/skills/measure-flakiness/SKILL.md +4 -2
  232. package/test/bundle/cli-bundle.test.ts +97 -67
  233. package/test/bundle/token-wrapper.test.ts +110 -0
  234. package/test/e2e/cli-bundle.e2e.test.ts +60 -93
  235. package/test/e2e/git-build-release.e2e.test.ts +113 -0
  236. package/test/e2e/helpers.ts +82 -0
  237. package/test/unit/bin/actor-filtering.test.ts +8 -0
  238. package/test/unit/bin/actor-ids.test.ts +47 -0
  239. package/test/unit/bin/affected-actors-cli.test.ts +271 -0
  240. package/test/unit/bin/affected-actors.test.ts +221 -0
  241. package/test/unit/bin/build-cli.test.ts +61 -0
  242. package/test/unit/bin/build-from-local.test.ts +16 -0
  243. package/test/unit/bin/build.test.ts +149 -5
  244. package/test/unit/bin/compiled-cli.ts +23 -0
  245. package/test/unit/bin/diff-changes.test.ts +181 -114
  246. package/test/unit/bin/diff.test.ts +25 -28
  247. package/test/unit/bin/git.test.ts +76 -361
  248. package/test/unit/bin/notify.test.ts +299 -0
  249. package/test/unit/bin/stdin-input.test.ts +120 -0
  250. package/test/unit/bin/test-cli.test.ts +207 -0
  251. package/test/unit/bin/test-files-glob.test.ts +118 -0
  252. package/test/unit/bin/test-report.test.ts +118 -0
  253. package/test/unit/bin/utils/config/load-config.test.ts +26 -1
  254. package/test/unit/bin/utils/config/parser.test.ts +46 -5
  255. package/test/unit/bin/utils/config/structures/grouped.test.ts +12 -0
  256. package/test/unit/bin/utils/config/structures/legacy.test.ts +1 -0
  257. package/test/unit/github-scripts/mask-config-secrets.test.ts +61 -0
  258. package/test/unit/github-scripts/run-with-apify-tokens.test.ts +115 -0
  259. package/test/unit/run-checks.test.ts +76 -0
  260. package/test/unit/run-test-result.test.ts +44 -0
  261. package/test/unit/should-built-and-test.test.ts +46 -39
  262. package/tsconfig.json +1 -1
  263. package/vitest.config.ts +9 -0
  264. package/workflow-scripts-src/run-with-apify-tokens.ts +112 -0
  265. package/.github/scripts/check-major-tag-refs.mjs +0 -72
  266. package/dist/test/unit/bin/logging.test.d.ts +0 -2
  267. package/dist/test/unit/bin/logging.test.d.ts.map +0 -1
  268. package/dist/test/unit/bin/logging.test.js +0 -43
  269. package/dist/test/unit/bin/logging.test.js.map +0 -1
  270. package/dist/test/unit/bin/slack.test.d.ts +0 -2
  271. package/dist/test/unit/bin/slack.test.d.ts.map +0 -1
  272. package/dist/test/unit/bin/slack.test.js +0 -54
  273. package/dist/test/unit/bin/slack.test.js.map +0 -1
  274. package/test/unit/bin/logging.test.ts +0 -52
  275. package/test/unit/bin/slack.test.ts +0 -65
@@ -1,7 +1,7 @@
1
- import picomatch from 'picomatch';
2
1
  import { isCosmeticOnlyJsonSchemaChange } from './diff-json-schema.js';
3
2
  import { loadDockerIgnore } from './dockerignore.js';
4
3
  import { logger } from './logger.js';
4
+ import { createTestFilesMatcher } from './test-files-glob.js';
5
5
  import { RelativeFile } from './utils/path/repo-relative.js';
6
6
  const IGNORED_TOP_LEVEL_FILES = [
7
7
  '.vscode/',
@@ -24,13 +24,15 @@ const isIgnoredTopLevelFile = (filePath, contextPath) => {
24
24
  * not one per actor, so it applies to every actor regardless of context/folder.
25
25
  * 2. Context matching (actorConfig.contextPaths) → outside-context if no match
26
26
  * 3. Hardcoded ignore list, checked against the path hoisted relative to the matched context entry → ignored
27
- * 4. .dockerignore filtering (patterns relative to dockerContextDir), skipped for the actor's own `.actor/`
28
- * dir and for test files → ignored if matched
29
- * 5. README.md by filename → cosmetic if inside the actor's own folder, otherwise ignored
30
- * 6. .json inside the actor's own `.actor/` dir with only cosmetic schema diffs → cosmetic (semantically verified)
31
- * 7. Everything else → functional
27
+ * 4. Platform test files (`platformTestsGlob`) → test, even when .dockerignore lists them. A test change needs the
28
+ * tests to run, but no release.
29
+ * 5. .dockerignore filtering (patterns relative to dockerContextDir), skipped for the actor's own `.actor/`
30
+ * dir → ignored if matched
31
+ * 6. README.md by filename → cosmetic if inside the actor's own folder, otherwise ignored
32
+ * 7. .json inside the actor's own `.actor/` dir with only cosmetic schema diffs → cosmetic (semantically verified)
33
+ * 8. Everything else → functional
32
34
  */
33
- const classifyFileChange = async (changedFile, actorConfig, commits, dockerIgnoreMatcher, isTestFile) => {
35
+ const classifyFileChange = async (changedFile, actorConfig, range, dockerIgnoreMatcher, isTestFile) => {
34
36
  const lowercaseFilePath = changedFile.path.toLowerCase();
35
37
  // TODO: hardcodes that there's a single repo-wide changelog belonging to every actor. Should instead
36
38
  // be derived from parsing actor.json (readme, changelog, schema paths), see
@@ -45,12 +47,15 @@ const classifyFileChange = async (changedFile, actorConfig, commits, dockerIgnor
45
47
  if (isIgnoredTopLevelFile(changedFile, matchedContext)) {
46
48
  return { impact: 'ignored' };
47
49
  }
50
+ // Test files are often in .dockerignore, but a change to them must still run the tests
51
+ if (isTestFile(changedFile.path)) {
52
+ return { impact: 'test' };
53
+ }
48
54
  const isUnderActorDotDir = actorConfig.actorJson.file.parent.contains(changedFile);
49
55
  // .actor/ can legitimately be listed in .dockerignore (the Apify platform evaluates it before
50
56
  // the Docker build, so excluding it from the build context is a valid caching optimization) —
51
57
  // that shouldn't cause changes to .actor/ itself to be ignored here.
52
- // Test files are often in .dockerignore too, but a change to them must still build and test.
53
- if (!isUnderActorDotDir && !isTestFile(changedFile.path) && dockerIgnoreMatcher(changedFile.path)) {
58
+ if (!isUnderActorDotDir && dockerIgnoreMatcher(changedFile.path)) {
54
59
  return { impact: 'ignored' };
55
60
  }
56
61
  const isInActorFolder = changedFile.isWithin(actorConfig.folder);
@@ -58,7 +63,7 @@ const classifyFileChange = async (changedFile, actorConfig, commits, dockerIgnor
58
63
  return isInActorFolder ? { impact: 'cosmetic', semanticallyVerified: false } : { impact: 'ignored' };
59
64
  }
60
65
  if (lowercaseFilePath.endsWith('.json') && isUnderActorDotDir) {
61
- const isCosmetic = await isCosmeticOnlyJsonSchemaChange(commits, changedFile.path);
66
+ const isCosmetic = await isCosmeticOnlyJsonSchemaChange(range, changedFile.path);
62
67
  if (isCosmetic)
63
68
  return { impact: 'cosmetic', semanticallyVerified: true };
64
69
  }
@@ -118,10 +123,11 @@ const logChangeGroups = (groups) => {
118
123
  }
119
124
  }
120
125
  };
121
- export const getChangedActors = async ({ filepathsChanged, actorConfigs, isLatest = false, commits, testFilesGlob, }) => {
126
+ /** Finds the Actors the changed files belong to, split by the most impactful change each Actor has. */
127
+ export const getChangedActors = async ({ filepathsChanged, actorConfigs, range, platformTestsGlob, }) => {
122
128
  const actorsChangedMap = new Map();
123
129
  const testFilesInContext = new Set();
124
- const isTestFile = testFilesGlob ? picomatch(testFilesGlob, { nocase: true, dot: true }) : () => false;
130
+ const isTestFile = createTestFilesMatcher(platformTestsGlob);
125
131
  for (const actorConfig of actorConfigs) {
126
132
  const dockerIgnoreMatcher = loadDockerIgnore(actorConfig.dockerContextDir);
127
133
  for (const originalFilePath of filepathsChanged) {
@@ -129,36 +135,43 @@ export const getChangedActors = async ({ filepathsChanged, actorConfigs, isLates
129
135
  if (isExcludedBySibling(filePath, actorConfig, actorConfigs)) {
130
136
  continue;
131
137
  }
132
- const change = await classifyFileChange(filePath, actorConfig, commits, dockerIgnoreMatcher, isTestFile);
138
+ const change = await classifyFileChange(filePath, actorConfig, range, dockerIgnoreMatcher, isTestFile);
133
139
  if (change.impact !== 'outside-context' && isTestFile(originalFilePath)) {
134
140
  testFilesInContext.add(originalFilePath);
135
141
  }
136
142
  if (change.impact === 'ignored' || change.impact === 'outside-context')
137
143
  continue;
138
- if (change.impact === 'cosmetic' && !isLatest)
139
- continue;
140
- const entry = actorsChangedMap.get(actorConfig.folder.path) ?? { actorConfig, files: [] };
144
+ const entry = actorsChangedMap.get(actorConfig.folder.path) ?? {
145
+ actorConfig,
146
+ files: [],
147
+ hasFunctionalChange: false,
148
+ hasCosmeticChange: false,
149
+ hasTestChange: false,
150
+ };
141
151
  entry.files.push(originalFilePath);
152
+ entry.hasFunctionalChange ||= change.impact === 'functional';
153
+ entry.hasCosmeticChange ||= change.impact === 'cosmetic';
154
+ entry.hasTestChange ||= change.impact === 'test';
142
155
  actorsChangedMap.set(actorConfig.folder.path, entry);
143
156
  }
144
157
  }
145
- const actorsChanged = Array.from(actorsChangedMap.values()).map((entry) => entry.actorConfig);
146
158
  // Log changes grouped by actor set, so changes shared across actors are logged once
147
159
  // instead of being repeated per actor.
148
- const fileToActors = buildFileToActorsMap(actorsChangedMap);
149
- const groups = groupFilesByActorSet(fileToActors);
150
- logChangeGroups(groups);
160
+ logChangeGroups(groupFilesByActorSet(buildFileToActorsMap(actorsChangedMap)));
151
161
  for (const testFile of filepathsChanged.filter((filePath) => isTestFile(filePath) && !testFilesInContext.has(filePath))) {
152
162
  logger.warn(`[DIFF]: Test file ${testFile} is outside every Actor's context, so changing only it builds and tests nothing. ` +
153
163
  `Add its folder to "overrideActorContext" of the Actors it tests.`);
154
164
  }
155
- if (actorsChanged.length > 0) {
156
- const actors = actorsChanged.map((config) => config.actorFullName);
157
- logger.info(`[DIFF]: Actors to be built and tested: ${actors.join(', ')}`);
158
- }
159
- else {
160
- logger.info(`[DIFF]: No relevant files changed, skipping builds and tests`);
161
- }
162
- return actorsChanged;
165
+ const entries = Array.from(actorsChangedMap.values());
166
+ const functional = entries.filter((entry) => entry.hasFunctionalChange).map((entry) => entry.actorConfig);
167
+ const cosmetic = entries
168
+ .filter((entry) => !entry.hasFunctionalChange && entry.hasCosmeticChange)
169
+ .map((entry) => entry.actorConfig);
170
+ const test = entries.filter((entry) => entry.hasTestChange).map((entry) => entry.actorConfig);
171
+ const names = (configs) => configs.map((config) => config.actorFullName).join(', ') || 'none';
172
+ logger.info(`[DIFF]: Actors with functional changes: ${names(functional)}`);
173
+ logger.info(`[DIFF]: Actors with only cosmetic changes: ${names(cosmetic)}`);
174
+ logger.info(`[DIFF]: Actors with platform test changes: ${names(test)}`);
175
+ return { functional, cosmetic, test };
163
176
  };
164
177
  //# sourceMappingURL=diff-changes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"diff-changes.js","sourceRoot":"","sources":["../../bin/diff-changes.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAA4B,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAoB,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAW/E,MAAM,uBAAuB,GAAG;IAC5B,UAAU;IACV,YAAY;IACZ,SAAS;IACT,WAAW;IACX,mBAAmB;IACnB,aAAa;IACb,eAAe;CAClB,CAAC;AAEF,MAAM,qBAAqB,GAAG,CAAC,QAAsB,EAAE,WAAwB,EAAW,EAAE;IACxF,MAAM,iBAAiB,GAAG,WAAW,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;IAClF,OAAO,uBAAuB,CAAC,IAAI,CAAC,CA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AAC,WAAW,CAAC,CAAC;IACvC,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAE9F,MAAM,KAAK,GAAG,CAAC,OAAsB,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC;IAC7G,MAAM,CAAC,IAAI,CAAC,2CAA2C,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IAC5E,MAAM,CAAC,IAAI,CAAC,8CAA8C,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC7E,MAAM,CAAC,IAAI,CAAC,8CAA8C,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEzE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAC1C,CAAC,CAAC"}
@@ -1,7 +1,7 @@
1
- import type { Commit } from './types.js';
1
+ import type { GitRange } from './types.js';
2
2
  /**
3
3
  * Returns true if the two JSON strings differ only in cosmetic fields
4
4
  * (title, description, example, enumTitles, sectionCaption, sectionDescription).
5
5
  */
6
- export declare const isCosmeticOnlyJsonSchemaChange: (commits: Commit[], changedFilepath: string) => Promise<boolean>;
6
+ export declare const isCosmeticOnlyJsonSchemaChange: ({ fromRef: oldRef, toRef: newRef }: GitRange, changedFilepath: string) => Promise<boolean>;
7
7
  //# sourceMappingURL=diff-json-schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"diff-json-schema.d.ts","sourceRoot":"","sources":["../../bin/diff-json-schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AA0BzC;;;GAGG;AACH,eAAO,MAAM,8BAA8B,GAAU,SAAS,MAAM,EAAE,EAAE,iBAAiB,MAAM,KAAG,OAAO,CAAC,OAAO,CAoBhH,CAAC"}
1
+ {"version":3,"file":"diff-json-schema.d.ts","sourceRoot":"","sources":["../../bin/diff-json-schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AA0B3C;;;GAGG;AACH,eAAO,MAAM,8BAA8B,GACvC,oCAAoC,QAAQ,EAC5C,iBAAiB,MAAM,KACxB,OAAO,CAAC,OAAO,CAgBjB,CAAC"}
@@ -25,10 +25,7 @@ const isCosmeticObjectChange = (oldVal, newVal, currentKey) => {
25
25
  * Returns true if the two JSON strings differ only in cosmetic fields
26
26
  * (title, description, example, enumTitles, sectionCaption, sectionDescription).
27
27
  */
28
- export const isCosmeticOnlyJsonSchemaChange = async (commits, changedFilepath) => {
29
- // TODO: validate this is the right commit range
30
- const oldRef = `${commits[0].sha}~`;
31
- const newRef = commits[commits.length - 1].sha;
28
+ export const isCosmeticOnlyJsonSchemaChange = async ({ fromRef: oldRef, toRef: newRef }, changedFilepath) => {
32
29
  const [oldJson, newJson] = await Promise.all([
33
30
  runGitCommand(['show', `${oldRef}:${changedFilepath}`])
34
31
  .then(JSON.parse)
@@ -1 +1 @@
1
- {"version":3,"file":"diff-json-schema.js","sourceRoot":"","sources":["../../bin/diff-json-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,yBAAyB,GAAG,IAAI,GAAG,CAAC;IACtC,OAAO;IACP,aAAa;IACb,SAAS;IACT,YAAY;IACZ,gBAAgB;IAChB,oBAAoB;CACvB,CAAC,CAAC;AAEH,MAAM,aAAa,GAAG,CAAC,GAAY,EAAkC,EAAE,CACnE,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI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AAkC,eAAe,YAAY,MAAM,QAAQ,MAAM,0EAA0E,CAC9J,CAAC;QACF,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,OAAO,sBAAsB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AACpD,CAAC,CAAC"}
package/dist/bin/git.d.ts CHANGED
@@ -1,37 +1,33 @@
1
- import type { Commit, Config } from './types.js';
1
+ import type { Commit } from './types.js';
2
2
  export declare const GIT_FORMAT_SEPARATOR = "\u00BB\u00A6\u00AB";
3
3
  /**
4
- * Gets the list of changed files between the given commits (inclusive).
4
+ * Files that differ between two commits, i.e. changed by the commits in the range (fromRef, toRef]. fromRef's own
5
+ * changes are not included: to include them, pass its parent, `${sha}~` (as getChangedFiles does).
6
+ * Diffing the endpoints, rather than walking a commit list, is what keeps merges right: the oldest commit of a
7
+ * merged branch can predate fromRef, and its changes are already in fromRef.
5
8
  */
6
- export declare const getChangedFiles: (commits: Commit[]) => Promise<string[]>;
9
+ export declare const getChangedFilesBetween: (fromRef: string, toRef: string) => Promise<string[]>;
7
10
  /**
8
- * Returns true if the branch contains a merge commit whose parent is reachable from targetBranch
9
- * (i.e. a genuine "merge from target" commit, not a merge of some unrelated branch).
10
- * Uses the full targetBranch..sourceBranch range, ignoring baseCommit.
11
+ * The commit `git diff base...head` compares against: where `head` forked from `base`, or the last commit of `base`
12
+ * that `head` merged in. The diff from it holds only what `head` itself changed, like GitHub's "Files changed" tab.
13
+ * With criss-cross merges there are several such commits and git picks one.
11
14
  */
12
- export declare const hasMergeFromTarget: (sourceBranch: string, targetBranch: string) => Promise<boolean>;
15
+ export declare const getMergeBase: (base: string, head: string) => Promise<string>;
16
+ /** Resolves a ref to a commit, or undefined when it isn't in the local history (e.g. it was force-pushed away). */
17
+ export declare const findCommitSha: (ref: string) => Promise<string | undefined>;
13
18
  /**
14
- * Returns all files touched by non-merge commits on the branch (full history, ignoring baseCommit).
15
- * Used to check whether the branch itself has any functional changes, independent of what master merged in.
19
+ * Commits reachable from toRef but not from fromRef, oldest first: the range (fromRef, toRef], so fromRef itself is
20
+ * not included. To include it, pass its parent, `${sha}~`.
16
21
  */
17
- export declare const getBranchOnlyChangedFiles: (sourceBranch: string, targetBranch: string) => Promise<string[]>;
18
- /**
19
- *
20
- * @param shaOrCommit Supports both a SHA string or a Commit object in JSON format. Can be empty.
21
- * @returns The SHA string if valid, otherwise throws an error.
22
- */
23
- export declare const parseBaseCommit: (shaOrCommit: string | undefined) => string | undefined;
24
- /**
25
- * Gets the commits between sourceBranch and targetBranch (exclusive).
26
- * - If baseCommit is provided, only returns commits after the baseCommit.
27
- */
28
- export declare const getCommits: ({ sourceBranch, targetBranch, baseCommit, }: Pick<Config, "sourceBranch" | "targetBranch" | "baseCommit">) => Promise<Commit[]>;
22
+ export declare const getCommitsBetween: (fromRef: string, toRef: string) => Promise<Commit[]>;
29
23
  export declare const parseCommit: (commitString: string) => Commit;
30
24
  /**
31
- * Returns the currently checked-out branch. Release builds point the Actor version at this branch,
25
+ * Returns the currently checked-out branch. Builds point the Actor version at this branch,
32
26
  * so a detached HEAD (no branch to point at) is an error rather than a guess.
33
27
  */
34
28
  export declare const getCurrentBranch: () => Promise<string>;
29
+ /** Resolves a ref (branch, remote branch, SHA, HEAD, ...) to the full SHA of the commit it points to. */
30
+ export declare const resolveCommitSha: (ref: string) => Promise<string>;
35
31
  /**
36
32
  * Picks the repo URL to build from. By default it's the `origin` remote, and runBuilds then checks it against
37
33
  * each Actor's default version, so a fork or mirror remote can't repoint a published Actor. An explicit
@@ -48,6 +44,11 @@ export declare const resolveRepoUrl: (explicitRepoUrl: string | undefined) => Pr
48
44
  * - ssh://git@github.com/org/repo#master:actors/foo (Actor versions carry a `#branch:folder` fragment)
49
45
  */
50
46
  export declare const normalizeRepoUrl: (repoUrl: string) => string;
47
+ /**
48
+ * Web link to a commit, e.g. https://github.com/apify-store/google-maps/commit/<sha>. Null for hosts other than
49
+ * GitHub, whose commit pages live under other paths.
50
+ */
51
+ export declare const getCommitUrl: (repoUrl: string, sha: string) => string | null;
51
52
  /** Repository name from its URL, e.g. `google-maps` for git@github.com:apify-store/google-maps.git */
52
53
  export declare const getRepoName: (repoUrl: string) => string;
53
54
  /**
@@ -55,16 +56,7 @@ export declare const getRepoName: (repoUrl: string) => string;
55
56
  * Unlike the PR path (getCommits), there is no lenient fallback. Falling back to "everything"
56
57
  * would rebuild the latest build of every Actor and post it to Slack, so every problem is an error.
57
58
  */
58
- export declare const resolveReleaseBaseCommit: (baseCommit: string) => Promise<string>;
59
- /**
60
- * Everything that changed since the last release (baseSha, exclusive) up to HEAD, or null when there
61
- * are no new commits. Changed files come from diffing the range directly instead of from the commit
62
- * list: with a merge commit, the oldest commit of the merged branch can be older than baseSha, and
63
- * diffing from its parent would pull in already-released changes.
64
- */
65
- export declare const getReleaseChanges: (baseSha: string) => Promise<{
66
- commits: Commit[];
67
- changedFiles: string[];
68
- changelog: string | null;
69
- } | null>;
59
+ export declare const resolveReleaseBaseCommit: (baseCommit: string, head?: string) => Promise<string>;
60
+ /** Returns the lines added to the root CHANGELOG.md between fromRef and toRef, or null if it didn't change. */
61
+ export declare const getChangelogAdditions: (fromRef: string, toRef: string, changedFiles: string[]) => Promise<string | null>;
70
62
  //# sourceMappingURL=git.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../bin/git.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAGjD,eAAO,MAAM,oBAAoB,uBAAQ,CAAC;AAG1C;;GAEG;AACH,eAAO,MAAM,eAAe,GAAU,SAAS,MAAM,EAAE,sBAetD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAU,cAAc,MAAM,EAAE,cAAc,MAAM,KAAG,OAAO,CAAC,OAAO,CAoCpG,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,yBAAyB,GAAU,cAAc,MAAM,EAAE,cAAc,MAAM,K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mHAAmH;AACnH,eAAO,MAAM,aAAa,GAAU,KAAK,MAAM,KAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAOtE,CAAC;AAEP;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAAU,SAAS,MAAM,EAAE,OAAO,MAAM,KAAG,OAAO,CAAC,MAAM,EAAE,CAQxF,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,cAAc,MAAM,KAAG,MAYlD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,QAAa,OAAO,CAAC,MAAM,CAUvD,CAAC;AAEF,yGAAyG;AACzG,eAAO,MAAM,gBAAgB,GAAU,KAAK,MAAM,KAAG,OAAO,CAAC,MAAM,CACyC,CAAC;AAa7G;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAU,iBAAiB,MAAM,GAAG,SAAS;;;EAGtE,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAI,SAAS,MAAM,KAAG,MAUlD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,YAAY,GAAI,SAAS,MAAM,EAAE,KAAK,MAAM,KAAG,MAAM,GAAG,IAGpE,CAAC;AAEF,sGAAsG;AACtG,eAAO,MAAM,WAAW,GAAI,SAAS,MAAM,KAAG,MAE7C,CAAC;AAOF;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,GAAU,YAAY,MAAM,EAAE,aAAa,KAAG,OAAO,CAAC,MAAM,CAmChG,CAAC;AAIF,+GAA+G;AAC/G,eAAO,MAAM,qBAAqB,GAC9B,SAAS,MAAM,EACf,OAAO,MAAM,EACb,cAAc,MAAM,EAAE,KACvB,OAAO,CAAC,MAAM,GAAG,IAAI,CA0BvB,CAAC"}
package/dist/bin/git.js CHANGED
@@ -2,119 +2,49 @@ import { logger } from './logger.js';
2
2
  import { GitCommandError, runGitCommand } from './utils.js';
3
3
  export const GIT_FORMAT_SEPARATOR = '»¦«';
4
4
  const GIT_LOG_FORMAT = ['%H', '%aN<%aE>', '%aD', '%s'].join(GIT_FORMAT_SEPARATOR);
5
+ // Lists the changed paths. With rename detection (on by default) a moved file is listed only under its new path,
6
+ // so the Actor whose context it left wouldn't count as changed. --no-renames lists it as deleted and added instead.
7
+ const LIST_CHANGED_PATHS = ['--name-only', '--no-renames'];
5
8
  /**
6
- * Gets the list of changed files between the given commits (inclusive).
9
+ * Files that differ between two commits, i.e. changed by the commits in the range (fromRef, toRef]. fromRef's own
10
+ * changes are not included: to include them, pass its parent, `${sha}~` (as getChangedFiles does).
11
+ * Diffing the endpoints, rather than walking a commit list, is what keeps merges right: the oldest commit of a
12
+ * merged branch can predate fromRef, and its changes are already in fromRef.
7
13
  */
8
- export const getChangedFiles = async (commits) => {
9
- // getCommits never returns an empty list (the rerun check returns all commits when the base commit
10
- // is the branch HEAD, and an empty git range throws when parsing), so this signals a programmer error
11
- if (commits.length === 0) {
12
- throw new Error('Cannot get changed files: the commit list is empty. This should never happen.');
13
- }
14
- const changedFilesString = await runGitCommand(['diff', '--name-only', `${commits[0].sha}~..${commits[commits.length - 1].sha}`], { operation: 'get the list of changed files between commits' });
14
+ export const getChangedFilesBetween = async (fromRef, toRef) => {
15
+ const changedFilesString = await runGitCommand(['diff', ...LIST_CHANGED_PATHS, `${fromRef}..${toRef}`], {
16
+ operation: 'get the list of changed files between commits',
17
+ });
15
18
  const changedFiles = changedFilesString.split('\n').filter(Boolean);
16
19
  logger.info(`Changed files (up to 50): ${changedFiles.slice(0, 50).join(', ')}`);
17
20
  return changedFiles;
18
21
  };
19
22
  /**
20
- * Returns true if the branch contains a merge commit whose parent is reachable from targetBranch
21
- * (i.e. a genuine "merge from target" commit, not a merge of some unrelated branch).
22
- * Uses the full targetBranch..sourceBranch range, ignoring baseCommit.
23
+ * The commit `git diff base...head` compares against: where `head` forked from `base`, or the last commit of `base`
24
+ * that `head` merged in. The diff from it holds only what `head` itself changed, like GitHub's "Files changed" tab.
25
+ * With criss-cross merges there are several such commits and git picks one.
23
26
  */
24
- export const hasMergeFromTarget = async (sourceBranch, targetBranch) => {
25
- const mergeShas = (await runGitCommand(['log', '--merges', '--pretty=format:%H', `${targetBranch}..${sourceBranch}`], {
26
- operation: 'find merge commits on the source branch that are absent from the target branch',
27
- }))
28
- .split('\n')
29
- .filter(Boolean);
30
- for (const sha of mergeShas) {
31
- const parents = (await runGitCommand(['log', '-1', '--pretty=format:%P', sha], {
32
- operation: 'get parents of a merge commit',
33
- })).split(' ');
34
- for (const parent of parents) {
35
- // git merge-base A B outputs the common ancestor.
36
- // If that equals A, then A is an ancestor of B (i.e. parent is reachable from targetBranch).
37
- let mergeBase;
38
- try {
39
- mergeBase = await runGitCommand(['merge-base', parent, targetBranch], {
40
- operation: 'check whether a merge parent is reachable from the target branch',
41
- });
42
- }
43
- catch (error) {
44
- // Exit code 1 on merge-base means the histories have no common ancestor.
45
- if (error instanceof GitCommandError && error.exitCode === 1) {
46
- continue;
47
- }
48
- throw error;
49
- }
50
- if (mergeBase === parent) {
51
- return true;
52
- }
53
- }
54
- }
55
- return false;
56
- };
57
- /**
58
- * Returns all files touched by non-merge commits on the branch (full history, ignoring baseCommit).
59
- * Used to check whether the branch itself has any functional changes, independent of what master merged in.
60
- */
61
- export const getBranchOnlyChangedFiles = async (sourceBranch, targetBranch) => {
62
- const output = await runGitCommand(['log', '--no-merges', '--name-only', '--pretty=format:', `${targetBranch}..${sourceBranch}`], { operation: 'list files changed by non-merge commits on the source branch' });
63
- return output.split('\n').filter(Boolean);
64
- };
65
- const SHA_REGEX = /^[0-9a-f]{40}$/i;
66
- /**
67
- *
68
- * @param shaOrCommit Supports both a SHA string or a Commit object in JSON format. Can be empty.
69
- * @returns The SHA string if valid, otherwise throws an error.
70
- */
71
- export const parseBaseCommit = (shaOrCommit) => {
72
- if (!shaOrCommit)
27
+ export const getMergeBase = async (base, head) => runGitCommand(['merge-base', base, head], { operation: `find where ${head} forked from ${base}` });
28
+ /** Resolves a ref to a commit, or undefined when it isn't in the local history (e.g. it was force-pushed away). */
29
+ export const findCommitSha = async (ref) => runGitCommand(['rev-parse', '--verify', '--quiet', `${ref}^{commit}`], {
30
+ operation: `look up ${ref} in local Git history`,
31
+ }).catch((error) => {
32
+ // --quiet suppresses Git's error text for a missing commit, but Git still exits with code 1
33
+ if (error instanceof GitCommandError && error.exitCode === 1)
73
34
  return undefined;
74
- let sha;
75
- if (shaOrCommit.startsWith('{')) {
76
- sha = JSON.parse(shaOrCommit).sha;
77
- }
78
- else {
79
- sha = shaOrCommit;
80
- }
81
- if (!SHA_REGEX.test(sha)) {
82
- throw new Error(`Invalid base commit SHA: "${sha}". It should be a 40-character hexadecimal string, instead got input: "${shaOrCommit}".`);
83
- }
84
- return sha;
85
- };
86
- const fetchAllBranchCommits = async (sourceBranch, targetBranch) => {
87
- const output = await runGitCommand(['log', `--pretty=format:${GIT_LOG_FORMAT}`, `${targetBranch}..${sourceBranch}`], { operation: 'list commits reachable from the source ref but absent from the target ref' });
88
- const commitsStrings = output.split('\n');
89
- const commits = commitsStrings.map((commitString) => parseCommit(commitString));
90
- commits.reverse();
91
- return commits;
92
- };
35
+ throw error;
36
+ });
93
37
  /**
94
- * Gets the commits between sourceBranch and targetBranch (exclusive).
95
- * - If baseCommit is provided, only returns commits after the baseCommit.
38
+ * Commits reachable from toRef but not from fromRef, oldest first: the range (fromRef, toRef], so fromRef itself is
39
+ * not included. To include it, pass its parent, `${sha}~`.
96
40
  */
97
- export const getCommits = async ({ sourceBranch, targetBranch, baseCommit, }) => {
98
- const baseCommitSha = parseBaseCommit(baseCommit);
99
- const commits = await fetchAllBranchCommits(sourceBranch, targetBranch);
100
- // The last validated (base) commit being the branch HEAD means nothing new was pushed since the last
101
- // validation — the dev reran the workflow (or force-pushed to the same state) to trigger a clean test
102
- const headSha = commits[commits.length - 1]?.sha;
103
- if (baseCommitSha !== undefined && baseCommitSha === headSha) {
104
- logger.info(`Detected rerun with the same commit that we already validated. This usually means the user wants to rerun the Action from scratch, ignoring last validated commit ${baseCommitSha} and returning all commits`);
105
- logger.info(`Commits being returned: ${commits.map((c) => c.sha).join(', ')}`);
106
- return commits;
107
- }
108
- const baseCommitIndex = commits.findIndex((commit) => commit.sha === baseCommitSha);
109
- const hasBaseCommit = baseCommitIndex !== -1;
110
- if (hasBaseCommit) {
111
- const commitsUpToBaseCommit = commits.slice(baseCommitIndex + 1);
112
- logger.info(`Found base commit ${baseCommitSha} at index ${baseCommitIndex}, returning ${commitsUpToBaseCommit.length} commits after it`);
113
- logger.info(`Commits being returned: ${commitsUpToBaseCommit.map((c) => c.sha).join(', ')}`);
114
- return commitsUpToBaseCommit;
115
- }
116
- logger.info(`Base commit ${baseCommitSha} not found in the commit range, returning all ${commits.length} commits`);
117
- logger.info(`Commits being returned: ${commits.map((c) => c.sha).join(', ')}`);
41
+ export const getCommitsBetween = async (fromRef, toRef) => {
42
+ const output = await runGitCommand(['log', `--pretty=format:${GIT_LOG_FORMAT}`, `${fromRef}..${toRef}`], {
43
+ operation: 'list commits reachable from the source ref but absent from the target ref',
44
+ });
45
+ // An empty range (e.g. `x..x`) prints nothing
46
+ const commits = output.split('\n').filter(Boolean).map(parseCommit);
47
+ commits.reverse();
118
48
  return commits;
119
49
  };
120
50
  export const parseCommit = (commitString) => {
@@ -131,18 +61,20 @@ export const parseCommit = (commitString) => {
131
61
  };
132
62
  };
133
63
  /**
134
- * Returns the currently checked-out branch. Release builds point the Actor version at this branch,
64
+ * Returns the currently checked-out branch. Builds point the Actor version at this branch,
135
65
  * so a detached HEAD (no branch to point at) is an error rather than a guess.
136
66
  */
137
67
  export const getCurrentBranch = async () => {
138
68
  const branch = await runGitCommand(['rev-parse', '--abbrev-ref', 'HEAD'], {
139
- operation: 'determine the current branch for release',
69
+ operation: 'determine the checked-out branch',
140
70
  });
141
71
  if (branch === 'HEAD') {
142
- throw new Error('Cannot determine the branch to release: HEAD is detached. Check out the branch you want to release.');
72
+ throw new Error('Cannot determine the branch to build from: HEAD is detached. Check out the branch you want to build.');
143
73
  }
144
74
  return branch;
145
75
  };
76
+ /** Resolves a ref (branch, remote branch, SHA, HEAD, ...) to the full SHA of the commit it points to. */
77
+ export const resolveCommitSha = async (ref) => runGitCommand(['rev-parse', '--verify', `${ref}^{commit}`], { operation: `resolve ${ref} to a commit` });
146
78
  /**
147
79
  * Reads the repository URL from the `origin` remote, rewritten to the SSH form the Apify platform
148
80
  * uses for Git repo sources, e.g. git@github.com:apify-store/google-maps
@@ -179,10 +111,19 @@ export const normalizeRepoUrl = (repoUrl) => {
179
111
  .replace(/\.git$/, '')
180
112
  .toLowerCase();
181
113
  };
114
+ /**
115
+ * Web link to a commit, e.g. https://github.com/apify-store/google-maps/commit/<sha>. Null for hosts other than
116
+ * GitHub, whose commit pages live under other paths.
117
+ */
118
+ export const getCommitUrl = (repoUrl, sha) => {
119
+ const repository = normalizeRepoUrl(repoUrl);
120
+ return repository.startsWith('github.com/') ? `https://${repository}/commit/${sha}` : null;
121
+ };
182
122
  /** Repository name from its URL, e.g. `google-maps` for git@github.com:apify-store/google-maps.git */
183
123
  export const getRepoName = (repoUrl) => {
184
124
  return normalizeRepoUrl(repoUrl).split('/').pop();
185
125
  };
126
+ const SHA_REGEX = /^[0-9a-f]{40}$/i;
186
127
  // Sent by e.g. GitHub as the "before" commit of a push that created the branch
187
128
  const ZERO_SHA_REGEX = /^0{40}$/;
188
129
  /**
@@ -190,49 +131,42 @@ const ZERO_SHA_REGEX = /^0{40}$/;
190
131
  * Unlike the PR path (getCommits), there is no lenient fallback. Falling back to "everything"
191
132
  * would rebuild the latest build of every Actor and post it to Slack, so every problem is an error.
192
133
  */
193
- export const resolveReleaseBaseCommit = async (baseCommit) => {
194
- const sha = parseBaseCommit(baseCommit);
195
- if (!sha) {
196
- throw new Error('--base-commit is required for release. See the README section "Releasing Actors".');
134
+ export const resolveReleaseBaseCommit = async (baseCommit, head = 'HEAD') => {
135
+ if (!SHA_REGEX.test(baseCommit)) {
136
+ throw new Error(`Invalid base commit SHA: "${baseCommit}". It should be a 40-character hexadecimal string. ` +
137
+ 'See the "Releasing Actors" section of docs/cli.md.');
197
138
  }
139
+ const sha = baseCommit;
198
140
  if (ZERO_SHA_REGEX.test(sha)) {
199
141
  throw new Error(`Base commit is ${sha}, which means the branch was just created and there is no previous release to diff against. ` +
200
- `Rerun with --base-commit set to the last commit before the changes you want to release.`);
142
+ `Rerun with the base commit set to the last commit before the changes you want to release.`);
201
143
  }
202
- // --quiet suppresses Git's error text for a missing commit, but Git still exits with code 1.
203
- const verifiedSha = await runGitCommand(['rev-parse', '--verify', '--quiet', `${sha}^{commit}`], {
204
- operation: 'verify the release base commit in local Git history',
205
- }).catch((error) => {
206
- if (error instanceof GitCommandError && error.exitCode === 1)
207
- return '';
208
- throw error;
209
- });
210
- if (!verifiedSha) {
144
+ if (!(await findCommitSha(sha))) {
211
145
  throw new Error(`Base commit ${sha} is not in the local git history. Either the checkout is shallow ` +
212
146
  `(fetch the full history, e.g. fetch-depth: 0 in actions/checkout) or the branch was force-pushed.`);
213
147
  }
214
148
  // git merge-base A B outputs the common ancestor. If that equals A, then A is an ancestor of B.
215
- const mergeBase = await runGitCommand(['merge-base', verifiedSha, 'HEAD'], {
216
- operation: 'check whether the release base commit is an ancestor of HEAD',
149
+ const mergeBase = await runGitCommand(['merge-base', sha, head], {
150
+ operation: `check whether the release base commit is an ancestor of ${head}`,
217
151
  }).catch((error) => {
218
152
  if (error instanceof GitCommandError && error.exitCode === 1)
219
153
  return '';
220
154
  throw error;
221
155
  });
222
156
  if (mergeBase !== sha) {
223
- throw new Error(`Base commit ${sha} is not an ancestor of HEAD, most likely because the branch was force-pushed. ` +
224
- `The changed files cannot be determined reliably. Rerun with --base-commit set to an ancestor of HEAD ` +
157
+ throw new Error(`Base commit ${sha} is not an ancestor of ${head}, most likely because the branch was force-pushed. ` +
158
+ `The changed files cannot be determined reliably. Rerun with the base commit set to an ancestor of ${head} ` +
225
159
  `from before the changes you want to release.`);
226
160
  }
227
161
  return sha;
228
162
  };
229
163
  const CHANGELOG_PATH = 'CHANGELOG.md';
230
- /** Returns the lines added to the root CHANGELOG.md between baseSha and HEAD, or null if it didn't change. */
231
- const getChangelogAdditions = async (baseSha, changedFiles) => {
164
+ /** Returns the lines added to the root CHANGELOG.md between fromRef and toRef, or null if it didn't change. */
165
+ export const getChangelogAdditions = async (fromRef, toRef, changedFiles) => {
232
166
  if (!changedFiles.includes(CHANGELOG_PATH)) {
233
167
  return null;
234
168
  }
235
- const diff = await runGitCommand(['diff', baseSha, 'HEAD', '--', CHANGELOG_PATH], {
169
+ const diff = await runGitCommand(['diff', fromRef, toRef, '--', CHANGELOG_PATH], {
236
170
  operation: 'read changelog changes since the last release',
237
171
  });
238
172
  const added = [];
@@ -254,21 +188,4 @@ const getChangelogAdditions = async (baseSha, changedFiles) => {
254
188
  }
255
189
  return added.join('\n').trim();
256
190
  };
257
- /**
258
- * Everything that changed since the last release (baseSha, exclusive) up to HEAD, or null when there
259
- * are no new commits. Changed files come from diffing the range directly instead of from the commit
260
- * list: with a merge commit, the oldest commit of the merged branch can be older than baseSha, and
261
- * diffing from its parent would pull in already-released changes.
262
- */
263
- export const getReleaseChanges = async (baseSha) => {
264
- if ((await runGitCommand(['rev-parse', 'HEAD'], { operation: 'identify the current release commit' })) === baseSha) {
265
- return null;
266
- }
267
- const commits = await fetchAllBranchCommits('HEAD', baseSha);
268
- const changedFiles = await runGitCommand(['diff', '--name-only', baseSha, 'HEAD'], {
269
- operation: 'list files changed since the last release',
270
- }).then((output) => output.split('\n').filter(Boolean));
271
- const changelog = await getChangelogAdditions(baseSha, changedFiles);
272
- return { commits, changedFiles, changelog };
273
- };
274
191
  //# sourceMappingURL=git.js.map