apify-test-tools 0.1.0

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 (103) hide show
  1. package/README.md +23 -0
  2. package/bin/build.ts +287 -0
  3. package/bin/consts.ts +6 -0
  4. package/bin/git.ts +56 -0
  5. package/bin/github.ts +75 -0
  6. package/bin/main.ts +145 -0
  7. package/bin/slack.ts +72 -0
  8. package/bin/test-report.ts +146 -0
  9. package/bin/types.ts +102 -0
  10. package/bin/utils.ts +204 -0
  11. package/dist/bin/build.d.ts +18 -0
  12. package/dist/bin/build.d.ts.map +1 -0
  13. package/dist/bin/build.js +222 -0
  14. package/dist/bin/build.js.map +1 -0
  15. package/dist/bin/consts.d.ts +4 -0
  16. package/dist/bin/consts.d.ts.map +1 -0
  17. package/dist/bin/consts.js +6 -0
  18. package/dist/bin/consts.js.map +1 -0
  19. package/dist/bin/git.d.ts +7 -0
  20. package/dist/bin/git.d.ts.map +1 -0
  21. package/dist/bin/git.js +47 -0
  22. package/dist/bin/git.js.map +1 -0
  23. package/dist/bin/github.d.ts +12 -0
  24. package/dist/bin/github.d.ts.map +1 -0
  25. package/dist/bin/github.js +64 -0
  26. package/dist/bin/github.js.map +1 -0
  27. package/dist/bin/main.d.ts +3 -0
  28. package/dist/bin/main.d.ts.map +1 -0
  29. package/dist/bin/main.js +117 -0
  30. package/dist/bin/main.js.map +1 -0
  31. package/dist/bin/slack.d.ts +12 -0
  32. package/dist/bin/slack.d.ts.map +1 -0
  33. package/dist/bin/slack.js +46 -0
  34. package/dist/bin/slack.js.map +1 -0
  35. package/dist/bin/test-report.d.ts +10 -0
  36. package/dist/bin/test-report.d.ts.map +1 -0
  37. package/dist/bin/test-report.js +74 -0
  38. package/dist/bin/test-report.js.map +1 -0
  39. package/dist/bin/types.d.ts +88 -0
  40. package/dist/bin/types.d.ts.map +1 -0
  41. package/dist/bin/types.js +2 -0
  42. package/dist/bin/types.js.map +1 -0
  43. package/dist/bin/utils.d.ts +26 -0
  44. package/dist/bin/utils.d.ts.map +1 -0
  45. package/dist/bin/utils.js +164 -0
  46. package/dist/bin/utils.js.map +1 -0
  47. package/dist/index.d.ts +3 -0
  48. package/dist/index.d.ts.map +1 -0
  49. package/dist/index.js +3 -0
  50. package/dist/index.js.map +1 -0
  51. package/dist/lib/consts.d.ts +3 -0
  52. package/dist/lib/consts.d.ts.map +1 -0
  53. package/dist/lib/consts.js +14 -0
  54. package/dist/lib/consts.js.map +1 -0
  55. package/dist/lib/extend-expect.d.ts +3 -0
  56. package/dist/lib/extend-expect.d.ts.map +1 -0
  57. package/dist/lib/extend-expect.js +228 -0
  58. package/dist/lib/extend-expect.js.map +1 -0
  59. package/dist/lib/lib.d.ts +16 -0
  60. package/dist/lib/lib.d.ts.map +1 -0
  61. package/dist/lib/lib.js +91 -0
  62. package/dist/lib/lib.js.map +1 -0
  63. package/dist/lib/run-test-result.d.ts +20 -0
  64. package/dist/lib/run-test-result.d.ts.map +1 -0
  65. package/dist/lib/run-test-result.js +62 -0
  66. package/dist/lib/run-test-result.js.map +1 -0
  67. package/dist/lib/types.d.ts +107 -0
  68. package/dist/lib/types.d.ts.map +1 -0
  69. package/dist/lib/types.js +2 -0
  70. package/dist/lib/types.js.map +1 -0
  71. package/dist/lib/utils.d.ts +7 -0
  72. package/dist/lib/utils.d.ts.map +1 -0
  73. package/dist/lib/utils.js +30 -0
  74. package/dist/lib/utils.js.map +1 -0
  75. package/dist/test/unit/custom-matchers.test.d.ts +2 -0
  76. package/dist/test/unit/custom-matchers.test.d.ts.map +1 -0
  77. package/dist/test/unit/custom-matchers.test.js +53 -0
  78. package/dist/test/unit/custom-matchers.test.js.map +1 -0
  79. package/dist/test/unit/should-built-and-test.test.d.ts +2 -0
  80. package/dist/test/unit/should-built-and-test.test.d.ts.map +1 -0
  81. package/dist/test/unit/should-built-and-test.test.js +136 -0
  82. package/dist/test/unit/should-built-and-test.test.js.map +1 -0
  83. package/dist/test/unit/test-actor.test.d.ts +2 -0
  84. package/dist/test/unit/test-actor.test.d.ts.map +1 -0
  85. package/dist/test/unit/test-actor.test.js +17 -0
  86. package/dist/test/unit/test-actor.test.js.map +1 -0
  87. package/dist/tsconfig.tsbuildinfo +1 -0
  88. package/example-github-events/pull-request.json +523 -0
  89. package/example-github-events/push.json +216 -0
  90. package/index.ts +2 -0
  91. package/lib/consts.ts +15 -0
  92. package/lib/extend-expect.ts +268 -0
  93. package/lib/lib.ts +134 -0
  94. package/lib/run-test-result.ts +70 -0
  95. package/lib/types.ts +131 -0
  96. package/lib/utils.ts +49 -0
  97. package/package.json +41 -0
  98. package/scripts/hook-job-started.sh +11 -0
  99. package/test/tsconfig.json +15 -0
  100. package/test/unit/custom-matchers.test.ts +61 -0
  101. package/test/unit/should-built-and-test.test.ts +166 -0
  102. package/test/unit/test-actor.test.ts +17 -0
  103. package/tsconfig.json +20 -0
@@ -0,0 +1,222 @@
1
+ import { ACTOR_SOURCE_TYPES } from '@apify/consts';
2
+ import { ApifyClient } from 'apify-client';
3
+ import { getEnvVar } from './utils.js';
4
+ class ApifyBuilder {
5
+ apifyClient;
6
+ actorName;
7
+ // eslint-disable-next-line no-empty-function
8
+ constructor(apifyClient, actorName) {
9
+ this.apifyClient = apifyClient;
10
+ this.actorName = actorName;
11
+ }
12
+ // Usually 'latest' but not necessarily (can be e.g. 'version-0')
13
+ getDefaultVersionAndTag = async () => {
14
+ const actorClient = this.apifyClient.actor(this.actorName);
15
+ const actorInfo = await actorClient.get();
16
+ if (!actorInfo) {
17
+ throw new Error(`[${this.actorName}] not found. It is not published or we are missing token to access it privately or its name is misspelled`);
18
+ }
19
+ const defaultBuildTag = actorInfo.defaultRunOptions.build;
20
+ console.error(`Default build tag for ${this.actorName} is ${defaultBuildTag}`);
21
+ // We could technically allow this but in most cases this is accidentally set wrongly and there is a workaround
22
+ if (defaultBuildTag.match(/\d+\.\d+\.\d+/)) {
23
+ throw new Error(`[${this.actorName}] Default build is a build number, not a tag. While this could work, `
24
+ + `we want to have a default as tag so this is often an accidental misconfiguration from the dev`);
25
+ }
26
+ // I reported that buildNumber should probably not be optional
27
+ const defaultBuildNumber = actorInfo.taggedBuilds[defaultBuildTag].buildNumber;
28
+ const defaultVersionNumber = defaultBuildNumber.match(/(\d+\.\d+)\.\d+/)[1];
29
+ console.error(`Default version for ${this.actorName} is ${defaultVersionNumber}`);
30
+ return { defaultBuildNumber, defaultVersionNumber, defaultBuildTag };
31
+ };
32
+ startActorBuild = async ({ buildTag, versionNumber, gitRepoUrl, }) => {
33
+ const actorClient = this.apifyClient.actor(this.actorName);
34
+ const actorInfo = await actorClient.get();
35
+ if (!actorInfo) {
36
+ throw new Error(`No actor named '${this.actorName}' was found on the platform. If this`
37
+ + ' is unexpected, make sure the actor you are targeting is spelled the'
38
+ + ' same as the folder in the repository.');
39
+ }
40
+ const actorVersion = {
41
+ buildTag,
42
+ versionNumber,
43
+ gitRepoUrl,
44
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
45
+ // @ts-ignore: coudn't find this type either :(
46
+ sourceType: ACTOR_SOURCE_TYPES.GIT_REPO,
47
+ };
48
+ // Prepare version
49
+ const versionExists = !actorInfo.versions.find((version) => version.versionNumber === versionNumber);
50
+ if (versionExists) {
51
+ // create new version
52
+ await actorClient.versions().create(actorVersion);
53
+ }
54
+ else {
55
+ const version = actorClient.version(versionNumber);
56
+ await version.update(actorVersion);
57
+ }
58
+ console.error(`[BUILD][${this.actorName}]: Will be built with version ${versionNumber}`);
59
+ console.error(`[BUILD][${this.actorName}]: ${JSON.stringify(actorVersion)}`);
60
+ // We also get back actId so the testing actor can both match by actor ID and name
61
+ const { id, actId, buildNumber } = await actorClient.build(versionNumber);
62
+ console.error(`[BUILD][${this.actorName}]: Build ${id} (${versionNumber}) has started`);
63
+ return { buildId: id, actorId: actId, buildNumber, actorName: this.actorName };
64
+ };
65
+ waitForBuildToFinish = async (buildId, actorName) => {
66
+ console.error(`[BUILD][${actorName}]: Waiting for build ${buildId} to finish`);
67
+ const build = await this.apifyClient.build(buildId).waitForFinish();
68
+ const versionNumber = build.buildNumber;
69
+ if (build.status === 'FAILED' || build.status === 'TIMED-OUT') {
70
+ const message = `[BUILD][${actorName}]: Build ${buildId} (${versionNumber}) failed. `
71
+ + `Not continuing with other builds and tests.`;
72
+ console.warn(`D€LIV€RY_$L&CK: Webhook-to-build: ${message}`);
73
+ throw new Error(message);
74
+ }
75
+ console.error(`[BUILD][${actorName}]: Build ${build.id} (${versionNumber}) finished successfully.`);
76
+ return build;
77
+ };
78
+ /**
79
+ * Create ApifyBuilder with actor owner's token
80
+ */
81
+ static fromActorName = (actorName) => {
82
+ const username = actorName.split('/')[0];
83
+ // GitHib secrets only allow word characters (alphanum + underscore)
84
+ const usernameInGitHubSecretsFormat = username.replaceAll(/\W/g, '_').toUpperCase();
85
+ const usernameEnvVar = `APIFY_TOKEN_${usernameInGitHubSecretsFormat}`;
86
+ const token = process.env[usernameEnvVar];
87
+ if (!token) {
88
+ throw new Error(`Cannot find Apify API token for username: ${username}. `
89
+ + `Have you set secret env var to this GitHub repo with key: ${usernameEnvVar}?`);
90
+ }
91
+ const apifyClient = new ApifyClient({ token });
92
+ const builder = new ApifyBuilder(apifyClient, actorName);
93
+ return builder;
94
+ };
95
+ /**
96
+ * Deletes build of all versions. Apify API doesn't allow to delete default build and we explicitly skip it
97
+ * We delete devel builds faster because we used the for every PR until recently so just to get rid of them faster
98
+ */
99
+ async deleteOldBuilds() {
100
+ // Even though we don't version our current Actors, if we ever such Actors to GitHub CI, we would accidentally delete old supported versions
101
+ // This hardcoded solution is not ideal, but it should prevent most imaginable cases
102
+ // All currently popular versioned Actors use `version-${number}` format
103
+ const PROTECTED_TAGS_PREFIX = ['latest', 'v-', 'version', 'v0', 'v1', 'v2', 'v3', 'v4', 'v5', 'v6', 'v7', 'v8', 'v9'];
104
+ // We don't want to be too short because we might to debug something
105
+ // but also not too long because it increases the risk of users using outdated versions
106
+ const DEFAULT_DAYS_BACK_PROD_VERSIONS = 30;
107
+ const DEFAULT_DAYS_BACK_DEVEL = 7;
108
+ const actorInfo = (await this.apifyClient.actor(this.actorName).get());
109
+ // 'devel' used to be hardcoded for testing version 0.99, once we get rid of this tag everywhere, we can remove this code
110
+ const taggedDevelBuildNumber = actorInfo.taggedBuilds.devel?.buildNumber;
111
+ const allTags = Object.keys(actorInfo.taggedBuilds ?? {});
112
+ const protectedTags = allTags.filter((tag) => PROTECTED_TAGS_PREFIX.some((prefix) => tag.startsWith(prefix)));
113
+ const protectedBuildNumbers = protectedTags.map((tag) => ({ buildNumber: actorInfo.taggedBuilds[tag].buildNumber, tag }));
114
+ const { items } = (await this.apifyClient.actor(this.actorName).builds().list());
115
+ // Deleting default build throws an error, so we skip it
116
+ const { defaultBuildNumber, defaultBuildTag } = await ApifyBuilder.fromActorName(this.actorName).getDefaultVersionAndTag();
117
+ const daysAgoUnixProd = Date.now() - DEFAULT_DAYS_BACK_PROD_VERSIONS * 24 * 60 * 60 * 1000;
118
+ const daysAgoUnixDevel = Date.now() - DEFAULT_DAYS_BACK_DEVEL * 24 * 60 * 60 * 1000;
119
+ const buildsToDelete = items.filter((build) => {
120
+ if (build.buildNumber === defaultBuildNumber) {
121
+ console.error(`[DELETE OLD BUILDS][${this.actorName}]: Skipping default build ${defaultBuildNumber} (${defaultBuildTag}). `
122
+ + `We never delete default builds`);
123
+ return false;
124
+ }
125
+ const protectedTagFound = protectedBuildNumbers.find((protectedBuildNumber) => protectedBuildNumber.buildNumber === build.buildNumber);
126
+ if (protectedTagFound) {
127
+ console.error(`[DELETE OLD BUILDS][${this.actorName}]: Skipping protected build ${protectedTagFound.buildNumber} (${protectedTagFound.tag}).`);
128
+ return false;
129
+ }
130
+ if (taggedDevelBuildNumber && build.buildNumber === taggedDevelBuildNumber) {
131
+ const shouldDeleteDevelBuild = build.startedAt.getTime() < daysAgoUnixDevel;
132
+ if (shouldDeleteDevelBuild) {
133
+ console.error(`[DELETE OLD BUILDS][${this.actorName}]: Removing olf devel build ${taggedDevelBuildNumber}.`);
134
+ }
135
+ return shouldDeleteDevelBuild;
136
+ }
137
+ return build.startedAt.getTime() < daysAgoUnixProd;
138
+ });
139
+ console.error(`[DELETE OLD BUILDS][${this.actorName}]: Deleting ${buildsToDelete.length} old builds that are non-default and `
140
+ + `older than 30 days from total ${items.length}`);
141
+ for (const build of buildsToDelete) {
142
+ await this.apifyClient.build(build.id).delete();
143
+ }
144
+ }
145
+ }
146
+ export const runBuilds = async ({ repoUrl, branch, actorConfigs, isLatest = false, dryRun, }) => {
147
+ const buildConfigs = [];
148
+ const circleActors = isLatest ? await findCircleApifyManaged(actorConfigs) : [];
149
+ for (const { actorName, folder } of actorConfigs.concat(circleActors)) {
150
+ let versionNumber;
151
+ let buildTag;
152
+ if (isLatest) {
153
+ const { defaultVersionNumber, defaultBuildTag } = await ApifyBuilder.fromActorName(actorName).getDefaultVersionAndTag();
154
+ versionNumber = defaultVersionNumber;
155
+ buildTag = defaultBuildTag;
156
+ }
157
+ else {
158
+ versionNumber = '0.99';
159
+ }
160
+ // Depending on if these are miniactors or standaloneActors
161
+ let gitRepoUrl = `${repoUrl}#${branch}`;
162
+ if (folder) {
163
+ gitRepoUrl = `${gitRepoUrl}:${folder}`;
164
+ }
165
+ buildConfigs.push({ actorName, gitRepoUrl, versionNumber, buildTag });
166
+ }
167
+ if (dryRun) {
168
+ return buildConfigs;
169
+ }
170
+ const startedBuilds = await Promise.all(buildConfigs.map(async (buildConfig) => {
171
+ const builder = ApifyBuilder.fromActorName(buildConfig.actorName);
172
+ const buildData = await builder.startActorBuild(buildConfig);
173
+ return buildData;
174
+ }));
175
+ await Promise.all(startedBuilds.map(async (buildData) => {
176
+ const builder = ApifyBuilder.fromActorName(buildData.actorName);
177
+ await builder.waitForBuildToFinish(buildData.buildId, buildData.actorName);
178
+ }));
179
+ return startedBuilds;
180
+ };
181
+ export const deleteOldBuilds = async (actorConfigs) => {
182
+ for (const { actorName } of actorConfigs) {
183
+ await ApifyBuilder.fromActorName(actorName).deleteOldBuilds();
184
+ }
185
+ };
186
+ /**
187
+ * We will read all Actors in the circ_le account and build those that match by name pattern
188
+ * There are many ways to approach this, a more robust one would be to have a map of Actors
189
+ * which would allow to have more than one special user per Actor
190
+ * But since that use-case might never be needed, I went with the simplest solution that doesn't require maintaining the map
191
+ * NOTE: One issue is that if any Actor is renamed, we will not match it in the circ_le account nor throw any error
192
+ */
193
+ const findCircleApifyManaged = async (actorConfigs) => {
194
+ // This token is hardcoded in the runner Actor, locally you have to inject it
195
+ const client = new ApifyClient({ token: getEnvVar('APIFY_TOKEN_CIRC_LE') });
196
+ const { items: circleActors } = await client.actors().list();
197
+ const actorsToBuild = circleActors.map((circleActor) => {
198
+ // They prefix all with apify-managed---, I communicated with Jacques to keep doing that
199
+ let actorConfigFound = actorConfigs.find((actorConfig) => circleActor.name.replace('apify-managed---', '') === actorConfig.actorName.split('/')[1]);
200
+ // Hack for bad naming of circ_le/apify-managed-google-search, we don't want to rename now to break customers
201
+ if (!actorConfigFound && circleActor.name === 'apify-managed-google-search') {
202
+ actorConfigFound = actorConfigs.find((actorConfig) => actorConfig.actorName.split('/')[1] === 'google-search-scraper');
203
+ }
204
+ if (actorConfigFound) {
205
+ return {
206
+ // We point the circle Actor to the repo folder
207
+ actorName: `${circleActor.username}/${circleActor.name}`,
208
+ folder: actorConfigFound.folder,
209
+ isStandalone: actorConfigFound.isStandalone,
210
+ };
211
+ }
212
+ return undefined;
213
+ }).filter((config) => config !== undefined);
214
+ console.error(`Found ${actorsToBuild.length} circ_le actors that match Actors we built out of total ${circleActors.length} circ_le actors`);
215
+ console.error(`All circ_le actors: ${circleActors.map((actor) => actor.name).join(', ')}`);
216
+ console.error(`circ_le Actors to build: ${actorsToBuild.map((actor) => actor.actorName).join(', ')}`);
217
+ if (actorsToBuild.length === 0) {
218
+ console.error('No circ_le actors to build');
219
+ }
220
+ return actorsToBuild;
221
+ };
222
+ //# sourceMappingURL=build.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"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,OAAO,aAAa,CAAC;AACzB,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare const DEFAULT_BUILD_ALL_FOLDERS: string[];
2
+ export declare const PERSISTED_GH_JOBS_KVS_ID = "XIBdO8EJePdD0KiAI";
3
+ export declare const MINIACTORS_LIST_STORE_ID = "ftXklt2f2mN30Oc3y";
4
+ //# sourceMappingURL=consts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../bin/consts.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,yBAAyB,UAAiC,CAAC;AAExE,eAAO,MAAM,wBAAwB,sBAAsB,CAAC;AAC5D,eAAO,MAAM,wBAAwB,sBAAsB,CAAC"}
@@ -0,0 +1,6 @@
1
+ // Technically, upgrades in shared or packages might not need impact every actor
2
+ // but we cannot really know that
3
+ export const DEFAULT_BUILD_ALL_FOLDERS = ['code', 'shared', 'packages'];
4
+ export const PERSISTED_GH_JOBS_KVS_ID = 'XIBdO8EJePdD0KiAI';
5
+ export const MINIACTORS_LIST_STORE_ID = 'ftXklt2f2mN30Oc3y';
6
+ //# sourceMappingURL=consts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consts.js","sourceRoot":"","sources":["../../bin/consts.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,iCAAiC;AACjC,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;AAExE,MAAM,CAAC,MAAM,wBAAwB,GAAG,mBAAmB,CAAC;AAC5D,MAAM,CAAC,MAAM,wBAAwB,GAAG,mBAAmB,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { Commit, Config } from './types';
2
+ export declare const getBranchLastCommit: (branch: string) => Commit;
3
+ export declare const getChangedFiles: (commits: Commit[]) => string[];
4
+ export declare const getCommits: ({ sourceBranch, targetBranch, baseCommit: baseCommitSha, }: Config) => Commit[];
5
+ export declare const getBaseCommit: (target: Commit, source: Commit) => Commit;
6
+ export declare const getCommitInfo: (commitSha: string) => Commit;
7
+ //# sourceMappingURL=git.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../bin/git.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAKzC,eAAO,MAAM,mBAAmB,WAAY,MAAM,KAAG,MAGpD,CAAC;AAEF,eAAO,MAAM,eAAe,YAAa,MAAM,EAAE,aAKhD,CAAC;AAEF,eAAO,MAAM,UAAU,+DAIpB,MAAM,KAAG,MAAM,EAwBjB,CAAC;AAEF,eAAO,MAAM,aAAa,WAAY,MAAM,UAAU,MAAM,KAAG,MAI9D,CAAC;AAEF,eAAO,MAAM,aAAa,cAAe,MAAM,KAAG,MAEjD,CAAC"}
@@ -0,0 +1,47 @@
1
+ import { spawnCommandInGhWorkspace } from './utils.js';
2
+ const GIT_LOG_FORMAT = `{"sha":"%H","author":"%aN<%aE>","date":"%aD","message":"%s"}`;
3
+ export const getBranchLastCommit = (branch) => {
4
+ const lastCommit = JSON.parse(spawnCommandInGhWorkspace(`git log -1 --pretty=format:'${GIT_LOG_FORMAT}' ${branch}`));
5
+ return lastCommit;
6
+ };
7
+ export const getChangedFiles = (commits) => {
8
+ const changedFiles = commits.length === 1
9
+ ? spawnCommandInGhWorkspace(`git show --pretty='format:' --name-only ${commits[0].sha}`)
10
+ : spawnCommandInGhWorkspace(`git diff --name-only ${commits[0].sha}..${commits[commits.length - 1].sha}`);
11
+ return changedFiles.split('\n');
12
+ };
13
+ export const getCommits = ({ sourceBranch, targetBranch, baseCommit: baseCommitSha, }) => {
14
+ const targetBranchCommit = getBranchLastCommit(targetBranch);
15
+ const sourceBranchCommit = getBranchLastCommit(sourceBranch);
16
+ let baseCommit;
17
+ if (baseCommitSha) {
18
+ try {
19
+ baseCommit = getCommitInfo(baseCommitSha);
20
+ }
21
+ catch (err) {
22
+ console.warn(`Failed to get base commit "${baseCommitSha}", it will not be used: ${err}`);
23
+ }
24
+ }
25
+ // const baseCommit = baseCommitSha !== undefined ? : undefined;
26
+ // const gitOutputFormat = '{"sha":"%H","author":"%aN<%aE>","date":"%aD","message":"%f"}';
27
+ // console.log(`git log --pretty=format:"${gitOutputFormat}" ${targetBranch}..${sourceBranch}`);
28
+ // return [];
29
+ const base = getBaseCommit(sourceBranchCommit, targetBranchCommit);
30
+ const commitsStrings = spawnCommandInGhWorkspace(`git log --pretty=format:'${GIT_LOG_FORMAT}' ${base.sha}..${sourceBranchCommit.sha}`)
31
+ .split('\n');
32
+ const commits = JSON.parse(`[${commitsStrings.join(',')}]`);
33
+ commits.reverse();
34
+ const baseCommitIndex = baseCommit
35
+ ? commits.findIndex(({ sha }) => sha === baseCommit.sha)
36
+ : -1;
37
+ return commits.slice(baseCommitIndex + 1);
38
+ };
39
+ export const getBaseCommit = (target, source) => {
40
+ const baseCommitSha = spawnCommandInGhWorkspace(`git merge-base ${target.sha} ${source.sha}`);
41
+ const baseCommit = getCommitInfo(baseCommitSha);
42
+ return baseCommit;
43
+ };
44
+ export const getCommitInfo = (commitSha) => {
45
+ return JSON.parse(spawnCommandInGhWorkspace(`git log -1 --pretty=format:'${GIT_LOG_FORMAT}' ${commitSha}`));
46
+ };
47
+ //# sourceMappingURL=git.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git.js","sourceRoot":"","sources":["../../bin/git.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAEvD,MAAM,cAAc,GAAG,8DAA8D,CAAC;AAEtF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,MAAc,EAAU,EAAE;IAC1D,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,yBAAyB,CAAC,+BAA+B,cAAc,KAAK,MAAM,EAAE,CAAC,CAAW,CAAC;IAC/H,OAAO,UAAU,CAAC;AACtB,CAAC,CAAC;AAEF,MAA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C,KAAK,CAAC,IAAI,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAa,CAAC;IACxE,OAAO,CAAC,OAAO,EAAE,CAAC;IAClB,MAAM,eAAe,GAAG,UAAU;QAC9B,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,KAAK,UAAU,CAAC,GAAG,CAAC;QACxD,CAAC,CAAC,CAAC,CAAC,CAAC;IACT,OAAO,OAAO,CAAC,KAAK,CAAC,eAAe,GAAG,CAAC,CAAC,CAAC;AAC9C,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,MAAc,EAAE,MAAc,EAAU,EAAE;IACpE,MAAM,aAAa,GAAG,yBAAyB,CAAC,kBAAkB,MAAM,CAAC,GAAG,IAAI,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;IAC9F,MAAM,UAAU,GAAG,aAAa,CAAC,aAAa,CAAC,CAAC;IAChD,OAAO,UAAU,CAAC;AACtB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,SAAiB,EAAU,EAAE;IACvD,OAAO,IAAI,CAAC,KAAK,CAAC,yBAAyB,CAAC,+BAA+B,cAAc,KAAK,SAAS,EAAE,CAAC,CAAC,CAAC;AAChH,CAAC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { Commit, GitHubEventPush } from './types';
2
+ export declare const getPushData: (path: string) => Promise<{
3
+ branch: string;
4
+ commits: Commit[];
5
+ changedFiles: string[];
6
+ repoUrl: string;
7
+ changelog: string | null;
8
+ repository: string;
9
+ }>;
10
+ export declare const loadGitHubEvent: (path: string) => Promise<GitHubEventPush>;
11
+ export declare const getChangelogChanges: (changedFiles: string[], event: GitHubEventPush) => string | null;
12
+ //# sourceMappingURL=github.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../../bin/github.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAGlD,eAAO,MAAM,WAAW,SAAgB,MAAM;;;;;;;EAuB7C,CAAC;AAEF,eAAO,MAAM,eAAe,SAAgB,MAAM,KAAG,OAAO,CAAC,eAAe,CAG3E,CAAC;AAOF,eAAO,MAAM,mBAAmB,iBACd,MAAM,EAAE,SACf,eAAe,KACvB,MAAM,GAAG,IAgCX,CAAC"}
@@ -0,0 +1,64 @@
1
+ import fs from 'fs/promises';
2
+ import { spawnCommandInGhWorkspace } from './utils.js';
3
+ export const getPushData = async (path) => {
4
+ const event = await loadGitHubEvent(path);
5
+ const branch = event.ref.replace('refs/heads/', '');
6
+ const { commits: ghCommits, repository: { ssh_url: repoUrl, name }, } = event;
7
+ const commits = ghCommits.map(({ author, message, id, timestamp }) => ({
8
+ author: author.username,
9
+ sha: id,
10
+ message,
11
+ date: timestamp,
12
+ }));
13
+ const changedFiles = getChangedFiles(event);
14
+ const changelog = getChangelogChanges(changedFiles, event);
15
+ return {
16
+ branch,
17
+ commits,
18
+ changedFiles,
19
+ repoUrl,
20
+ changelog,
21
+ repository: name,
22
+ };
23
+ };
24
+ export const loadGitHubEvent = async (path) => {
25
+ const pushEvent = JSON.parse((await fs.readFile(path)).toString());
26
+ return pushEvent;
27
+ };
28
+ const getChangedFiles = ({ after, before }) => {
29
+ const changedFiles = spawnCommandInGhWorkspace(`git diff --name-only ${after}..${before}`);
30
+ return changedFiles.split('\n');
31
+ };
32
+ export const getChangelogChanges = (changedFiles, event) => {
33
+ const changelogPath = 'CHANGELOG.md';
34
+ if (!changedFiles.includes(changelogPath)) {
35
+ return null;
36
+ }
37
+ const { after, before } = event;
38
+ const diff = spawnCommandInGhWorkspace('git', [
39
+ 'diff',
40
+ before,
41
+ after,
42
+ '--',
43
+ changelogPath,
44
+ ]);
45
+ const added = [];
46
+ let startedChangelog = false;
47
+ for (const line of diff.split('\n')) {
48
+ // We should already get only files we care about from getLastCommitDiffForFile but better to double check
49
+ if (line.startsWith('+++') && line.toLowerCase().includes(changelogPath.toLowerCase())) {
50
+ startedChangelog = true;
51
+ continue;
52
+ }
53
+ if (startedChangelog) {
54
+ if (line.startsWith('diff')) {
55
+ break;
56
+ }
57
+ if (line.startsWith('+')) {
58
+ added.push(line.slice(1).trim());
59
+ }
60
+ }
61
+ }
62
+ return added.join('\n').trim();
63
+ };
64
+ //# sourceMappingURL=github.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github.js","sourceRoot":"","sources":["../../bin/github.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,aAAa,CAAC;AAE7B,OAAO,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAEvD,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,EAAE,IAAY,EAAE,EAAE;IAC9C,MAAM,KAAK,GAAG,MAAM,eAAe,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;IACpD,MAAM,EACF,OAAO,EAAE,SAAS,EAClB,UAAU,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,GACzC,GAAG,KAAK,CAAC;IACV,MAAM,OAAO,GAAa,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC;QAC7E,MAAM,EAAE,MAAM,CAAC,QAAQ;QACvB,GAAG,EAAE,EAAE;QACP,OAAO;QACP,IAAI,EAAE,SAAS;KAClB,CAAC,CAAC,CAAC;IACJ,MAAM,YAAY,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;IAC5C,MAAM,SAAS,GAAG,mBAAmB,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;IAC3D,OAAO;QACH,MAAM;QACN,OAAO;QACP,YAAY;QACZ,OAAO;QACP,SAAS;QACT,UAA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ACrF,gBAAgB,GAAG,IAAI,CAAC;YACxB,SAAS;QACb,CAAC;QACD,IAAI,gBAAgB,EAAE,CAAC;YACnB,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC1B,MAAM;YACV,CAAC;YACD,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;gBACvB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;YACrC,CAAC;QACL,CAAC;IACL,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;AACnC,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=main.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../bin/main.ts"],"names":[],"mappings":""}
@@ -0,0 +1,117 @@
1
+ #!/usr/bin/env node
2
+ import process from 'process';
3
+ import yargs from 'yargs';
4
+ import { hideBin } from 'yargs/helpers';
5
+ import { getRepoActors, getChangedActors, spawnCommandInGhWorkspace, } from './utils.js';
6
+ import { runBuilds } from './build.js';
7
+ import { getChangedFiles, getCommits } from './git.js';
8
+ import { getPushData } from './github.js';
9
+ import { notifyToSlack } from './slack.js';
10
+ import { reportTestRestuls } from './test-report.js';
11
+ const buildOptions = (y) => {
12
+ return y
13
+ .option('target-branch', {
14
+ type: 'string',
15
+ demandOption: true,
16
+ })
17
+ .option('source-branch', {
18
+ type: 'string',
19
+ demandOption: true,
20
+ })
21
+ .option('base-commit', {
22
+ type: 'string',
23
+ });
24
+ };
25
+ await yargs()
26
+ .scriptName('public-actors-utils')
27
+ .option('dry-run', {
28
+ type: 'boolean',
29
+ default: false,
30
+ })
31
+ .command('get-commits', '', buildOptions, (args) => {
32
+ const commits = getCommits(args);
33
+ console.log(JSON.stringify(commits));
34
+ })
35
+ .command('get-latest-commit', '', buildOptions, (args) => {
36
+ const commits = getCommits(args);
37
+ if (commits.length > 0) {
38
+ console.log(JSON.stringify(commits[commits.length - 1]));
39
+ }
40
+ })
41
+ .command('get-changed-files', '', buildOptions, (args) => {
42
+ const commits = getCommits(args);
43
+ const changedFiles = getChangedFiles(commits);
44
+ console.log(JSON.stringify(changedFiles));
45
+ })
46
+ .command('get-actor-configs', '', (_) => _, async () => {
47
+ const actorConfigs = await getRepoActors();
48
+ console.log(JSON.stringify(actorConfigs));
49
+ })
50
+ .command('get-affected-actors', '', buildOptions, async (args) => {
51
+ const commits = getCommits(args);
52
+ const changedFiles = getChangedFiles(commits);
53
+ const actorConfigs = await getRepoActors();
54
+ const { actorsChanged } = getChangedActors({ filepathsChanged: changedFiles, actorConfigs, isLatest: false });
55
+ console.log(JSON.stringify(actorsChanged));
56
+ })
57
+ .command('report-tests', '', (args) => args
58
+ .option('report-file', { type: 'string', demandOption: true })
59
+ .option('job-url', { type: 'string' })
60
+ .option('workflow-name', { type: 'string' })
61
+ .option('repository', { type: 'string' }), async (args) => {
62
+ await reportTestRestuls(args);
63
+ })
64
+ .command('build', '', (args) => buildOptions(args)
65
+ .option('dry-run', { type: 'boolean', default: false }), async (args) => {
66
+ const commits = getCommits(args);
67
+ const changedFiles = getChangedFiles(commits);
68
+ const actorConfigs = await getRepoActors();
69
+ const { actorsChanged } = getChangedActors({
70
+ filepathsChanged: changedFiles,
71
+ actorConfigs,
72
+ });
73
+ // https://github.com/apify-store/google-maps#:actors/lukaskrivka_google-maps-with-contact-details
74
+ // git@github.com:apify-store/google-maps#:actors/lukaskrivka_google-maps-with-contact-details
75
+ const repoUrl = spawnCommandInGhWorkspace(`git remote get-url origin`)
76
+ .replace(/^https:\/\/github\.com\//, 'git@github.com:');
77
+ const builds = await runBuilds({
78
+ repoUrl,
79
+ actorConfigs: actorsChanged,
80
+ branch: args.sourceBranch.replace('origin/', ''),
81
+ dryRun: args.dryRun,
82
+ });
83
+ console.log(JSON.stringify(builds));
84
+ })
85
+ .command('release', '', (args) => args
86
+ .option('push-event-path', { type: 'string', demandOption: true })
87
+ .option('dry-run', { type: 'boolean', default: false }), async (args) => {
88
+ const { branch, changedFiles, repoUrl, commits, changelog, repository, } = await getPushData(args.pushEventPath);
89
+ const isLatest = true;
90
+ const actorConfigs = await getRepoActors();
91
+ const { actorsChanged } = getChangedActors({
92
+ filepathsChanged: changedFiles,
93
+ actorConfigs,
94
+ isLatest,
95
+ });
96
+ const { dryRun } = args;
97
+ const builds = await runBuilds({
98
+ isLatest,
99
+ repoUrl,
100
+ actorConfigs: actorsChanged,
101
+ branch,
102
+ dryRun,
103
+ });
104
+ console.error(JSON.stringify(builds));
105
+ // TODO: build circle actors
106
+ await notifyToSlack({
107
+ changedFiles,
108
+ commits,
109
+ changelog,
110
+ repository,
111
+ dryRun,
112
+ });
113
+ })
114
+ .strictCommands()
115
+ .demandCommand(1, 'Command is required')
116
+ .parse(hideBin(process.argv));
117
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../../bin/main.ts"],"names":[],"mappings":";AAEA,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EACH,aAAa,EACb,gBAAgB,EAChB,yBAAyB,GAC5B,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,MAAM,YAAY,GAAG,CAAC,CAAa,EAAE,EAAE;I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;IACX,MAAM,EACF,MAAM,EACN,YAAY,EACZ,OAAO,EACP,OAAO,EACP,SAAS,EACT,UAAU,GACb,GAAG,MAAM,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC1C,MAAM,QAAQ,GAAG,IAAI,CAAC;IACtB,MAAM,YAAY,GAAG,MAAM,aAAa,EAAE,CAAC;IAC3C,MAAM,EAAE,aAAa,EAAE,GAAG,gBAAgB,CAAC;QACvC,gBAAgB,EAAE,YAAY;QAC9B,YAAY;QACZ,QAAQ;KACX,CAAC,CAAC;IACH,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACxB,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC;QAC3B,QAAQ;QACR,OAAO;QACP,YAAY,EAAE,aAAa;QAC3B,MAAM;QACN,MAAM;KACT,CAAC,CAAC;IACH,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;IAEtC,4BAA4B;IAC5B,MAAM,aAAa,CAAC;QAChB,YAAY;QACZ,OAAO;QACP,SAAS;QACT,UAAU;QACV,MAAM;KACT,CAAC,CAAC;AACP,CAAC,CAAC;KACL,cAAc,EAAE;KAChB,aAAa,CAAC,CAAC,EAAE,qBAAqB,CAAC;KACvC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { Commit } from './types';
2
+ type NotifyToSlackOptions = {
3
+ repository: string;
4
+ changedFiles: string[];
5
+ changelog: string | null;
6
+ commits: Commit[];
7
+ dryRun: boolean;
8
+ };
9
+ export declare const notifyToSlack: ({ changedFiles, commits, changelog, repository, dryRun, }: NotifyToSlackOptions) => Promise<void>;
10
+ export declare const sendSlackMessage: (channel: string, text: string, blocks: string[], token: string) => Promise<void>;
11
+ export {};
12
+ //# sourceMappingURL=slack.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slack.d.ts","sourceRoot":"","sources":["../../bin/slack.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAGjC,KAAK,oBAAoB,GAAG;IACxB,UAAU,EAAE,MAAM,CAAA;IAClB,YAAY,EAAE,MAAM,EAAE,CAAA;IACtB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,MAAM,EAAE,OAAO,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,aAAa,8DAMvB,oBAAoB,kBAoCtB,CAAC;AAEF,eAAO,MAAM,gBAAgB,YAChB,MAAM,QACT,MAAM,UACJ,MAAM,EAAE,SACT,MAAM,kBAWhB,CAAC"}
@@ -0,0 +1,46 @@
1
+ import { WebClient } from '@slack/web-api';
2
+ import { getEnvVar } from './utils.js';
3
+ export const notifyToSlack = async ({ changedFiles, commits, changelog, repository, dryRun, }) => {
4
+ const slack = new WebClient(getEnvVar('SLACK_TOKEN_RELEASES_BOT'));
5
+ if (!changelog) {
6
+ console.warn('No new changelog entries found, haven\'t you forgotten to update it?');
7
+ }
8
+ let shortMessage = `${repository}: new release:\n`;
9
+ // This one is just for broader public that only cares about public facing changes
10
+ if (changelog) {
11
+ console.error(`New changelog entries: ${changelog}`);
12
+ shortMessage += `Changelog:\n\n${changelog}\n`;
13
+ const channel = '#delivery-public-actors';
14
+ console.error(`Sending slack message to channel: ${channel}. Message: ${shortMessage}`);
15
+ if (!dryRun) {
16
+ await slack.chat.postMessage({
17
+ channel,
18
+ text: shortMessage,
19
+ });
20
+ }
21
+ }
22
+ const commitsMessage = `${commits.map(({ author, message }, index) => ` ${index + 1} Commit message: ${message}\n Author: ${author}.`).join('\n')}`;
23
+ const changedFilesMessage = `Files changed: ${changedFiles.join(', ')}`;
24
+ const longMessage = `${shortMessage}\nCommits:\n\n${commitsMessage}\n\n${changedFilesMessage}`;
25
+ // This one is for devs and project managers that need to know more details
26
+ const notifChannel = `#notif-${repository.toLowerCase()}`;
27
+ console.error(`Sending slack message to channel: ${notifChannel}. Message: ${longMessage}`);
28
+ if (!dryRun) {
29
+ await slack.chat.postMessage({
30
+ text: longMessage,
31
+ channel: notifChannel,
32
+ });
33
+ }
34
+ };
35
+ export const sendSlackMessage = async (channel, text, blocks, token) => {
36
+ const slack = new WebClient(token);
37
+ const { ts } = await slack.chat.postMessage({ text, channel });
38
+ if (blocks.length > 0 && ts) {
39
+ await slack.chat.postMessage({
40
+ channel,
41
+ thread_ts: ts,
42
+ blocks: blocks.map((t) => ({ text: { type: 'mrkdwn', text: t }, type: 'section' })),
43
+ });
44
+ }
45
+ };
46
+ //# sourceMappingURL=slack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slack.js","sourceRoot":"","sources":["../../bin/slack.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAUvC,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAAE,EAChC,YAAY,EACZ,OAAO,EACP,SAAS,EACT,UAAU,EACV,MAAM,GACa,EAAE,EAAE;IACvB,MAAM,KAAK,GAAG,IAAI,SAAS,CAAC,SAAS,CAAC,0BAA0B,CAAC,CAAC,CAAC;IAEnE,IAAI,CAAC,SAAS,EAAE,CAAC;QACb,OAAO,CAAC,IAAI,CAAC,sEAAsE,CAAC,CAAC;IACzF,CAAC;IAED,IAAI,YAAY,GAAG,GAAG,UAAU,kBAAkB,CAAC;IAEnD,kFAAkF;IAClF,IAAI,SAAS,EAAE,CAAC;QACZ,OAAO,CAAC,KAAK,CAAC,0BAA0B,SAAS,EAAE,CAAC,CAAC;QACrD,YAAY,IAAI,iBAAiB,SAAS,IAAI,CAAC;QAC/C,MAAM,OAAO,GAAG,yBAAyB,CAAC;QAC1C,OAAO,CAAC,KAAK,CAAC,qCAAqC,OAAO,cAAc,YAAY,EAAE,CAAC,CAAC;QACxF,IAAI,CAAC,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,CAAC,IAAI,CAAC,WAAW,CAAC;YACzB,OAAO;YACP,SAAS,EAAE,EAAE;YACb,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;SACtF,CAAC,CAAC;IACP,CAAC;AACL,CAAC,CAAC"}
@@ -0,0 +1,10 @@
1
+ interface ReportTestRestulsOptions {
2
+ reportFile: string;
3
+ dryRun: boolean;
4
+ jobUrl?: string;
5
+ repository?: string;
6
+ workflowName?: string;
7
+ }
8
+ export declare const reportTestRestuls: ({ dryRun, reportFile: jsonResultsPath, jobUrl, workflowName, repository, }: ReportTestRestulsOptions) => Promise<void>;
9
+ export {};
10
+ //# sourceMappingURL=test-report.d.ts.map