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