apify-test-tools 0.10.2-beta.1 → 0.10.2-beta.11

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 (189) hide show
  1. package/.gitattributes +2 -0
  2. package/.github/actionlint.yaml +11 -0
  3. package/.github/actions/checkout-restore-dependencies/action.yaml +64 -28
  4. package/.github/cli/apify-test-tools.mjs +360 -0
  5. package/.github/scripts/mask-config-secrets.sh +17 -0
  6. package/.github/scripts/run-with-apify-tokens.mjs +37 -12
  7. package/.github/workflows/_check_code.yaml +25 -16
  8. package/.github/workflows/_move_major_tag.yaml +5 -83
  9. package/.github/workflows/_tests.yaml +34 -0
  10. package/.github/workflows/_update_release_metadata.yaml +0 -12
  11. package/.github/workflows/manual_move_major_tag.yaml +3 -3
  12. package/.github/workflows/manual_release_stable.yaml +3 -13
  13. package/.github/workflows/on_master.yaml +9 -5
  14. package/.github/workflows/on_pull_request.yaml +3 -48
  15. package/.github/workflows/public_platform-tests-claude-investigate-and-fix.yaml +16 -3
  16. package/.github/workflows/public_platform-tests.yaml +27 -3
  17. package/.github/workflows/public_pr-build-test.yaml +67 -29
  18. package/.github/workflows/public_push-build-latest.yaml +44 -10
  19. package/.github/workflows/public_review.yaml +5 -4
  20. package/.husky/pre-commit +5 -0
  21. package/.prettierignore +3 -0
  22. package/CHANGELOG.md +17 -0
  23. package/CONTRIBUTING.md +112 -24
  24. package/README.md +218 -600
  25. package/bin/affected-actors.ts +198 -0
  26. package/bin/build-from-local.ts +65 -13
  27. package/bin/build.ts +123 -41
  28. package/bin/diff-changes.ts +32 -23
  29. package/bin/diff-json-schema.ts +5 -6
  30. package/bin/git.ts +69 -99
  31. package/bin/main.ts +96 -135
  32. package/bin/slack.ts +43 -10
  33. package/bin/stdin-input.ts +65 -0
  34. package/bin/test-report.ts +6 -9
  35. package/bin/types.ts +15 -0
  36. package/dist/bin/affected-actors.d.ts +46 -0
  37. package/dist/bin/affected-actors.d.ts.map +1 -0
  38. package/dist/bin/affected-actors.js +135 -0
  39. package/dist/bin/affected-actors.js.map +1 -0
  40. package/dist/bin/build-from-local.d.ts +12 -3
  41. package/dist/bin/build-from-local.d.ts.map +1 -1
  42. package/dist/bin/build-from-local.js +34 -12
  43. package/dist/bin/build-from-local.js.map +1 -1
  44. package/dist/bin/build.d.ts +30 -7
  45. package/dist/bin/build.d.ts.map +1 -1
  46. package/dist/bin/build.js +85 -26
  47. package/dist/bin/build.js.map +1 -1
  48. package/dist/bin/diff-changes.d.ts +11 -4
  49. package/dist/bin/diff-changes.d.ts.map +1 -1
  50. package/dist/bin/diff-changes.js +19 -19
  51. package/dist/bin/diff-changes.js.map +1 -1
  52. package/dist/bin/diff-json-schema.d.ts +2 -2
  53. package/dist/bin/diff-json-schema.d.ts.map +1 -1
  54. package/dist/bin/diff-json-schema.js +1 -4
  55. package/dist/bin/diff-json-schema.js.map +1 -1
  56. package/dist/bin/git.d.ts +23 -21
  57. package/dist/bin/git.d.ts.map +1 -1
  58. package/dist/bin/git.js +60 -83
  59. package/dist/bin/git.js.map +1 -1
  60. package/dist/bin/main.js +82 -105
  61. package/dist/bin/main.js.map +1 -1
  62. package/dist/bin/slack.d.ts +14 -4
  63. package/dist/bin/slack.d.ts.map +1 -1
  64. package/dist/bin/slack.js +39 -6
  65. package/dist/bin/slack.js.map +1 -1
  66. package/dist/bin/stdin-input.d.ts +17 -0
  67. package/dist/bin/stdin-input.d.ts.map +1 -0
  68. package/dist/bin/stdin-input.js +54 -0
  69. package/dist/bin/stdin-input.js.map +1 -0
  70. package/dist/bin/test-report.d.ts.map +1 -1
  71. package/dist/bin/test-report.js +6 -8
  72. package/dist/bin/test-report.js.map +1 -1
  73. package/dist/bin/types.d.ts +13 -0
  74. package/dist/bin/types.d.ts.map +1 -1
  75. package/dist/lib/extend-expect.d.ts.map +1 -1
  76. package/dist/lib/extend-expect.js +37 -218
  77. package/dist/lib/extend-expect.js.map +1 -1
  78. package/dist/lib/lib.d.ts +1 -2
  79. package/dist/lib/lib.d.ts.map +1 -1
  80. package/dist/lib/lib.js +15 -22
  81. package/dist/lib/lib.js.map +1 -1
  82. package/dist/lib/run-checks.d.ts +14 -0
  83. package/dist/lib/run-checks.d.ts.map +1 -0
  84. package/dist/lib/run-checks.js +82 -0
  85. package/dist/lib/run-checks.js.map +1 -0
  86. package/dist/lib/run-test-result.d.ts +3 -6
  87. package/dist/lib/run-test-result.d.ts.map +1 -1
  88. package/dist/lib/run-test-result.js +41 -54
  89. package/dist/lib/run-test-result.js.map +1 -1
  90. package/dist/test/bundle/cli-bundle.test.d.ts +2 -0
  91. package/dist/test/bundle/cli-bundle.test.d.ts.map +1 -0
  92. package/dist/test/bundle/cli-bundle.test.js +190 -0
  93. package/dist/test/bundle/cli-bundle.test.js.map +1 -0
  94. package/dist/test/e2e/cli-bundle.e2e.test.d.ts +2 -0
  95. package/dist/test/e2e/cli-bundle.e2e.test.d.ts.map +1 -0
  96. package/dist/test/e2e/cli-bundle.e2e.test.js +138 -0
  97. package/dist/test/e2e/cli-bundle.e2e.test.js.map +1 -0
  98. package/dist/test/e2e/git-build-release.e2e.test.d.ts +2 -0
  99. package/dist/test/e2e/git-build-release.e2e.test.d.ts.map +1 -0
  100. package/dist/test/e2e/git-build-release.e2e.test.js +87 -0
  101. package/dist/test/e2e/git-build-release.e2e.test.js.map +1 -0
  102. package/dist/test/e2e/helpers.d.ts +37 -0
  103. package/dist/test/e2e/helpers.d.ts.map +1 -0
  104. package/dist/test/e2e/helpers.js +57 -0
  105. package/dist/test/e2e/helpers.js.map +1 -0
  106. package/dist/test/unit/bin/affected-actors-cli.test.d.ts +2 -0
  107. package/dist/test/unit/bin/affected-actors-cli.test.d.ts.map +1 -0
  108. package/dist/test/unit/bin/affected-actors-cli.test.js +167 -0
  109. package/dist/test/unit/bin/affected-actors-cli.test.js.map +1 -0
  110. package/dist/test/unit/bin/affected-actors.test.d.ts +2 -0
  111. package/dist/test/unit/bin/affected-actors.test.d.ts.map +1 -0
  112. package/dist/test/unit/bin/affected-actors.test.js +141 -0
  113. package/dist/test/unit/bin/affected-actors.test.js.map +1 -0
  114. package/dist/test/unit/bin/build-cli.test.d.ts +2 -0
  115. package/dist/test/unit/bin/build-cli.test.d.ts.map +1 -0
  116. package/dist/test/unit/bin/build-cli.test.js +44 -0
  117. package/dist/test/unit/bin/build-cli.test.js.map +1 -0
  118. package/dist/test/unit/bin/build-from-local.test.js +65 -1
  119. package/dist/test/unit/bin/build-from-local.test.js.map +1 -1
  120. package/dist/test/unit/bin/build.test.js +223 -3
  121. package/dist/test/unit/bin/build.test.js.map +1 -1
  122. package/dist/test/unit/bin/compiled-cli.d.ts +6 -0
  123. package/dist/test/unit/bin/compiled-cli.d.ts.map +1 -0
  124. package/dist/test/unit/bin/compiled-cli.js +16 -0
  125. package/dist/test/unit/bin/compiled-cli.js.map +1 -0
  126. package/dist/test/unit/bin/diff-changes.test.js +130 -101
  127. package/dist/test/unit/bin/diff-changes.test.js.map +1 -1
  128. package/dist/test/unit/bin/diff.test.js +25 -28
  129. package/dist/test/unit/bin/diff.test.js.map +1 -1
  130. package/dist/test/unit/bin/git.test.js +69 -152
  131. package/dist/test/unit/bin/git.test.js.map +1 -1
  132. package/dist/test/unit/bin/slack.test.d.ts +2 -0
  133. package/dist/test/unit/bin/slack.test.d.ts.map +1 -0
  134. package/dist/test/unit/bin/slack.test.js +71 -0
  135. package/dist/test/unit/bin/slack.test.js.map +1 -0
  136. package/dist/test/unit/bin/stdin-input.test.d.ts +2 -0
  137. package/dist/test/unit/bin/stdin-input.test.d.ts.map +1 -0
  138. package/dist/test/unit/bin/stdin-input.test.js +50 -0
  139. package/dist/test/unit/bin/stdin-input.test.js.map +1 -0
  140. package/dist/test/unit/github-scripts/mask-config-secrets.test.d.ts +2 -0
  141. package/dist/test/unit/github-scripts/mask-config-secrets.test.d.ts.map +1 -0
  142. package/dist/test/unit/github-scripts/mask-config-secrets.test.js +50 -0
  143. package/dist/test/unit/github-scripts/mask-config-secrets.test.js.map +1 -0
  144. package/dist/test/unit/github-scripts/run-with-apify-tokens.test.d.ts +2 -0
  145. package/dist/test/unit/github-scripts/run-with-apify-tokens.test.d.ts.map +1 -0
  146. package/dist/test/unit/github-scripts/run-with-apify-tokens.test.js +102 -0
  147. package/dist/test/unit/github-scripts/run-with-apify-tokens.test.js.map +1 -0
  148. package/dist/test/unit/run-checks.test.d.ts +2 -0
  149. package/dist/test/unit/run-checks.test.d.ts.map +1 -0
  150. package/dist/test/unit/run-checks.test.js +62 -0
  151. package/dist/test/unit/run-checks.test.js.map +1 -0
  152. package/dist/test/unit/run-test-result.test.d.ts +2 -0
  153. package/dist/test/unit/run-test-result.test.d.ts.map +1 -0
  154. package/dist/test/unit/run-test-result.test.js +34 -0
  155. package/dist/test/unit/run-test-result.test.js.map +1 -0
  156. package/dist/test/unit/should-built-and-test.test.js +41 -38
  157. package/dist/test/unit/should-built-and-test.test.js.map +1 -1
  158. package/dist/tsconfig.tsbuildinfo +1 -1
  159. package/docs/cli.md +373 -0
  160. package/docs/lib.md +271 -0
  161. package/docs/workflows.md +370 -0
  162. package/lib/extend-expect.ts +48 -258
  163. package/lib/lib.ts +24 -28
  164. package/lib/run-checks.ts +101 -0
  165. package/lib/run-test-result.ts +45 -55
  166. package/package.json +13 -3
  167. package/test/bundle/cli-bundle.test.ts +235 -0
  168. package/test/e2e/cli-bundle.e2e.test.ts +207 -0
  169. package/test/e2e/git-build-release.e2e.test.ts +113 -0
  170. package/test/e2e/helpers.ts +82 -0
  171. package/test/unit/bin/affected-actors-cli.test.ts +201 -0
  172. package/test/unit/bin/affected-actors.test.ts +182 -0
  173. package/test/unit/bin/build-cli.test.ts +55 -0
  174. package/test/unit/bin/build-from-local.test.ts +71 -0
  175. package/test/unit/bin/build.test.ts +279 -3
  176. package/test/unit/bin/compiled-cli.ts +17 -0
  177. package/test/unit/bin/diff-changes.test.ts +139 -101
  178. package/test/unit/bin/diff.test.ts +25 -28
  179. package/test/unit/bin/git.test.ts +85 -176
  180. package/test/unit/bin/slack.test.ts +84 -0
  181. package/test/unit/bin/stdin-input.test.ts +61 -0
  182. package/test/unit/github-scripts/mask-config-secrets.test.ts +61 -0
  183. package/test/unit/github-scripts/run-with-apify-tokens.test.ts +115 -0
  184. package/test/unit/run-checks.test.ts +76 -0
  185. package/test/unit/run-test-result.test.ts +44 -0
  186. package/test/unit/should-built-and-test.test.ts +46 -39
  187. package/.github/scripts/check-major-tag-refs.mjs +0 -72
  188. package/.github/scripts/check-package-version-bump.mjs +0 -74
  189. package/.github/workflows-package-version +0 -1
package/.gitattributes ADDED
@@ -0,0 +1,2 @@
1
+ # Generated by `npm run bundle`: collapsed in GitHub diffs and shown as binary by git diff.
2
+ .github/cli/apify-test-tools.mjs linguist-generated=true -diff
@@ -10,3 +10,14 @@ paths:
10
10
  ignore:
11
11
  - 'input "display_report" is not defined in action "anthropics/claude-code-action@v1"'
12
12
  - 'property "conclusion" is not defined in object type'
13
+
14
+ # actionlint (v1.7.11, and v1.7.12 too) predates two newer GitHub features these workflows rely on:
15
+ # - `uses: $/path`, the self-repository syntax: this repo at the commit the workflow runs at.
16
+ # actionlint only knows `./path`, `docker://` and `owner/repo@ref`, so it reports the ref as missing.
17
+ # https://github.blog/changelog/2026-07-30-reference-same-repository-actions-with-self-repository-syntax/
18
+ # - `job.workflow_repository` and `job.workflow_sha`, the reusable workflow's own repo and commit.
19
+ # https://docs.github.com/en/actions/reference/workflows-and-actions/contexts#job-context
20
+ .github/workflows/public_*.yaml:
21
+ ignore:
22
+ - 'specifying action "\$/[^"]*" in invalid format because ref is missing'
23
+ - 'property "workflow_(repository|sha)" is not defined in object type'
@@ -8,6 +8,11 @@ inputs:
8
8
  generated .npmrc references), and only on the dependency install steps, so it
9
9
  never reaches the build or test steps. Use a read-only token.
10
10
  required: false
11
+ config-secrets:
12
+ description: >-
13
+ The CONFIG_SECRETS workflow secret, if the caller passed one. Every value inside it is
14
+ registered as a mask, see .github/scripts/mask-config-secrets.sh.
15
+ required: false
11
16
 
12
17
  outputs:
13
18
  scripts-path:
@@ -18,12 +23,19 @@ outputs:
18
23
  value: ${{ steps.scripts-path.outputs.path }}
19
24
 
20
25
  # Sets common steps and ensure we use cached node_modules
21
- # To test a change here, repoint the `uses:` refs in the reusable workflows at your branch, and
22
- # change them back before merging. Merging to master no longer ships it: consumers track the `workflows-v0`
23
- # tag, which only moves once the package version in .github/workflows-package-version is on npm.
26
+ # The reusable workflows load this with `uses: $/...`, which resolves to the same commit as the
27
+ # workflow itself, so testing a change here only needs the caller pointed at your branch.
24
28
  runs:
25
29
  using: 'composite'
26
30
  steps:
31
+ # Runs before anything can use a packed secret, see the script for why.
32
+ - name: Mask config secrets
33
+ if: inputs.config-secrets != ''
34
+ shell: bash
35
+ env:
36
+ CONFIG_SECRETS: ${{ inputs.config-secrets }}
37
+ run: bash "${{ github.action_path }}/../../scripts/mask-config-secrets.sh"
38
+
27
39
  - name: Checkout Repository
28
40
  uses: actions/checkout@v5
29
41
  with:
@@ -49,7 +61,24 @@ runs:
49
61
  shell: bash
50
62
  run: echo "path=$(cd "${{ github.action_path }}/../../scripts" && pwd)" >> "$GITHUB_OUTPUT"
51
63
 
64
+ # A repo is on pnpm when it has a pnpm-lock.yaml and no package-lock.json.
65
+ - name: Detect package manager
66
+ id: package-manager
67
+ shell: bash
68
+ run: |
69
+ if [ -f pnpm-lock.yaml ] && [ ! -f package-lock.json ]; then
70
+ echo "name=pnpm" >> "$GITHUB_OUTPUT"
71
+ else
72
+ echo "name=npm" >> "$GITHUB_OUTPUT"
73
+ fi
74
+
75
+ # Takes the pnpm version from the `packageManager` field of the repo's package.json.
76
+ - name: Install pnpm
77
+ if: steps.package-manager.outputs.name == 'pnpm'
78
+ uses: pnpm/action-setup@v6
79
+
52
80
  - name: Cache dependencies npm
81
+ if: steps.package-manager.outputs.name == 'npm'
53
82
  id: check-dependencies-cache
54
83
  uses: actions/cache@v5
55
84
  with:
@@ -57,39 +86,46 @@ runs:
57
86
  key: modules-npm-${{ hashFiles('package-lock.json') }}
58
87
 
59
88
  - name: install npm dependencies
60
- if: steps.check-dependencies-cache.outputs.cache-hit != 'true'
89
+ if: steps.package-manager.outputs.name == 'npm' && steps.check-dependencies-cache.outputs.cache-hit != 'true'
61
90
  shell: bash
62
91
  env:
63
92
  NPM_TOKEN: ${{ inputs.npm-token }}
64
93
  NODE_AUTH_TOKEN: ${{ inputs.npm-token }}
65
94
  run: npm ci
66
95
 
67
- # Repos can still have older version locally but on cloud we enforce uniformity.
68
- # --no-save swaps the package in node_modules only and leaves the repo's package.json and
69
- # package-lock.json untouched, so node_modules is ahead of the lockfile but the checkout stays clean.
70
- - name: Enforce test tools version required by these workflows
71
- # We don't override beta so we can use it to test branch-specific versions of apify-test-tools
72
- # Needs the npm token too: a repo whose .npmrc routes all traffic through a private
73
- # registry has to authenticate even for public packages.
96
+ # Caching node_modules would miss each workspace package's own node_modules, so we cache the
97
+ # store and always install; with a warm store that only links files.
98
+ - name: Resolve pnpm store path
99
+ if: steps.package-manager.outputs.name == 'pnpm'
100
+ id: pnpm-store
101
+ shell: bash
102
+ run: echo "path=$(pnpm store path --silent)" >> "$GITHUB_OUTPUT"
103
+
104
+ - name: Cache pnpm store
105
+ if: steps.package-manager.outputs.name == 'pnpm'
106
+ uses: actions/cache@v5
107
+ with:
108
+ path: ${{ steps.pnpm-store.outputs.path }}
109
+ key: pnpm-store-${{ hashFiles('pnpm-lock.yaml') }}
110
+
111
+ - name: install pnpm dependencies
112
+ if: steps.package-manager.outputs.name == 'pnpm'
74
113
  shell: bash
75
114
  env:
76
115
  NPM_TOKEN: ${{ inputs.npm-token }}
77
116
  NODE_AUTH_TOKEN: ${{ inputs.npm-token }}
117
+ run: pnpm install --frozen-lockfile
118
+
119
+ # The CLI the workflows call ships with this action as one bundled file (npm run bundle), so
120
+ # nothing is installed for it. The repo's node_modules stays exactly what its lockfile says,
121
+ # and its tests import the lib from the version they locked.
122
+ # Steps call `apify-test-tools` without npx: npx would pick the repo's own copy in node_modules/.bin first.
123
+ - name: Put apify-test-tools CLI on PATH
124
+ shell: bash
78
125
  run: |
79
- locked_version=$(jq -r '.packages["node_modules/apify-test-tools"].version' package-lock.json)
80
- echo "Package-lock version of apify-test-tools: $locked_version"
81
- if [[ "$locked_version" == *"-beta"* ]]; then
82
- echo "Beta version detected, reinstalling $locked_version to ensure cache consistency"
83
- npm install "apify-test-tools@$locked_version" --no-save --audit=false --no-fund;
84
- else
85
- # The workflows name the exact package version they ship with, so a tag is a complete
86
- # statement: these workflows and this library. A frozen major tag then keeps
87
- # installing what it was tested against however far the package moves on. A `>=`
88
- # floor could not do that — being open-ended, it resolves to the newest release
89
- # forever, so freezing the tag would freeze the workflow files but not their
90
- # dependency. The stable release writes this file, so it always names a published
91
- # version; the release that publishes X is the commit that pins X.
92
- pinned_version=$(cat "${{ github.action_path }}/../../workflows-package-version")
93
- echo "Installing apify-test-tools@$pinned_version (pinned by these workflows)"
94
- npm install "apify-test-tools@$pinned_version" --no-save --audit=false --no-fund;
95
- fi
126
+ bundle="$(cd "${{ github.action_path }}/../../cli" && pwd)/apify-test-tools.mjs"
127
+ bin_dir="$RUNNER_TEMP/apify-test-tools-bin"
128
+ mkdir -p "$bin_dir"
129
+ printf '#!/bin/sh\nexec node --no-warnings "%s" "$@"\n' "$bundle" > "$bin_dir/apify-test-tools"
130
+ chmod +x "$bin_dir/apify-test-tools"
131
+ echo "$bin_dir" >> "$GITHUB_PATH"