apify-test-tools 0.10.2-beta.1 → 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.
- package/.gitattributes +2 -0
- package/.github/actions/checkout-restore-dependencies/action.yaml +13 -29
- package/.github/cli/apify-test-tools.mjs +362 -0
- package/.github/scripts/run-with-apify-tokens.mjs +2 -2
- package/.github/workflows/_check_code.yaml +25 -0
- package/.github/workflows/_move_major_tag.yaml +3 -81
- package/.github/workflows/_tests.yaml +34 -0
- package/.github/workflows/_update_release_metadata.yaml +0 -12
- package/.github/workflows/manual_move_major_tag.yaml +3 -3
- package/.github/workflows/manual_release_stable.yaml +3 -13
- package/.github/workflows/on_master.yaml +9 -5
- package/.github/workflows/on_pull_request.yaml +3 -48
- package/.github/workflows/public_platform-tests.yaml +1 -1
- package/.github/workflows/public_pr-build-test.yaml +2 -2
- package/.github/workflows/public_push-build-latest.yaml +2 -2
- package/.husky/pre-commit +5 -0
- package/.prettierignore +3 -0
- package/CHANGELOG.md +4 -0
- package/CONTRIBUTING.md +8 -18
- package/README.md +39 -44
- package/bin/build-from-local.ts +47 -13
- package/bin/build.ts +35 -19
- package/bin/main.ts +20 -5
- package/bin/slack.ts +28 -6
- package/bin/test-report.ts +6 -9
- package/bin/types.ts +9 -0
- package/dist/bin/build-from-local.d.ts +10 -2
- package/dist/bin/build-from-local.d.ts.map +1 -1
- package/dist/bin/build-from-local.js +29 -11
- package/dist/bin/build-from-local.js.map +1 -1
- package/dist/bin/build.d.ts +15 -5
- package/dist/bin/build.d.ts.map +1 -1
- package/dist/bin/build.js +24 -15
- package/dist/bin/build.js.map +1 -1
- package/dist/bin/main.js +18 -4
- package/dist/bin/main.js.map +1 -1
- package/dist/bin/slack.d.ts +8 -1
- package/dist/bin/slack.d.ts.map +1 -1
- package/dist/bin/slack.js +26 -5
- package/dist/bin/slack.js.map +1 -1
- package/dist/bin/test-report.d.ts.map +1 -1
- package/dist/bin/test-report.js +6 -8
- package/dist/bin/test-report.js.map +1 -1
- package/dist/bin/types.d.ts +8 -0
- package/dist/bin/types.d.ts.map +1 -1
- package/dist/test/bundle/cli-bundle.test.d.ts +2 -0
- package/dist/test/bundle/cli-bundle.test.d.ts.map +1 -0
- package/dist/test/bundle/cli-bundle.test.js +162 -0
- package/dist/test/bundle/cli-bundle.test.js.map +1 -0
- package/dist/test/e2e/cli-bundle.e2e.test.d.ts +2 -0
- package/dist/test/e2e/cli-bundle.e2e.test.d.ts.map +1 -0
- package/dist/test/e2e/cli-bundle.e2e.test.js +172 -0
- package/dist/test/e2e/cli-bundle.e2e.test.js.map +1 -0
- package/dist/test/unit/bin/build-from-local.test.js +53 -1
- package/dist/test/unit/bin/build-from-local.test.js.map +1 -1
- package/dist/test/unit/bin/build.test.js +113 -3
- package/dist/test/unit/bin/build.test.js.map +1 -1
- package/dist/test/unit/bin/slack.test.d.ts +2 -0
- package/dist/test/unit/bin/slack.test.d.ts.map +1 -0
- package/dist/test/unit/bin/slack.test.js +54 -0
- package/dist/test/unit/bin/slack.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -3
- package/test/bundle/cli-bundle.test.ts +192 -0
- package/test/e2e/cli-bundle.e2e.test.ts +237 -0
- package/test/unit/bin/build-from-local.test.ts +55 -0
- package/test/unit/bin/build.test.ts +135 -3
- package/test/unit/bin/slack.test.ts +65 -0
- package/.github/scripts/check-package-version-bump.mjs +0 -74
- 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
|
|
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
|
|
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
|
|
4
|
-
#
|
|
5
|
-
#
|
|
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
|
|
4
|
-
#
|
|
5
|
-
#
|
|
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
|
|
29
|
-
#
|
|
30
|
-
#
|
|
31
|
-
#
|
|
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
|
-
|
|
26
|
-
|
|
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
|
-
|
|
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 }}" \
|
|
@@ -65,7 +65,7 @@ jobs:
|
|
|
65
65
|
)
|
|
66
66
|
[ -n "$base_commit" ] && args+=(--base-commit "$base_commit")
|
|
67
67
|
actor_builds=$(node "$SCRIPTS_PATH/run-with-apify-tokens.mjs" \
|
|
68
|
-
|
|
68
|
+
apify-test-tools build "${args[@]}")
|
|
69
69
|
echo "actor_builds=$actor_builds" | tee -a "$GITHUB_OUTPUT"
|
|
70
70
|
|
|
71
71
|
# Runs the repo's test code and its whole import graph, so it gets the tester token only.
|
|
@@ -88,7 +88,7 @@ jobs:
|
|
|
88
88
|
--target-branch "origin/$BASE_REF"
|
|
89
89
|
)
|
|
90
90
|
[ -n "$base_commit" ] && args+=(--base-commit "$base_commit")
|
|
91
|
-
|
|
91
|
+
apify-test-tools get-latest-commit "${args[@]}" > ./base_commit.txt
|
|
92
92
|
echo "New last validated (base) commit: $(cat base_commit.txt)"
|
|
93
93
|
|
|
94
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
|
-
|
|
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
|
-
|
|
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
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,10 @@ 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' 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)
|
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
|
-
-
|
|
93
|
-
-
|
|
94
|
-
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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.
|
package/README.md
CHANGED
|
@@ -308,48 +308,35 @@ Slack credentials in scope, so a postinstall script in the dependency tree canno
|
|
|
308
308
|
|
|
309
309
|
## Versioning and releases
|
|
310
310
|
|
|
311
|
-
The workflows and the npm package live in one repo but ship on their own schedules
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
|
315
|
-
|
|
|
316
|
-
| the
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
- **A workflow that calls a new CLI feature** — the one case that can break consumers, and the only
|
|
334
|
-
one with any ceremony. Put the package change, the workflow change, and the new pin in one PR. On
|
|
335
|
-
merge the tag is **held**: the CI job reports that the pinned version isn't on npm and leaves `workflows-v0`
|
|
336
|
-
where it is, so consumers keep running the previous workflows. Cut a stable release, and the tag
|
|
337
|
-
moves on its own. Run **Move major version tag** if you don't want to wait for the next master
|
|
338
|
-
push.
|
|
311
|
+
The workflows and the npm package live in one repo but ship on their own schedules:
|
|
312
|
+
|
|
313
|
+
| What | Consumers get it through | Ships when |
|
|
314
|
+
| -------------------------------------------- | ------------------------------------------ | ----------------------- |
|
|
315
|
+
| the workflows and the CLI they call | the `@workflows-v0` tag in `uses:` | every master push |
|
|
316
|
+
| the lib (`testActor`, `describe`, matchers…) | `apify-test-tools` in their `package.json` | a stable release on npm |
|
|
317
|
+
|
|
318
|
+
The CLI is bundled with its dependencies into `.github/cli/apify-test-tools.mjs` (`npm run bundle`,
|
|
319
|
+
run by the pre-commit hook and checked in CI), and the setup action runs it from there. Nothing is
|
|
320
|
+
installed for it, so a tag is a complete statement: these workflows and this CLI, with the exact
|
|
321
|
+
dependency versions from `package-lock.json` at that commit. The consumer's own `node_modules` is
|
|
322
|
+
left alone, so their tests keep the lib version they locked.
|
|
323
|
+
|
|
324
|
+
- **Workflow or CLI change** — merge it. `workflows-v0` moves once checks and tests pass, and it goes
|
|
325
|
+
live. No release needed, even when a workflow starts using a new CLI feature: both are in the
|
|
326
|
+
same commit.
|
|
327
|
+
- **Lib change** — merge it, then cut a release when you want it out. Consumers pick it up when
|
|
328
|
+
they update `apify-test-tools`.
|
|
329
|
+
|
|
330
|
+
The CLI and the lib in one job can be different versions now, so the formats between them are a
|
|
331
|
+
contract: the `ACTOR_BUILDS` JSON that `build` writes and the lib reads, and the vitest JSON report
|
|
332
|
+
`report-tests` reads. Add fields freely; renaming or removing one needs a new major tag.
|
|
339
333
|
|
|
340
334
|
`workflows-v0` moving on every master push means `@workflows-v0` is as live as `@master` was —
|
|
341
|
-
there's no staging step
|
|
342
|
-
|
|
343
|
-
|
|
335
|
+
there's no staging step. What the tag buys you is a `workflows-v1` for breaking workflow changes,
|
|
336
|
+
so repos migrate one at a time instead of all at once, and a way to roll back by pointing the tag at
|
|
337
|
+
an earlier commit (**Move major version tag** workflow). Bump `MAJOR_TAG` in
|
|
344
338
|
`.github/workflows/_move_major_tag.yaml` to cut the next major; the old tag then freezes where it is
|
|
345
|
-
and keeps working.
|
|
346
|
-
|
|
347
|
-
Freezing is real, which is the whole reason the version is pinned rather than a floor. A frozen `workflows-v0`
|
|
348
|
-
points at a commit whose pinned version never changes, so it keeps installing the library it was
|
|
349
|
-
tested against no matter how far the package moves on. Had the workflows installed `>=<floor>`, a
|
|
350
|
-
frozen `workflows-v0` would still resolve to whatever is newest — and since the release that enables
|
|
351
|
-
`workflows-v1` is usually the same release that breaks `workflows-v0`, the migration window would
|
|
352
|
-
have been zero.
|
|
339
|
+
and keeps working, CLI included, since the bundle is part of the frozen commit.
|
|
353
340
|
|
|
354
341
|
The tag tracks the **workflows'** contract, not the npm package version. They move independently on
|
|
355
342
|
purpose, so `@workflows-v0` is expected to stay `@workflows-v0` after the package reaches 1.0 —
|
|
@@ -360,9 +347,8 @@ and those refs disagree, which is the mistake that would otherwise ship silently
|
|
|
360
347
|
### Testing workflow changes
|
|
361
348
|
|
|
362
349
|
- Point [testing-repo-for-github-actions](https://github.com/apify-store/testing-repo-for-github-actions)
|
|
363
|
-
at your branch (`uses: ...@your-branch`). It has real attached Actors and tests.
|
|
364
|
-
|
|
365
|
-
action installs that exact version — so one branch tests both halves of a change together.
|
|
350
|
+
at your branch (`uses: ...@your-branch`). It has real attached Actors and tests. The branch carries
|
|
351
|
+
its own CLI bundle, so one branch tests the workflows and the CLI together.
|
|
366
352
|
- To change the composite action itself, repoint the `uses:` refs inside the reusable workflows at
|
|
367
353
|
your branch as well, and change them back before merging.
|
|
368
354
|
- Make sure the shell code actually works on your laptop first.
|
|
@@ -580,6 +566,15 @@ describe('standby tests', () => {
|
|
|
580
566
|
|
|
581
567
|
The package includes a CLI binary used by CI workflows to build Actors, detect changes, and report test results. You can also run it locally.
|
|
582
568
|
|
|
569
|
+
### Dry runs (`--dry-run`)
|
|
570
|
+
|
|
571
|
+
Every command that changes something (`build`, `build-from-local`, `release`, `delete-old-builds`, `report-tests`) takes `--dry-run`. A dry run:
|
|
572
|
+
|
|
573
|
+
- **Changes nothing.** No versions or builds are created, nothing is uploaded or deleted, and no Slack message is posted.
|
|
574
|
+
- **Does every read and check the real run does**, so it fails wherever the real run would: change detection, the Apify token and Actor lookup, the [repository check](#repository-check), collecting and zipping local sources, and the Slack token (verified with Slack's read-only `auth.test`).
|
|
575
|
+
- **Needs the same tokens as the real run.** Read-only tokens are enough, since nothing is written. A dry run can't tell whether a token is also allowed to write, because the Apify API has no dry-run mode of its own.
|
|
576
|
+
- **Prints a plan, not results.** Logs start with `[DRY RUN] Would …`. `build` and `build-from-local` write `{ "dryRun": true, "builds": [...] }` to stdout instead of the build array, so the plan can't be passed to tests as `ACTOR_BUILDS` by mistake.
|
|
577
|
+
|
|
583
578
|
### Running locally
|
|
584
579
|
|
|
585
580
|
Running the testing library locally is useful when you only want to update the testing code in /test because you can iterate on it without pushing new code to the remote.
|
|
@@ -610,7 +605,7 @@ APIFY_TOKEN_JOHN_DOE=<token> \
|
|
|
610
605
|
--dry-run
|
|
611
606
|
```
|
|
612
607
|
|
|
613
|
-
Remove `--dry-run` to actually trigger builds and update the branch names
|
|
608
|
+
With `--dry-run`, it prints the plan (the version and Git URL each Actor would be built from). Remove `--dry-run` to actually trigger builds and update the branch names. The command outputs a JSON array of build objects to stdout:
|
|
614
609
|
|
|
615
610
|
```json
|
|
616
611
|
[{ "buildId": "...", "actorRawId": "...", "buildNumber": "...", "actorFullName": "john.doe/my-actor" }]
|
|
@@ -625,7 +620,7 @@ APIFY_TOKEN_JOHN_DOE=<token> \
|
|
|
625
620
|
npx apify-test-tools build-from-local --actors john.doe/my-actor
|
|
626
621
|
```
|
|
627
622
|
|
|
628
|
-
Pass a hardcoded actor name via `--actors` to build only that Actor (comma-separate multiple names). Omit `--actors` to build all Actors in the repo, or add `--dry-run` to
|
|
623
|
+
Pass a hardcoded actor name via `--actors` to build only that Actor (comma-separate multiple names). Omit `--actors` to build all Actors in the repo, or add `--dry-run` to check the token, the Actor and the zipped sources without uploading or building. It outputs the same JSON build array as `build`, so you run tests against it the same way as in step 5 below:
|
|
629
624
|
|
|
630
625
|
```bash
|
|
631
626
|
# Build from local source and capture output
|