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

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 (78) hide show
  1. package/.gitattributes +2 -0
  2. package/.github/actions/checkout-restore-dependencies/action.yaml +13 -29
  3. package/.github/cli/apify-test-tools.mjs +362 -0
  4. package/.github/scripts/run-with-apify-tokens.mjs +2 -2
  5. package/.github/workflows/_check_code.yaml +25 -0
  6. package/.github/workflows/_move_major_tag.yaml +3 -81
  7. package/.github/workflows/_tests.yaml +34 -0
  8. package/.github/workflows/_update_release_metadata.yaml +0 -12
  9. package/.github/workflows/manual_move_major_tag.yaml +3 -3
  10. package/.github/workflows/manual_release_stable.yaml +3 -13
  11. package/.github/workflows/on_master.yaml +9 -5
  12. package/.github/workflows/on_pull_request.yaml +3 -48
  13. package/.github/workflows/public_platform-tests.yaml +1 -1
  14. package/.github/workflows/public_pr-build-test.yaml +5 -28
  15. package/.github/workflows/public_push-build-latest.yaml +2 -2
  16. package/.husky/pre-commit +5 -0
  17. package/.prettierignore +3 -0
  18. package/CHANGELOG.md +5 -0
  19. package/CONTRIBUTING.md +8 -18
  20. package/README.md +40 -42
  21. package/bin/build-from-local.ts +47 -13
  22. package/bin/build.ts +35 -19
  23. package/bin/diff-changes.ts +24 -3
  24. package/bin/main.ts +35 -7
  25. package/bin/slack.ts +28 -6
  26. package/bin/test-report.ts +6 -9
  27. package/bin/types.ts +10 -0
  28. package/dist/bin/build-from-local.d.ts +10 -2
  29. package/dist/bin/build-from-local.d.ts.map +1 -1
  30. package/dist/bin/build-from-local.js +29 -11
  31. package/dist/bin/build-from-local.js.map +1 -1
  32. package/dist/bin/build.d.ts +15 -5
  33. package/dist/bin/build.d.ts.map +1 -1
  34. package/dist/bin/build.js +24 -15
  35. package/dist/bin/build.js.map +1 -1
  36. package/dist/bin/diff-changes.d.ts +2 -1
  37. package/dist/bin/diff-changes.d.ts.map +1 -1
  38. package/dist/bin/diff-changes.js +16 -5
  39. package/dist/bin/diff-changes.js.map +1 -1
  40. package/dist/bin/main.js +32 -6
  41. package/dist/bin/main.js.map +1 -1
  42. package/dist/bin/slack.d.ts +8 -1
  43. package/dist/bin/slack.d.ts.map +1 -1
  44. package/dist/bin/slack.js +26 -5
  45. package/dist/bin/slack.js.map +1 -1
  46. package/dist/bin/test-report.d.ts.map +1 -1
  47. package/dist/bin/test-report.js +6 -8
  48. package/dist/bin/test-report.js.map +1 -1
  49. package/dist/bin/types.d.ts +9 -0
  50. package/dist/bin/types.d.ts.map +1 -1
  51. package/dist/test/bundle/cli-bundle.test.d.ts +2 -0
  52. package/dist/test/bundle/cli-bundle.test.d.ts.map +1 -0
  53. package/dist/test/bundle/cli-bundle.test.js +162 -0
  54. package/dist/test/bundle/cli-bundle.test.js.map +1 -0
  55. package/dist/test/e2e/cli-bundle.e2e.test.d.ts +2 -0
  56. package/dist/test/e2e/cli-bundle.e2e.test.d.ts.map +1 -0
  57. package/dist/test/e2e/cli-bundle.e2e.test.js +172 -0
  58. package/dist/test/e2e/cli-bundle.e2e.test.js.map +1 -0
  59. package/dist/test/unit/bin/build-from-local.test.js +53 -1
  60. package/dist/test/unit/bin/build-from-local.test.js.map +1 -1
  61. package/dist/test/unit/bin/build.test.js +113 -3
  62. package/dist/test/unit/bin/build.test.js.map +1 -1
  63. package/dist/test/unit/bin/diff-changes.test.js +91 -0
  64. package/dist/test/unit/bin/diff-changes.test.js.map +1 -1
  65. package/dist/test/unit/bin/slack.test.d.ts +2 -0
  66. package/dist/test/unit/bin/slack.test.d.ts.map +1 -0
  67. package/dist/test/unit/bin/slack.test.js +54 -0
  68. package/dist/test/unit/bin/slack.test.js.map +1 -0
  69. package/dist/tsconfig.tsbuildinfo +1 -1
  70. package/package.json +15 -3
  71. package/test/bundle/cli-bundle.test.ts +192 -0
  72. package/test/e2e/cli-bundle.e2e.test.ts +237 -0
  73. package/test/unit/bin/build-from-local.test.ts +55 -0
  74. package/test/unit/bin/build.test.ts +135 -3
  75. package/test/unit/bin/diff-changes.test.ts +106 -0
  76. package/test/unit/bin/slack.test.ts +65 -0
  77. package/.github/scripts/check-package-version-bump.mjs +0 -74
  78. package/.github/workflows-package-version +0 -1
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
  // Runs apify-test-tools and passes it only secrets needed for the Actors, no other secrets are leaked.
3
3
  //
4
- // node .github/scripts/run-with-apify-tokens.mjs npx apify-test-tools build --target-branch ...
4
+ // node .github/scripts/run-with-apify-tokens.mjs apify-test-tools build --target-branch ...
5
5
  //
6
6
  // The step passes the whole secrets map as ALL_SECRETS. The token names come from `tokenEnvVar` in
7
7
  // the repo's apify-test-tools.config.json, which is the same file apify-test-tools itself reads, so
8
8
  // the two can't drift. Everything else in the secrets map (npm, Slack, GitHub, anything else the
9
- // repo holds) is left out, and ALL_SECRETS itself is dropped, so the blob never reaches npx or
9
+ // repo holds) is left out, and ALL_SECRETS itself is dropped, so the blob never reaches the CLI or
10
10
  // anything under node_modules.
11
11
  //
12
12
  // The command runs without a shell, so branch names and other interpolated arguments are passed
@@ -92,3 +92,28 @@ jobs:
92
92
  run: npm ci
93
93
  - name: Build
94
94
  run: npm run build
95
+
96
+ # The composite action runs the CLI from .github/cli/apify-test-tools.mjs, which the pre-commit
97
+ # hook rebuilds. This catches commits that skipped the hook, so a stale bundle never ships.
98
+ cli_bundle:
99
+ name: CLI bundle
100
+ runs-on: ubuntu-latest
101
+ steps:
102
+ - name: Checkout repository
103
+ uses: actions/checkout@v6
104
+ - name: Use Node.js
105
+ uses: actions/setup-node@v6
106
+ with:
107
+ node-version: 24
108
+ cache: 'npm'
109
+ cache-dependency-path: 'package-lock.json'
110
+ - name: Install dependencies
111
+ run: npm ci
112
+ - name: Check the bundle is up to date
113
+ run: |
114
+ npm run bundle
115
+ if ! git diff --quiet -- .github/cli/; then
116
+ echo "::error::.github/cli/apify-test-tools.mjs is out of date. Run \`npm run bundle\` and commit the result."
117
+ exit 1
118
+ fi
119
+ node .github/cli/apify-test-tools.mjs --help > /dev/null
@@ -1,13 +1,8 @@
1
1
  name: Move major version tag
2
2
 
3
- # Consumer repos track a floating major tag (`...@v0`), not `master`, so merging to master does not
4
- # ship anything by itself. This workflow is what ships: it moves that tag forward, but only once the
5
- # package version the workflows pin in .github/workflows-package-version is actually on npm.
6
- #
7
- # That gate is the whole point. The workflows and the npm package release on their own schedules, so
8
- # the only combination that can break consumers is a workflow that calls a CLI feature which has not
9
- # been published yet. In that case the tag simply stays where it is and production keeps running the
10
- # previous workflows until someone cuts a release.
3
+ # Consumer repos track a floating major tag (`...@workflows-v0`), not `master`. This workflow is what
4
+ # ships: it moves that tag forward. The workflows and the CLI they call (bundled in .github/cli/)
5
+ # live in the same commit, so whatever the tag points at is consistent on its own.
11
6
 
12
7
  on:
13
8
  workflow_call:
@@ -16,13 +11,6 @@ on:
16
11
  description: Commit to move the tag to. Defaults to the commit that triggered the caller.
17
12
  type: string
18
13
  default: ''
19
- wait_for_publish:
20
- description: >-
21
- Set by a release that has just published the pinned version. npm accepts a publish
22
- before the version is readable, so the check waits instead of treating the gap as
23
- a held tag, and fails if the version never appears.
24
- type: boolean
25
- default: false
26
14
 
27
15
  permissions:
28
16
  contents: read
@@ -63,54 +51,7 @@ jobs:
63
51
  with:
64
52
  ref: ${{ inputs.ref || github.sha }}
65
53
 
66
- - name: Check the required package version is published
67
- id: check
68
- env:
69
- # npm accepts a publish and processes it asynchronously ("Your package is being
70
- # processed and may take a few minutes to become available"). Observed at ~19
71
- # minutes for a provenance-signed release, so the release path waits well past
72
- # npm's own estimate rather than shipping a tag consumers cannot install against.
73
- WAIT_SECONDS: ${{ inputs.wait_for_publish && 2400 || 0 }}
74
- run: |
75
- pinned_version=$(cat .github/workflows-package-version)
76
- echo "pinned_version=$pinned_version" >> "$GITHUB_OUTPUT"
77
-
78
- deadline=$(( $(date +%s) + WAIT_SECONDS ))
79
- while :; do
80
- # --prefer-online so a 404 cached from an earlier attempt cannot outlive the
81
- # publish it was polling for.
82
- if output=$(npm view "apify-test-tools@$pinned_version" version --prefer-online 2>&1); then
83
- echo "apify-test-tools@$pinned_version is on npm"
84
- echo "published=true" >> "$GITHUB_OUTPUT"
85
- exit 0
86
- fi
87
-
88
- # Anything that is not "this version does not exist" is a registry, network or
89
- # auth problem. Sitting in the retry loop would hide it behind a held tag.
90
- if ! grep -q 'code E404' <<< "$output"; then
91
- echo "::error::npm view failed for a reason other than the version being absent."
92
- echo "$output"
93
- exit 1
94
- fi
95
-
96
- if [ "$(date +%s)" -ge "$deadline" ]; then
97
- break
98
- fi
99
- echo "apify-test-tools@$pinned_version is not on npm yet, retrying in 30s"
100
- sleep 30
101
- done
102
-
103
- echo "published=false" >> "$GITHUB_OUTPUT"
104
-
105
- # A release waited for its own publish and never saw it. That is a broken release,
106
- # not a held tag, and it has to be red so it can be re-run once npm catches up.
107
- if [ "$WAIT_SECONDS" -gt 0 ]; then
108
- echo "::error::apify-test-tools@$pinned_version was published by this run but is still not readable after $((WAIT_SECONDS / 60))m. Re-run this job once it appears on npm."
109
- exit 1
110
- fi
111
-
112
54
  - name: Move tag
113
- if: steps.check.outputs.published == 'true'
114
55
  env:
115
56
  TARGET_SHA: ${{ inputs.ref || github.sha }}
116
57
  run: |
@@ -120,23 +61,4 @@ jobs:
120
61
  echo "### \`$MAJOR_TAG\` moved"
121
62
  echo
122
63
  echo "Now points at \`$TARGET_SHA\`."
123
- echo "Pins \`apify-test-tools@${{ steps.check.outputs.pinned_version }}\`, which is published."
124
- } >> "$GITHUB_STEP_SUMMARY"
125
-
126
- # Not a failure. Holding the tag is the designed outcome of merging a workflow change
127
- # that needs an unreleased package feature, and consumers are unaffected while it waits.
128
- - name: Report held tag
129
- if: steps.check.outputs.published != 'true'
130
- env:
131
- TARGET_SHA: ${{ inputs.ref || github.sha }}
132
- run: |
133
- {
134
- echo "### \`$MAJOR_TAG\` held"
135
- echo
136
- echo "\`$TARGET_SHA\` pins \`apify-test-tools@${{ steps.check.outputs.pinned_version }}\`, which is not on npm."
137
- echo "Consumers keep running the workflows \`$MAJOR_TAG\` already points at."
138
- echo
139
- echo "Publish that version with the **Stable release** workflow. The tag moves on the"
140
- echo "next master push, or immediately via the **Move major version tag** workflow."
141
64
  } >> "$GITHUB_STEP_SUMMARY"
142
- echo "::warning::$MAJOR_TAG not moved: apify-test-tools@${{ steps.check.outputs.pinned_version }} is not published yet."
@@ -3,6 +3,10 @@ name: Tests
3
3
  on:
4
4
  workflow_dispatch:
5
5
  workflow_call:
6
+ secrets:
7
+ # Token of an isolated sandbox account that can only reach the e2e test's two dummy Actors.
8
+ E2E_TEST_APIFY_TOKEN_DBYPODOIHUZABNQTR:
9
+ required: false
6
10
 
7
11
  permissions:
8
12
  contents: read
@@ -33,3 +37,33 @@ jobs:
33
37
 
34
38
  - name: Unit tests
35
39
  run: npm test
40
+
41
+ # Runs the shipped CLI bundle against real Actors (test/e2e). Node 24 only, so one push builds
42
+ # and runs the sandbox Actors once rather than once per Node version.
43
+ e2e_tests:
44
+ name: E2E tests
45
+ runs-on: ubuntu-latest
46
+ steps:
47
+ - name: Checkout repository
48
+ uses: actions/checkout@v6
49
+
50
+ - name: Use Node.js
51
+ uses: actions/setup-node@v6
52
+ with:
53
+ node-version: 24
54
+ cache: 'npm'
55
+ cache-dependency-path: 'package-lock.json'
56
+
57
+ - name: Install dependencies
58
+ run: npm ci
59
+
60
+ # The token is only on this step. Fork and Dependabot PRs don't get the secret, and the
61
+ # suite skips itself without it.
62
+ - name: E2E tests
63
+ env:
64
+ E2E_TEST_APIFY_TOKEN_DBYPODOIHUZABNQTR: ${{ secrets.E2E_TEST_APIFY_TOKEN_DBYPODOIHUZABNQTR }}
65
+ run: |
66
+ if [ -z "$E2E_TEST_APIFY_TOKEN_DBYPODOIHUZABNQTR" ]; then
67
+ echo "::notice::E2E_TEST_APIFY_TOKEN_DBYPODOIHUZABNQTR is not available to this run, the e2e tests are skipped."
68
+ fi
69
+ npm run test:e2e
@@ -77,18 +77,6 @@ jobs:
77
77
  write-mode: overwrite
78
78
  contents: ${{ needs.release_metadata.outputs.changelog }}
79
79
 
80
- # The reusable workflows install this exact version, so the commit that releases a
81
- # version is the commit that pins it. That is what lets a frozen major tag keep
82
- # installing the library it was tested against instead of drifting to whatever is
83
- # newest.
84
- #
85
- # Skipped for prereleases: master pushes release a `-beta` that consumer repos must
86
- # never install. Their pin stays on the last stable, and the beta stays reachable
87
- # through the lockfile path in the setup action, which is how branch testing works.
88
- - name: Update the version the workflows pin
89
- if: inputs.release_type != 'prerelease'
90
- run: echo "${{ needs.release_metadata.outputs.version_number }}" > .github/workflows-package-version
91
-
92
80
  - name: Commit changes
93
81
  id: commit
94
82
  uses: apify/actions/signed-commit@v1.0.0
@@ -1,8 +1,8 @@
1
1
  name: Move major version tag
2
2
 
3
- # Escape hatch for the two cases the automatic move does not cover: shipping a workflow change right
4
- # after the release that unblocked it, without waiting for the next master push, and rolling the tag
5
- # back to an earlier commit when a shipped workflow turns out to be broken.
3
+ # Escape hatch for what the automatic move on master pushes does not cover: rolling the tag back to
4
+ # an earlier commit when a shipped workflow or CLI turns out to be broken, or moving it after a push
5
+ # whose checks failed for an unrelated reason.
6
6
 
7
7
  on:
8
8
  workflow_dispatch:
@@ -36,6 +36,9 @@ jobs:
36
36
  tests:
37
37
  name: Tests
38
38
  uses: ./.github/workflows/_tests.yaml
39
+ # Only the sandbox token, not `secrets: inherit`: the test job runs test code.
40
+ secrets:
41
+ E2E_TEST_APIFY_TOKEN_DBYPODOIHUZABNQTR: ${{ secrets.E2E_TEST_APIFY_TOKEN_DBYPODOIHUZABNQTR }}
39
42
 
40
43
  release_metadata:
41
44
  name: Update release metadata
@@ -79,16 +82,3 @@ jobs:
79
82
  "ref": "${{ needs.release_metadata.outputs.changelog_commitish }}",
80
83
  "tag": "latest"
81
84
  }
82
-
83
- # This release is what unblocks a major tag being held for an unpublished package version, so
84
- # try the move again now rather than making someone wait for the next master push. A no-op when
85
- # the tag was not being held.
86
- move_major_tag:
87
- name: Move major version tag
88
- needs: [release_metadata, npm_publish]
89
- permissions:
90
- contents: write
91
- uses: ./.github/workflows/_move_major_tag.yaml
92
- with:
93
- ref: ${{ needs.release_metadata.outputs.changelog_commitish }}
94
- wait_for_publish: true
@@ -24,14 +24,18 @@ jobs:
24
24
  if: "!startsWith(github.event.head_commit.message, 'docs')"
25
25
  name: Tests
26
26
  uses: ./.github/workflows/_tests.yaml
27
+ # Only the sandbox token, not `secrets: inherit`: the test job runs test code.
28
+ secrets:
29
+ E2E_TEST_APIFY_TOKEN_DBYPODOIHUZABNQTR: ${{ secrets.E2E_TEST_APIFY_TOKEN_DBYPODOIHUZABNQTR }}
27
30
 
28
- # Ships any workflow change in this push to consumer repos. Deliberately independent of the npm
29
- # release below: a workflow-only change needs no release, and a package-only release leaves the
30
- # workflows byte-identical. `code_checks` runs actionlint, which is what validates the workflows;
31
- # `tests` covers the npm package and is skipped for docs commits, so it is not a dependency here.
31
+ # Ships this push to consumer repos: the workflows and the CLI bundled in .github/cli/ go live
32
+ # together. Independent of the npm release below, which only matters to people importing the lib.
33
+ # `code_checks` runs actionlint and checks the bundle is up to date. `tests` cover the CLI but are
34
+ # skipped for docs commits, so a skipped run does not hold the tag; a failed one does.
32
35
  move_major_tag:
33
36
  name: Move major version tag
34
- needs: [code_checks]
37
+ needs: [code_checks, tests]
38
+ if: ${{ !failure() && !cancelled() }}
35
39
  permissions:
36
40
  contents: write
37
41
  uses: ./.github/workflows/_move_major_tag.yaml
@@ -21,51 +21,6 @@ jobs:
21
21
  tests:
22
22
  name: Tests
23
23
  uses: ./.github/workflows/_tests.yaml
24
-
25
- # Catches the one combination that breaks consumers: a workflow starting to use a CLI feature
26
- # from the same PR. Merging ships the workflow immediately, so the pinned version has to move in
27
- # the same change or the workflow goes live calling something that is not published.
28
- package_version_bump_needed:
29
- name: Package version bump needed
30
- runs-on: ubuntu-latest
31
- steps:
32
- - name: Checkout repository
33
- uses: actions/checkout@v6
34
- with:
35
- fetch-depth: 0
36
- ref: ${{ github.event.pull_request.head.sha }}
37
-
38
- - name: Check whether this PR needs a version bump
39
- env:
40
- BASE_REF: ${{ github.base_ref }}
41
- PR_LABELS: ${{ join(github.event.pull_request.labels.*.name, ',') }}
42
- run: |
43
- git fetch --no-tags origin "$BASE_REF"
44
- git diff --name-only FETCH_HEAD...HEAD | node .github/scripts/check-package-version-bump.mjs
45
-
46
- # Reports whether merging this PR will ship the workflows or hold the major tag until a release.
47
- # Never fails: pinning a version ahead of the release that publishes it is a supported way to
48
- # land the package change and the workflow change that needs it in one PR.
49
- workflows_package_version:
50
- name: Workflows package version
51
- runs-on: ubuntu-latest
52
- steps:
53
- - name: Checkout repository
54
- uses: actions/checkout@v6
55
-
56
- - name: Check the pinned package version is published
57
- run: |
58
- pinned_version=$(cat .github/workflows-package-version)
59
- if npm view "apify-test-tools@$pinned_version" version >/dev/null 2>&1; then
60
- echo "Workflows pin apify-test-tools@$pinned_version, which is published."
61
- echo "The major tag moves on merge and these workflows go live." >> "$GITHUB_STEP_SUMMARY"
62
- else
63
- {
64
- echo "### Major tag will be held on merge"
65
- echo
66
- echo "These workflows pin \`apify-test-tools@$pinned_version\`, which is not on npm yet."
67
- echo "Merging is fine: consumers keep running the current workflows until you cut a"
68
- echo "stable release, and the tag moves once that version is published."
69
- } >> "$GITHUB_STEP_SUMMARY"
70
- echo "::notice::Merging will not ship these workflows until apify-test-tools $pinned_version is released."
71
- fi
24
+ # Only the sandbox token, not `secrets: inherit`: the test job runs test code.
25
+ secrets:
26
+ E2E_TEST_APIFY_TOKEN_DBYPODOIHUZABNQTR: ${{ secrets.E2E_TEST_APIFY_TOKEN_DBYPODOIHUZABNQTR }}
@@ -47,7 +47,7 @@ jobs:
47
47
  --fileParallelism=true \
48
48
  --maxWorkers 100
49
49
  return_code=$?
50
- npx apify-test-tools report-tests \
50
+ apify-test-tools report-tests \
51
51
  --report-file ./test-output.json \
52
52
  --workflow-name "${{ github.workflow }}" \
53
53
  --job-url "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
@@ -59,44 +59,21 @@ jobs:
59
59
  args=(
60
60
  --source-branch "origin/$HEAD_REF"
61
61
  --target-branch "origin/$BASE_REF"
62
+ # TODO: Temporary hotfix until build glob matching aligns with Vitest's test selection glob.
63
+ --test-files-glob 'test/platform/**'
62
64
  --use-docker-cache
63
65
  )
64
66
  [ -n "$base_commit" ] && args+=(--base-commit "$base_commit")
65
67
  actor_builds=$(node "$SCRIPTS_PATH/run-with-apify-tokens.mjs" \
66
- npx apify-test-tools build "${args[@]}")
68
+ apify-test-tools build "${args[@]}")
67
69
  echo "actor_builds=$actor_builds" | tee -a "$GITHUB_OUTPUT"
68
70
 
69
- # Test files are outside every actor's Docker build context, so the diff above finds nothing
70
- # to build and every test skips. Right for "rebuild?", wrong for "test?".
71
- - name: Find changed platform tests
72
- id: changed_tests
73
- env:
74
- # Branch names are attacker-controlled on fork PRs, so they reach the script as
75
- # environment variables rather than being interpolated into it.
76
- HEAD_REF: ${{ github.head_ref }}
77
- BASE_REF: ${{ github.base_ref }}
78
- run: |
79
- changed=$(git diff --name-only --diff-filter=d "origin/$BASE_REF...HEAD" -- test/platform/ \
80
- | sed "s|^|./|" | tr '\n' ' ')
81
- branch_actors=$(npx apify-test-tools get-affected-actors \
82
- --source-branch "origin/$HEAD_REF" \
83
- --target-branch "origin/$BASE_REF")
84
- if [ -n "$changed" ] && [ "$branch_actors" = "[]" ]; then
85
- echo "target=$changed" | tee -a "$GITHUB_OUTPUT"
86
- elif [ -n "$changed" ]; then
87
- echo "Platform tests: the changed platform tests did not run. This branch also changes actor code validated at an earlier commit, so they could only have run against the deployed build, which lacks those changes. Re-run this job from scratch to rebuild and test together." >> "$GITHUB_STEP_SUMMARY"
88
- fi
89
-
90
71
  # Runs the repo's test code and its whole import graph, so it gets the tester token only.
91
72
  - name: Test
92
73
  env:
93
74
  ACTOR_BUILDS: ${{ steps.build.outputs.actor_builds }}
94
75
  TESTER_APIFY_TOKEN: ${{ secrets.TESTER_APIFY_TOKEN }}
95
- # No build to pin to, so lift the per-actor gate and let each run use the deployed build.
96
- RUN_ALL_PLATFORM_TESTS: ${{ steps.changed_tests.outputs.target && '1' || '' }}
97
- # `related` runs the tests that import each changed file, so a changed helper runs its dependents.
98
- # A plain filter would match no test for a helper and exit 1; `related` exits 0 when nothing imports it.
99
- run: npx vitest ${{ steps.changed_tests.outputs.target && format('related {0}', steps.changed_tests.outputs.target) || format('./test/platform/{0}', inputs.test-files-glob) }} --run --maxConcurrency 20 --fileParallelism=true --maxWorkers 100
76
+ run: npx vitest ./test/platform/${{ inputs.test-files-glob }} --run --maxConcurrency 20 --fileParallelism=true --maxWorkers 100
100
77
 
101
78
  # NOTE: This is an optimization that if we did functional changes and later only cosmetic changes (e.g. dev readme), we will compare changes files only for the last commit. This must run after tests because we want to cache the latest commit only if the tests are successful
102
79
  - name: Store last validated commit to cache
@@ -111,7 +88,7 @@ jobs:
111
88
  --target-branch "origin/$BASE_REF"
112
89
  )
113
90
  [ -n "$base_commit" ] && args+=(--base-commit "$base_commit")
114
- npx apify-test-tools get-latest-commit "${args[@]}" > ./base_commit.txt
91
+ apify-test-tools get-latest-commit "${args[@]}" > ./base_commit.txt
115
92
  echo "New last validated (base) commit: $(cat base_commit.txt)"
116
93
 
117
94
  # Pure static checks against the repo. Needs no Apify or Slack credentials, only the npm
@@ -36,11 +36,11 @@ jobs:
36
36
  SLACK_TOKEN_RELEASES_BOT: ${{ secrets.SLACK_TOKEN_RELEASES_BOT }}
37
37
  run: |
38
38
  node "${{ steps.setup.outputs.scripts-path }}/run-with-apify-tokens.mjs" \
39
- npx apify-test-tools release --base-commit ${{ github.event.before }} --release-slack-channel "#delivery-public-actors" --report-slack-channel "${{ inputs.report-slack-channel || format('#notif-{0}', github.event.repository.name) }}" --use-docker-cache
39
+ apify-test-tools release --base-commit ${{ github.event.before }} --release-slack-channel "#delivery-public-actors" --report-slack-channel "${{ inputs.report-slack-channel || format('#notif-{0}', github.event.repository.name) }}" --use-docker-cache
40
40
 
41
41
  - name: Delete old builds
42
42
  env:
43
43
  ALL_SECRETS: ${{ toJSON(secrets) }}
44
44
  run: |
45
45
  node "${{ steps.setup.outputs.scripts-path }}/run-with-apify-tokens.mjs" \
46
- npx apify-test-tools delete-old-builds
46
+ apify-test-tools delete-old-builds
package/.husky/pre-commit CHANGED
@@ -1,6 +1,11 @@
1
1
  echo "pre-commit: typechecking, linting, testing, checking code formatting, checking for unused exports & validating schemas"
2
2
 
3
3
 
4
+ # The workflows run the CLI from this bundle, so it ships with every commit that changes bin/ or its
5
+ # dependencies. Rebuilding takes well under a second.
6
+ npm run -s bundle
7
+ git add .github/cli/apify-test-tools.mjs
8
+
4
9
  npm test
5
10
  npm run format:check
6
11
  # We typecheck & lint last when we know our code works
package/.prettierignore CHANGED
@@ -8,3 +8,6 @@ CHANGELOG.md
8
8
 
9
9
  # Fixtures must stay byte-exact — several are deliberately malformed or empty
10
10
  test/fixtures
11
+
12
+ # Generated by `npm run bundle`
13
+ .github/cli/
package/CHANGELOG.md CHANGED
@@ -5,9 +5,14 @@ All notable changes to this project will be documented in this file.
5
5
  <!-- git-cliff-unreleased-start -->
6
6
  ## 0.10.2 - **not yet released**
7
7
 
8
+ ### 🚀 Features
9
+
10
+ - **ci:** Ship the workflows&#x27; CLI as a bundle in the action instead of installing it ([#200](https://github.com/apify/apify-test-tools/pull/200)) ([a0ef975](https://github.com/apify/apify-test-tools/commit/a0ef9756123a30a8210590b080a2a289c6a9c17c)) by [@metalwarrior665](https://github.com/metalwarrior665)
11
+
8
12
  ### 🐛 Bug Fixes
9
13
 
10
14
  - **toBeObject:** Reject null ([#191](https://github.com/apify/apify-test-tools/pull/191)) ([6bdae49](https://github.com/apify/apify-test-tools/commit/6bdae4905756e0ae8dd6146942e6fc04dbead48e)) by [@JuanGalilea](https://github.com/JuanGalilea), closes [#88](https://github.com/apify/apify-test-tools/issues/88)
15
+ - Build and test on test-only changes even when .dockerignore lists the tests ([#177](https://github.com/apify/apify-test-tools/pull/177)) ([5cb1b5a](https://github.com/apify/apify-test-tools/commit/5cb1b5ab5f6f43ec279f9624b402e73d55a5974a)) by [@artogahr](https://github.com/artogahr), closes [#145](https://github.com/apify/apify-test-tools/issues/145)
11
16
 
12
17
 
13
18
  <!-- git-cliff-unreleased-end -->
package/CONTRIBUTING.md CHANGED
@@ -89,24 +89,14 @@ Consumers pin `@workflows-v0`, not `@master`. See
89
89
  [Versioning and releases](./README.md#versioning-and-releases) in the README for how the tag and the
90
90
  npm release relate — the short version:
91
91
 
92
- - changing only a workflow needs no npm release
93
- - changing only the package needs no workflow change
94
- - a workflow that calls a **new** CLI feature must set `.github/workflows-package-version` to the
95
- version that will contain it, in the same PR. The `workflows-v0` tag is then held until that version is on
96
- npm, so merging can't ship a workflow that calls a CLI that doesn't exist yet.
97
-
98
- `.github/workflows-package-version` holds one exact version, and the stable release writes it. The
99
- workflows install exactly it, which is what makes a frozen major tag stay frozen — it keeps the
100
- library it was tested with instead of following `latest` forever.
101
-
102
- The `Package version bump needed` check enforces the point above: a PR touching both a `public_`
103
- workflow (or the composite action) and `bin/`, `lib/` or `index.ts` has to move the pin. When the
104
- two changes are unrelated and the workflow doesn't need the new code, label the PR
105
- `no-version-bump-needed`.
106
-
107
- It only looks at a single PR, so it won't catch a workflow that starts using a CLI feature merged in
108
- an earlier, still-unreleased PR. That needs someone to land a CLI change and sit on it unreleased;
109
- catching it would mean flagging every workflow edit made while any package change is unreleased.
92
+ - the workflows and the CLI ship together on every master push, through the tag; no npm release needed
93
+ - the lib ships through a stable npm release
94
+ - the CLI runs from `.github/cli/apify-test-tools.mjs`, a bundle the pre-commit hook rebuilds with
95
+ `npm run bundle`. If you commit with `--no-verify`, run it yourself: the `CLI bundle` check fails
96
+ on a stale bundle, and a stale bundle would hold the tag.
97
+ - `npm test` covers the bundle without network (`test/bundle/`). `npm run test:e2e` runs it against two
98
+ dummy Actors in an isolated sandbox account (`test/e2e/`) and skips itself unless
99
+ `E2E_TEST_APIFY_TOKEN_DBYPODOIHUZABNQTR` is set. CI passes that secret only to the `E2E tests` job.
110
100
 
111
101
  `npm run lint` and `actionlint` (via the `Code checks` workflow) both gate master, so run them before
112
102
  pushing workflow changes.