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

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 +22 -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 +167 -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 +138 -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 +146 -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 +469 -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 +175 -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
@@ -0,0 +1,21 @@
1
+ import type { TestTarget } from './stdin-input.js';
2
+ import { type TestReport } from './test-report.js';
3
+ interface RunTestsOptions {
4
+ /** Glob from the repo root (`cwd`) of the test files to run, e.g. `test/platform/**` */
5
+ testFilesGlob: string;
6
+ /** The Actors to test, each with its build or, without one, its default build */
7
+ targets: TestTarget[];
8
+ /** Keeps vitest's own JSON report there, e.g. to upload it */
9
+ vitestOutputFile?: string;
10
+ /** Vitest reporters to add to the default one and the JSON one the report is read from, e.g. `github-actions` */
11
+ reporters?: string[];
12
+ cwd?: string;
13
+ }
14
+ /**
15
+ * Runs the repository's vitest on the given builds and returns what happened as a `TestReport`. Vitest's own output
16
+ * goes to stderr, so stdout stays free for the report. A failing test or a crashing vitest is a failed report, not
17
+ * an error: the report is how the failure gets to `notify`.
18
+ */
19
+ export declare const runTests: ({ testFilesGlob, targets, vitestOutputFile, reporters, cwd, }: RunTestsOptions) => Promise<TestReport>;
20
+ export {};
21
+ //# sourceMappingURL=run-tests.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-tests.d.ts","sourceRoot":"","sources":["../../bin/run-tests.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAAkC,KAAK,UAAU,EAAuC,MAAM,kBAAkB,CAAC;AA2CxH,UAAU,eAAe;IACrB,wFAAwF;IACxF,aAAa,EAAE,MAAM,CAAC;IACtB,iFAAiF;IACjF,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,8DAA8D;IAC9D,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iHAAiH;IACjH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;GAIG;AACH,eAAO,MAAM,QAAQ,GAAU,+DAM5B,eAAe,KAAG,OAAO,CAAC,UAAU,CA6DtC,CAAC"}
@@ -0,0 +1,138 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { existsSync } from 'node:fs';
3
+ import fs from 'node:fs/promises';
4
+ import os from 'node:os';
5
+ import path from 'node:path';
6
+ import process from 'node:process';
7
+ import { createInterface } from 'node:readline';
8
+ import { withActorIds } from './actor-ids.js';
9
+ import { logger } from './logger.js';
10
+ import { resolveTestFilesGlob } from './test-files-glob.js';
11
+ import { failedRunReport, logTestReport, toTestReport } from './test-report.js';
12
+ /**
13
+ * Finds the vitest the repository installed, the way Node would resolve it from `cwd`. The CLI ships as a bundle
14
+ * that runs outside the repository's `node_modules`, so the tests keep the vitest (and the lib) version the
15
+ * repository locked. Read from `package.json` because vitest's exports don't expose its bin.
16
+ */
17
+ const resolveVitestBin = async (cwd) => {
18
+ for (let dir = path.resolve(cwd);; dir = path.dirname(dir)) {
19
+ const packageDir = path.join(dir, 'node_modules', 'vitest');
20
+ if (existsSync(path.join(packageDir, 'package.json'))) {
21
+ const { bin } = JSON.parse(await fs.readFile(path.join(packageDir, 'package.json'), 'utf8'));
22
+ return path.join(packageDir, typeof bin === 'string' ? bin : bin.vitest);
23
+ }
24
+ if (path.dirname(dir) === dir) {
25
+ throw new Error(`vitest is not installed in ${cwd}, install the repository's dependencies first`);
26
+ }
27
+ }
28
+ };
29
+ /**
30
+ * Turns the glob into vitest filters. Vitest filters are parts of a file path, not globs, so the glob is resolved here.
31
+ * The filters are the folders that hold only matched files and the other matched files one by one, so the command
32
+ * line stays short. They go to vitest as absolute paths. Vitest also matches their path relative to the root anywhere
33
+ * in a test file's path, so a copy at `dist/test/platform/a.test.ts` would run too: vitest's own `exclude` keeps such
34
+ * copies out.
35
+ */
36
+ const resolveVitestFilters = async (testFilesGlob, cwd) => {
37
+ const { files, paths } = await resolveTestFilesGlob(testFilesGlob, cwd);
38
+ // Without filters vitest would run every test of the repo
39
+ if (files.length === 0) {
40
+ throw new Error(`No files match --test-files-glob "${testFilesGlob}". The glob is relative to the repo root, e.g. "test/platform/**".`);
41
+ }
42
+ logger.info(`Running the ${files.length} file(s) that match --test-files-glob "${testFilesGlob}"`);
43
+ logger.debug(`Files: ${files.join(', ')}`);
44
+ // Vitest compares against real paths, and cwd can be a symlink (e.g. /tmp on macOS). join keeps a folder's
45
+ // trailing slash, which stops `test/platform/daily/` from also matching `test/platform/daily-without-pr/`.
46
+ const root = await fs.realpath(cwd);
47
+ return paths.map((filePath) => path.join(root, filePath));
48
+ };
49
+ /**
50
+ * Runs the repository's vitest on the given builds and returns what happened as a `TestReport`. Vitest's own output
51
+ * goes to stderr, so stdout stays free for the report. A failing test or a crashing vitest is a failed report, not
52
+ * an error: the report is how the failure gets to `notify`.
53
+ */
54
+ export const runTests = async ({ testFilesGlob, targets, vitestOutputFile, reporters = [], cwd = process.cwd(), }) => {
55
+ // Without it the lib skips every platform test, and a run that tested nothing would pass
56
+ if (!process.env.TESTER_APIFY_TOKEN) {
57
+ throw new Error('TESTER_APIFY_TOKEN is not set. The platform tests need it to run the Actors.');
58
+ }
59
+ const vitestBin = await resolveVitestBin(cwd);
60
+ const vitestFilters = await resolveVitestFilters(testFilesGlob, cwd);
61
+ // A test only runs when the ID it names its Actor by is listed, so each Actor gets both its full name and raw ID
62
+ const actorBuilds = await withActorIds(targets);
63
+ const tempDir = vitestOutputFile ? null : await fs.mkdtemp(path.join(os.tmpdir(), 'apify-test-tools-'));
64
+ const outputFile = path.resolve(cwd, vitestOutputFile ?? path.join(tempDir, 'vitest-report.json'));
65
+ // A report left over from an earlier run must not pass for this one's
66
+ await fs.rm(outputFile, { force: true });
67
+ // Stdin is the only source of what to test, so whatever the caller's environment holds doesn't leak into the tests
68
+ const env = { ...process.env };
69
+ // Vitest writes to a pipe, so it would drop colors that the terminal it ends up in shows
70
+ if (process.stderr.isTTY && env.FORCE_COLOR === undefined && env.NO_COLOR === undefined)
71
+ env.FORCE_COLOR = '1';
72
+ // The lib runs the tests of the Actors listed here, each on the build given, or on its default build without one
73
+ env.ACTOR_BUILDS = JSON.stringify(actorBuilds);
74
+ const described = actorBuilds.map(({ actorFullName, actorRawId, buildNumber }) => `${actorFullName ?? actorRawId} (${buildNumber ?? 'default build'})`);
75
+ logger.info(`Testing ${targets.length} Actor(s): ${described.join(', ') || 'none'}`);
76
+ const args = [
77
+ vitestBin,
78
+ 'run',
79
+ ...vitestFilters,
80
+ '--reporter=default',
81
+ '--reporter=json',
82
+ ...reporters.map((reporter) => `--reporter=${reporter}`),
83
+ `--outputFile.json=${outputFile}`,
84
+ // Platform tests mostly wait on Actor runs, not on the CPU, so they run far more at once than vitest's defaults
85
+ '--maxConcurrency=20',
86
+ '--fileParallelism',
87
+ '--maxWorkers=100',
88
+ ];
89
+ logger.debug(`Running vitest: ${args.join(' ')}`);
90
+ try {
91
+ const exitCode = await spawnVitest(args, { cwd, env });
92
+ let vitestReport;
93
+ try {
94
+ vitestReport = JSON.parse(await fs.readFile(outputFile, 'utf8'));
95
+ }
96
+ catch (error) {
97
+ logger.debug(`Could not read the vitest report: ${error.message}`);
98
+ const report = failedRunReport(`Vitest exited with code ${exitCode} without a report, see its output above`);
99
+ logTestReport(report);
100
+ return report;
101
+ }
102
+ const report = toTestReport(vitestReport, { cwd, exitCode });
103
+ logTestReport(report);
104
+ return report;
105
+ }
106
+ finally {
107
+ if (tempDir)
108
+ await fs.rm(tempDir, { recursive: true, force: true });
109
+ }
110
+ };
111
+ /** Resolves with vitest's exit code. Signals we get (a cancelled CI job) are passed on, so vitest can clean up. */
112
+ const spawnVitest = async (args, { cwd, env }) => new Promise((resolve, reject) => {
113
+ // Vitest's stdout goes to our stderr: stdout is reserved for the report. It is piped through us rather than
114
+ // handed over, to leave out the JSON reporter's note about the temporary file it wrote.
115
+ const child = spawn(process.execPath, args, { cwd, env, stdio: ['ignore', 'pipe', 2] });
116
+ createInterface({ input: child.stdout, crlfDelay: Infinity }).on('line', (line) => {
117
+ if (!line.startsWith('JSON report written to '))
118
+ process.stderr.write(`${line}\n`);
119
+ });
120
+ const forward = (signal) => child.kill(signal);
121
+ process.on('SIGINT', forward);
122
+ process.on('SIGTERM', forward);
123
+ const cleanup = () => {
124
+ process.off('SIGINT', forward);
125
+ process.off('SIGTERM', forward);
126
+ };
127
+ child.on('error', (error) => {
128
+ cleanup();
129
+ reject(new Error(`Failed to start vitest: ${error.message}`));
130
+ });
131
+ child.on('close', (code, signal) => {
132
+ cleanup();
133
+ if (signal)
134
+ logger.warn(`Vitest was stopped by ${signal}`);
135
+ resolve(code ?? 1);
136
+ });
137
+ });
138
+ //# sourceMappingURL=run-tests.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-tests.js","sourceRoot":"","sources":["../../bin/run-tests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,aAAa,EAAmB,YAAY,EAAyB,MAAM,kBAAkB,CAAC;AAExH;;;;GAIG;AACH,MAAM,gBAAgB,GAAG,KAAK,EAAE,GAAW,EAAmB,EAAE;IAC5D,KAAK,IAAI,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAI,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1D,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,EAAE,QAAQ,CAAC,CAAC;QAC5D,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC;YACpD,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC,EAAE,MAAM,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,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC/B,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACpC,CAAC,CAAC;IACF,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;QACxB,OAAO,EAAE,CAAC;QACV,MAAM,CAAC,IAAI,KAAK,CAAC,2BAA2B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;IACH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;QAC/B,OAAO,EAAE,CAAC;QACV,IAAI,MAAM;YAAE,MAAM,CAAC,IAAI,CAAC,yBAAyB,MAAM,EAAE,CAAC,CAAC;QAC3D,OAAO,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -1,22 +1,10 @@
1
1
  import { WebClient } from '@slack/web-api';
2
- import type { Commit } from './types.js';
3
- type NotifyToSlackOptions = {
4
- repository: string;
5
- changedFiles: string[];
6
- changelog: string | null;
7
- commits: Commit[];
8
- dryRun: boolean;
9
- author: string;
10
- releaseSlackChannel?: string;
11
- reportSlackChannel?: string;
12
- };
13
2
  /**
14
3
  * Creates the client the real run posts with. A dry run posts nothing but still requires the token and checks
15
4
  * Slack accepts it (`auth.test` is read-only), so it fails wherever the real run would.
16
5
  */
17
6
  export declare const getSlackClient: (tokenEnvVar: string, dryRun: boolean) => Promise<WebClient>;
18
7
  export declare const sendingLabel: (dryRun: boolean) => "[DRY RUN] Would send" | "Sending";
19
- export declare const notifyToSlack: ({ changedFiles, commits, changelog, repository, dryRun, author, releaseSlackChannel, reportSlackChannel, }: NotifyToSlackOptions) => Promise<void>;
20
- export declare const sendSlackMessage: (slack: WebClient, channel: string, text: string, blocks: string[]) => Promise<void>;
21
- export {};
8
+ /** Posts `text`, with `details` as sections in its thread, as many replies as Slack's block limit needs. */
9
+ export declare const sendSlackMessage: (slack: WebClient, channel: string, text: string, details: string[]) => Promise<void>;
22
10
  //# sourceMappingURL=slack.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"slack.d.ts","sourceRoot":"","sources":["../../bin/slack.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAGzC,KAAK,oBAAoB,GAAG;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC/B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,cAAc,GAAU,aAAa,MAAM,EAAE,QAAQ,OAAO,KAAG,OAAO,CAAC,SAAS,CAW5F,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,QAAQ,OAAO,uCAAkD,CAAC;AAK/F,eAAO,MAAM,aAAa,GAAU,4GASjC,oBAAoB,kBAgDtB,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAU,OAAO,SAAS,EAAE,SAAS,MAAM,EAAE,MAAM,MAAM,EAAE,QAAQ,MAAM,EAAE,kBASvG,CAAC"}
1
+ {"version":3,"file":"slack.d.ts","sourceRoot":"","sources":["../../bin/slack.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAK3C;;;GAGG;AACH,eAAO,MAAM,cAAc,GAAU,aAAa,MAAM,EAAE,QAAQ,OAAO,KAAG,OAAO,CAAC,SAAS,CAW5F,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,QAAQ,OAAO,uCAAkD,CAAC;AAM/F,4GAA4G;AAC5G,eAAO,MAAM,gBAAgB,GAAU,OAAO,SAAS,EAAE,SAAS,MAAM,EAAE,MAAM,MAAM,EAAE,SAAS,MAAM,EAAE,kBAkBxG,CAAC"}
package/dist/bin/slack.js CHANGED
@@ -19,56 +19,27 @@ export const getSlackClient = async (tokenEnvVar, dryRun) => {
19
19
  return slack;
20
20
  };
21
21
  export const sendingLabel = (dryRun) => (dryRun ? '[DRY RUN] Would send' : 'Sending');
22
- // Git authors come as "Name<email>", Slack only needs the name
23
- const displayName = (author) => author.replace(/\s*<[^>]*>$/, '');
24
- export const notifyToSlack = async ({ changedFiles, commits, changelog, repository, dryRun, author, releaseSlackChannel, reportSlackChannel, }) => {
25
- if (!changelog) {
26
- logger.warn('No new changelog entries found, did you forget to update it?');
27
- }
28
- if (!releaseSlackChannel && !reportSlackChannel) {
29
- logger.info('Skipping slack notification, no --release-slack-channel or --report-slack-channel passed');
30
- return;
31
- }
32
- const slack = await getSlackClient('SLACK_TOKEN_RELEASES_BOT', dryRun);
33
- let shortMessage = `*${repository}* – New release (by ${displayName(author)}):\n\n`;
34
- // This one is just for broader public that only cares about public facing changes
35
- if (changelog && releaseSlackChannel) {
36
- shortMessage += `*Additions to the changelog*:\n\n${changelog}\n`;
37
- logger.info(`=========================================`);
38
- logger.info(`**${sendingLabel(dryRun)} slack message to channel**: ${releaseSlackChannel}.\n\n${shortMessage}`);
39
- logger.info(`=========================================`);
40
- if (!dryRun) {
41
- await slack.chat.postMessage({
42
- channel: releaseSlackChannel,
43
- text: shortMessage,
44
- });
45
- }
46
- }
47
- const commitsMessage = `${commits
48
- .map(({ author: commitAuthor, message }, index) => `${index + 1}. Commit message: ${message}\n\tAuthor: ${displayName(commitAuthor)}.`)
49
- .join('\n')}`;
50
- const changedFilesMessage = `*Files changed*: ${changedFiles.map((file) => `\`${file}\``).join(', ')}`;
51
- const longMessage = `${shortMessage}\n*Commit list*:\n${commitsMessage}\n\n${changedFilesMessage}`;
52
- // This one is for devs and project managers that need to know more details
53
- if (reportSlackChannel) {
54
- logger.info(`=========================================`);
55
- logger.info(`${sendingLabel(dryRun)} slack message to channel: ${reportSlackChannel}.\n\n${longMessage}`);
56
- logger.info(`=========================================`);
57
- if (!dryRun) {
58
- await slack.chat.postMessage({
59
- text: longMessage,
60
- channel: reportSlackChannel,
61
- });
62
- }
63
- }
64
- };
65
- export const sendSlackMessage = async (slack, channel, text, blocks) => {
22
+ // Slack's limits: 50 blocks per message, 3000 characters per section
23
+ const MAX_BLOCKS_PER_MESSAGE = 50;
24
+ const MAX_SECTION_LENGTH = 3000;
25
+ /** Posts `text`, with `details` as sections in its thread, as many replies as Slack's block limit needs. */
26
+ export const sendSlackMessage = async (slack, channel, text, details) => {
66
27
  const { ts } = await slack.chat.postMessage({ text, channel });
67
- if (blocks.length > 0 && ts) {
28
+ if (!ts)
29
+ return;
30
+ for (let i = 0; i < details.length; i += MAX_BLOCKS_PER_MESSAGE) {
31
+ const sections = details.slice(i, i + MAX_BLOCKS_PER_MESSAGE);
68
32
  await slack.chat.postMessage({
69
33
  channel,
70
34
  thread_ts: ts,
71
- blocks: blocks.map((t) => ({ text: { type: 'mrkdwn', text: t }, type: 'section' })),
35
+ text: sections.join('\n').slice(0, MAX_SECTION_LENGTH),
36
+ blocks: sections.map((t) => ({
37
+ text: {
38
+ type: 'mrkdwn',
39
+ text: t.length > MAX_SECTION_LENGTH ? `${t.slice(0, MAX_SECTION_LENGTH - 1)}…` : t,
40
+ },
41
+ type: 'section',
42
+ })),
72
43
  });
73
44
  }
74
45
  };
@@ -1 +1 @@
1
- {"version":3,"file":"slack.js","sourceRoot":"","sources":["../../bin/slack.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAavC;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;YACb,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,kBAAkB,CAAC;YACtD,MAAM,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBACzB,IAAI,EAAE;oBACF,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,kBAAkB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,kBAAkB,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;iBACrF;gBACD,IAAI,EAAE,SAAS;aAClB,CAAC,CAAC;SACN,CAAC,CAAC;IACP,CAAC;AACL,CAAC,CAAC"}
@@ -0,0 +1,79 @@
1
+ import z from 'zod';
2
+ export declare const readStdin: () => Promise<string>;
3
+ export declare const parseBuildInput: (raw: string) => {
4
+ actors: {
5
+ actorFullName: string;
6
+ }[];
7
+ };
8
+ /**
9
+ * What `test` reads: the Actors to test, each with the build to test or, without one, its default build. The builds
10
+ * `build` and `build-from-local` print fit, and so does `get-actor-configs`, whose other fields are ignored. An Actor
11
+ * needs its full name or its raw ID, `test` looks up the other. A dry-run plan is an object on purpose, so it is
12
+ * rejected here rather than tested as if it were built.
13
+ */
14
+ declare const testTargetsSchema: z.ZodArray<z.ZodObject<{
15
+ actorFullName: z.ZodOptional<z.ZodString>;
16
+ buildId: z.ZodOptional<z.ZodString>;
17
+ actorRawId: z.ZodOptional<z.ZodString>;
18
+ buildNumber: z.ZodOptional<z.ZodString>;
19
+ }, z.z.core.$strip>>;
20
+ export type TestTarget = z.infer<typeof testTargetsSchema>[number];
21
+ export declare const parseTestTargets: (raw: string) => {
22
+ actorFullName?: string | undefined;
23
+ buildId?: string | undefined;
24
+ actorRawId?: string | undefined;
25
+ buildNumber?: string | undefined;
26
+ }[];
27
+ declare const testReportSchema: z.ZodObject<{
28
+ kind: z.ZodLiteral<"test-report">;
29
+ version: z.ZodLiteral<1>;
30
+ success: z.ZodBoolean;
31
+ summary: z.ZodObject<{
32
+ total: z.ZodNumber;
33
+ passed: z.ZodNumber;
34
+ failed: z.ZodNumber;
35
+ skipped: z.ZodNumber;
36
+ }, z.z.core.$strip>;
37
+ tests: z.ZodArray<z.ZodObject<{
38
+ name: z.ZodString;
39
+ file: z.ZodString;
40
+ status: z.ZodEnum<{
41
+ passed: "passed";
42
+ failed: "failed";
43
+ skipped: "skipped";
44
+ }>;
45
+ durationMs: z.ZodNullable<z.ZodNumber>;
46
+ failureMessages: z.ZodArray<z.ZodString>;
47
+ run: z.ZodNullable<z.ZodObject<{
48
+ actorId: z.ZodString;
49
+ runId: z.ZodString;
50
+ runLink: z.ZodString;
51
+ }, z.z.core.$strip>>;
52
+ }, z.z.core.$strip>>;
53
+ errors: z.ZodArray<z.ZodString>;
54
+ }, z.z.core.$strip>;
55
+ /** The parts of a get-affected-actors document that describe what a release changed. Other fields are ignored. */
56
+ declare const releaseChangesSchema: z.ZodObject<{
57
+ commits: z.ZodArray<z.ZodObject<{
58
+ sha: z.ZodString;
59
+ author: z.ZodString;
60
+ date: z.ZodString;
61
+ message: z.ZodString;
62
+ }, z.z.core.$strip>>;
63
+ changelog: z.ZodNullable<z.ZodString>;
64
+ }, z.z.core.$strip>;
65
+ export type ReleaseChanges = z.infer<typeof releaseChangesSchema>;
66
+ export type NotifyInput = {
67
+ kind: 'tests';
68
+ report: z.infer<typeof testReportSchema>;
69
+ } | {
70
+ kind: 'release';
71
+ changes: ReleaseChanges;
72
+ };
73
+ /**
74
+ * What `notify` reads: a test run, as `test` reports it, or a release, as `get-affected-actors` reports it. The test
75
+ * report says so in its `kind`, a release is told by its `commits`, so either can be piped in as it is.
76
+ */
77
+ export declare const parseNotifyInput: (raw: string) => NotifyInput;
78
+ export {};
79
+ //# sourceMappingURL=stdin-input.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stdin-input.d.ts","sourceRoot":"","sources":["../../bin/stdin-input.ts"],"names":[],"mappings":"AAEA,OAAO,CAAkC,MAAM,KAAK,CAAC;AAErD,eAAO,MAAM,SAAS,QAAa,OAAO,CAAC,MAAM,CAUhD,CAAC;AAyCF,eAAO,MAAM,eAAe,GAAI,KAAK,MAAM;;;;CAIrC,CAAC;AAEP;;;;;GAKG;AACH,QAAA,MAAM,iBAAiB;;;;;oBAWtB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAWnE,eAAO,MAAM,gBAAgB,GAAI,KAAK,MAAM;;;;;GAQ3C,CAAC;AAIF,QAAA,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAgBpB,CAAC;AAEH,kHAAkH;AAClH,QAAA,MAAM,oBAAoB;;;;;;;;mBAGxB,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,MAAM,MAAM,WAAW,GACjB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA;CAAE,GAC3D;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,cAAc,CAAA;CAAE,CAAC;AAEnD;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAAI,KAAK,MAAM,KAAG,WAkB9C,CAAC"}
@@ -0,0 +1,124 @@
1
+ import process from 'node:process';
2
+ import z, { prettifyError } from 'zod';
3
+ export const readStdin = async () => {
4
+ // Nothing piped in: fail right away instead of waiting for someone to type
5
+ if (process.stdin.isTTY) {
6
+ throw new Error('Expected JSON on stdin, but nothing was piped in.');
7
+ }
8
+ let raw = '';
9
+ for await (const chunk of process.stdin) {
10
+ raw += chunk;
11
+ }
12
+ return raw;
13
+ };
14
+ const parseStdinJson = (raw, schema, { expected, example }) => {
15
+ // Empty input is an error, not "nothing to do": it is what a failed command earlier in the pipe leaves behind
16
+ if (!raw.trim()) {
17
+ throw new Error(`Expected ${expected} as JSON on stdin, got nothing (${example}).`);
18
+ }
19
+ let json;
20
+ try {
21
+ json = JSON.parse(raw);
22
+ }
23
+ catch (error) {
24
+ throw new Error(`The input on stdin is not valid JSON: ${error.message}`);
25
+ }
26
+ return validateStdinJson(json, schema, { expected, example });
27
+ };
28
+ const validateStdinJson = (json, schema, { expected, example }) => {
29
+ const result = schema.safeParse(json);
30
+ if (!result.success) {
31
+ throw new Error(`The input on stdin is not ${expected} (${example}):\n${prettifyError(result.error)}`);
32
+ }
33
+ return result.data;
34
+ };
35
+ /**
36
+ * What `build` reads: the Actors to build. Only their names are read, the config file stays the source of truth
37
+ * for everything else about them. Other fields are ignored, so a get-affected-actors document only needs its Actor
38
+ * list picked, e.g. `jq '{ actors: .functionallyChangedActors }'`.
39
+ */
40
+ const buildInputSchema = z.object({
41
+ actors: z.array(z.object({ actorFullName: z.string() })),
42
+ });
43
+ export const parseBuildInput = (raw) => parseStdinJson(raw, buildInputSchema, {
44
+ expected: 'the Actors to build',
45
+ example: `e.g. echo '{"actors":[{"actorFullName":"owner/name"}]}' | apify-test-tools build --version-number 0.1`,
46
+ });
47
+ /**
48
+ * What `test` reads: the Actors to test, each with the build to test or, without one, its default build. The builds
49
+ * `build` and `build-from-local` print fit, and so does `get-actor-configs`, whose other fields are ignored. An Actor
50
+ * needs its full name or its raw ID, `test` looks up the other. A dry-run plan is an object on purpose, so it is
51
+ * rejected here rather than tested as if it were built.
52
+ */
53
+ const testTargetsSchema = z.array(z
54
+ .object({
55
+ actorFullName: z.string().optional(),
56
+ buildId: z.string().optional(),
57
+ actorRawId: z.string().optional(),
58
+ buildNumber: z.string().optional(),
59
+ })
60
+ .refine(({ actorFullName, actorRawId }) => !!actorFullName || !!actorRawId, {
61
+ message: 'An Actor needs actorFullName or actorRawId',
62
+ }));
63
+ const isDryRunPlan = (raw) => {
64
+ try {
65
+ return JSON.parse(raw)?.dryRun === true;
66
+ }
67
+ catch {
68
+ // Not JSON at all, parseStdinJson says so
69
+ return false;
70
+ }
71
+ };
72
+ export const parseTestTargets = (raw) => {
73
+ const example = 'e.g. ... | apify-test-tools build --version-number 0.99 | apify-test-tools test, ' +
74
+ "or apify-test-tools get-actor-configs | apify-test-tools test for every Actor's default build";
75
+ if (isDryRunPlan(raw)) {
76
+ throw new Error(`The input on stdin is a dry-run plan, not builds, so there is nothing to test (${example}).`);
77
+ }
78
+ return parseStdinJson(raw, testTargetsSchema, { expected: 'the Actors to test', example });
79
+ };
80
+ /** The report `test` prints, see TestReport. */
81
+ const testRunSchema = z.object({ actorId: z.string(), runId: z.string(), runLink: z.string() });
82
+ const testReportSchema = z.object({
83
+ kind: z.literal('test-report'),
84
+ version: z.literal(1),
85
+ success: z.boolean(),
86
+ summary: z.object({ total: z.number(), passed: z.number(), failed: z.number(), skipped: z.number() }),
87
+ tests: z.array(z.object({
88
+ name: z.string(),
89
+ file: z.string(),
90
+ status: z.enum(['passed', 'failed', 'skipped']),
91
+ durationMs: z.number().nullable(),
92
+ failureMessages: z.array(z.string()),
93
+ run: testRunSchema.nullable(),
94
+ })),
95
+ errors: z.array(z.string()),
96
+ });
97
+ /** The parts of a get-affected-actors document that describe what a release changed. Other fields are ignored. */
98
+ const releaseChangesSchema = z.object({
99
+ commits: z.array(z.object({ sha: z.string(), author: z.string(), date: z.string(), message: z.string() })),
100
+ changelog: z.string().nullable(),
101
+ });
102
+ /**
103
+ * What `notify` reads: a test run, as `test` reports it, or a release, as `get-affected-actors` reports it. The test
104
+ * report says so in its `kind`, a release is told by its `commits`, so either can be piped in as it is.
105
+ */
106
+ export const parseNotifyInput = (raw) => {
107
+ const example = 'e.g. ... | apify-test-tools test | apify-test-tools notify --slack-channel "#my-channel", ' +
108
+ 'or apify-test-tools get-affected-actors --since <sha> | apify-test-tools notify --slack-channel "#my-channel"';
109
+ const expected = 'the output of test or get-affected-actors';
110
+ const json = parseStdinJson(raw, z.looseObject({}), { expected, example });
111
+ if (json.kind === 'test-report') {
112
+ const report = validateStdinJson(json, testReportSchema, { expected: 'the output of test', example });
113
+ return { kind: 'tests', report };
114
+ }
115
+ if ('commits' in json) {
116
+ const changes = validateStdinJson(json, releaseChangesSchema, {
117
+ expected: 'the output of get-affected-actors',
118
+ example,
119
+ });
120
+ return { kind: 'release', changes };
121
+ }
122
+ throw new Error(`The input on stdin is not ${expected} (${example}).`);
123
+ };
124
+ //# sourceMappingURL=stdin-input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stdin-input.js","sourceRoot":"","sources":["../../bin/stdin-input.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,OAAO,CAAC,EAAE,EAAE,aAAa,EAAgB,MAAM,KAAK,CAAC;AAErD,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,IAAqB,EAAE;IACjD,2EAA2E;IAC3E,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACzE,CAAC;IACD,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;QACtC,GAAG,IAAI,KAAK,CAAC;IACjB,CAAC;IACD,OAAO,GAAG,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,CACnB,GAAW,EACX,MAAkB,EAClB,EAAE,QAAQ,EAAE,OAAO,EAAyC,EAC9D,EAAE;IACA,8GAA8G;IAC9G,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,YAAY,QAAQ,mCAAmC,OAAO,IAAI,CAAC,CAAC;IACxF,CAAC;IACD,IAAI,IAAa,CAAC;IAClB,IAAI,CAAC;QACD,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,G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C,QAAQ,EAAE;CACnC,CAAC,CAAC;AAQH;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,GAAW,EAAe,EAAE;IACzD,MAAM,OAAO,GACT,4FAA4F;QAC5F,+GAA+G,CAAC;IACpH,MAAM,QAAQ,GAAG,2CAA2C,CAAC;IAC7D,MAAM,IAAI,GAAG,cAAc,CAAC,GAAG,EAAE,CAAC,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;IAC3E,IAAI,IAAI,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;QAC9B,MAAM,MAAM,GAAG,iBAAiB,CAAC,IAAI,EAAE,gBAAgB,EAAE,EAAE,QAAQ,EAAE,oBAAoB,EAAE,OAAO,EAAE,CAAC,CAAC;QACtG,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IACrC,CAAC;IACD,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;QACpB,MAAM,OAAO,GAAG,iBAAiB,CAAC,IAAI,EAAE,oBAAoB,EAAE;YAC1D,QAAQ,EAAE,mCAAmC;YAC7C,OAAO;SACV,CAAC,CAAC;QACH,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;IACxC,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,6BAA6B,QAAQ,KAAK,OAAO,IAAI,CAAC,CAAC;AAC3E,CAAC,CAAC"}
@@ -0,0 +1,18 @@
1
+ /** Tells whether a repo-root-relative path matches the glob. Without a glob, nothing matches. */
2
+ export declare const createTestFilesMatcher: (glob?: string) => ((filePath: string) => boolean);
3
+ interface ResolvedTestFiles {
4
+ /** Every file the glob matches, as repo-root-relative POSIX paths, sorted */
5
+ files: string[];
6
+ /**
7
+ * The same files as few paths as possible: directories (ending with `/`) that hold only matched files, and the
8
+ * other matched files one by one. Sorted.
9
+ */
10
+ paths: string[];
11
+ }
12
+ /**
13
+ * Finds the files the glob matches. `cwd` is the repo root. Only the glob's static base (`test/platform` for
14
+ * `test/platform/{daily,hourly}/**`) is walked.
15
+ */
16
+ export declare const resolveTestFilesGlob: (glob: string, cwd: string) => Promise<ResolvedTestFiles>;
17
+ export {};
18
+ //# sourceMappingURL=test-files-glob.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-files-glob.d.ts","sourceRoot":"","sources":["../../bin/test-files-glob.ts"],"names":[],"mappings":"AAoBA,iGAAiG;AACjG,eAAO,MAAM,sBAAsB,GAAI,OAAO,MAAM,KAAG,CAAC,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAMpF,CAAC;AA6EF,UAAU,iBAAiB;IACvB,6EAA6E;IAC7E,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB;;;OAGG;IACH,KAAK,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAAU,MAAM,MAAM,EAAE,KAAK,MAAM,KAAG,OAAO,CAAC,iBAAiB,CAO/F,CAAC"}