@argos-ci/core 4.5.0 → 5.0.1
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/dist/index.d.ts +13 -6
- package/dist/index.js +79 -52
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -116,6 +116,10 @@ interface Config {
|
|
|
116
116
|
* No screenshots are uploaded, and the commit status is marked as success.
|
|
117
117
|
*/
|
|
118
118
|
skipped?: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Whether the environment is a merge queue.
|
|
121
|
+
*/
|
|
122
|
+
mergeQueue?: boolean;
|
|
119
123
|
}
|
|
120
124
|
declare function readConfig(options?: Partial<Config>): Promise<Config>;
|
|
121
125
|
declare function getConfigFromOptions({ parallel, ...options }: Omit<Partial<Config>, "parallel"> & {
|
|
@@ -397,11 +401,6 @@ interface UploadParameters {
|
|
|
397
401
|
previewUrl?: {
|
|
398
402
|
baseUrl: string;
|
|
399
403
|
} | ((url: string) => string);
|
|
400
|
-
/**
|
|
401
|
-
* Mark this build as skipped.
|
|
402
|
-
* No screenshots are uploaded, and the commit status is marked as success.
|
|
403
|
-
*/
|
|
404
|
-
skipped?: boolean;
|
|
405
404
|
}
|
|
406
405
|
interface Screenshot {
|
|
407
406
|
hash: string;
|
|
@@ -424,4 +423,12 @@ declare function upload(params: UploadParameters): Promise<{
|
|
|
424
423
|
screenshots: Screenshot[];
|
|
425
424
|
}>;
|
|
426
425
|
|
|
427
|
-
|
|
426
|
+
type SkipParameters = Pick<UploadParameters, "apiBaseUrl" | "commit" | "branch" | "token" | "prNumber" | "buildName" | "metadata">;
|
|
427
|
+
/**
|
|
428
|
+
* Mark a build as skipped.
|
|
429
|
+
*/
|
|
430
|
+
declare function skip(params: SkipParameters): Promise<{
|
|
431
|
+
build: ArgosAPISchema.components["schemas"]["Build"];
|
|
432
|
+
}>;
|
|
433
|
+
|
|
434
|
+
export { type Config, type FinalizeParameters, type UploadParameters, finalize, getConfigFromOptions, readConfig, skip, upload };
|
package/dist/index.js
CHANGED
|
@@ -151,7 +151,8 @@ var service = {
|
|
|
151
151
|
prNumber: getPrNumber({ env }),
|
|
152
152
|
prHeadCommit: null,
|
|
153
153
|
prBaseBranch: null,
|
|
154
|
-
nonce: env.BITRISEIO_PIPELINE_ID || null
|
|
154
|
+
nonce: env.BITRISEIO_PIPELINE_ID || null,
|
|
155
|
+
mergeQueue: false
|
|
155
156
|
};
|
|
156
157
|
},
|
|
157
158
|
getMergeBaseCommitSha,
|
|
@@ -201,7 +202,8 @@ var service2 = {
|
|
|
201
202
|
prNumber: env.BUILDKITE_PULL_REQUEST ? Number(env.BUILDKITE_PULL_REQUEST) : null,
|
|
202
203
|
prHeadCommit: null,
|
|
203
204
|
prBaseBranch: null,
|
|
204
|
-
nonce: env.BUILDKITE_BUILD_ID || null
|
|
205
|
+
nonce: env.BUILDKITE_BUILD_ID || null,
|
|
206
|
+
mergeQueue: false
|
|
205
207
|
};
|
|
206
208
|
},
|
|
207
209
|
getMergeBaseCommitSha,
|
|
@@ -226,7 +228,8 @@ var service3 = {
|
|
|
226
228
|
prNumber: null,
|
|
227
229
|
prHeadCommit: null,
|
|
228
230
|
prBaseBranch: null,
|
|
229
|
-
nonce: env.HEROKU_TEST_RUN_ID || null
|
|
231
|
+
nonce: env.HEROKU_TEST_RUN_ID || null,
|
|
232
|
+
mergeQueue: false
|
|
230
233
|
}),
|
|
231
234
|
getMergeBaseCommitSha,
|
|
232
235
|
listParentCommits
|
|
@@ -353,19 +356,16 @@ function getPullRequestFromPayload(payload) {
|
|
|
353
356
|
return null;
|
|
354
357
|
}
|
|
355
358
|
function getVercelDeploymentPayload(payload) {
|
|
356
|
-
if (
|
|
357
|
-
return
|
|
358
|
-
}
|
|
359
|
-
if (process.env.GITHUB_EVENT_NAME !== "repository_dispatch") {
|
|
360
|
-
return null;
|
|
359
|
+
if (process.env.GITHUB_EVENT_NAME === "repository_dispatch" && payload && "action" in payload && payload.action === "vercel.deployment.success") {
|
|
360
|
+
return payload;
|
|
361
361
|
}
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
if (payload.action
|
|
366
|
-
return
|
|
362
|
+
return null;
|
|
363
|
+
}
|
|
364
|
+
function getMergeGroupPayload(payload) {
|
|
365
|
+
if (payload && process.env.GITHUB_EVENT_NAME === "merge_group" && "action" in payload && payload.action === "checks_requested") {
|
|
366
|
+
return payload;
|
|
367
367
|
}
|
|
368
|
-
return
|
|
368
|
+
return null;
|
|
369
369
|
}
|
|
370
370
|
function getSha(context, vercelPayload) {
|
|
371
371
|
if (vercelPayload) {
|
|
@@ -384,6 +384,7 @@ var service4 = {
|
|
|
384
384
|
const { env } = context;
|
|
385
385
|
const payload = readEventPayload(context);
|
|
386
386
|
const vercelPayload = getVercelDeploymentPayload(payload);
|
|
387
|
+
const mergeGroupPayload = getMergeGroupPayload(payload);
|
|
387
388
|
const sha = getSha(context, vercelPayload);
|
|
388
389
|
const pullRequest = payload && !vercelPayload ? getPullRequestFromPayload(payload) : await getPullRequestFromHeadSha(context, sha);
|
|
389
390
|
return {
|
|
@@ -397,7 +398,8 @@ var service4 = {
|
|
|
397
398
|
branch: vercelPayload?.client_payload?.git?.ref || getBranchFromContext(context) || pullRequest?.head.ref || (payload ? getBranchFromPayload(payload) : null) || null,
|
|
398
399
|
prNumber: pullRequest?.number || null,
|
|
399
400
|
prHeadCommit: pullRequest?.head.sha ?? null,
|
|
400
|
-
prBaseBranch: pullRequest?.base.ref ?? null
|
|
401
|
+
prBaseBranch: pullRequest?.base.ref ?? null,
|
|
402
|
+
mergeQueue: mergeGroupPayload?.action === "checks_requested"
|
|
401
403
|
};
|
|
402
404
|
},
|
|
403
405
|
getMergeBaseCommitSha,
|
|
@@ -445,7 +447,8 @@ var service5 = {
|
|
|
445
447
|
prNumber: getPrNumber2({ env }),
|
|
446
448
|
prHeadCommit: null,
|
|
447
449
|
prBaseBranch: null,
|
|
448
|
-
nonce: env.CIRCLE_WORKFLOW_ID || env.CIRCLE_BUILD_NUM || null
|
|
450
|
+
nonce: env.CIRCLE_WORKFLOW_ID || env.CIRCLE_BUILD_NUM || null,
|
|
451
|
+
mergeQueue: false
|
|
449
452
|
};
|
|
450
453
|
},
|
|
451
454
|
getMergeBaseCommitSha,
|
|
@@ -489,7 +492,8 @@ var service6 = {
|
|
|
489
492
|
prNumber: getPrNumber3(ctx),
|
|
490
493
|
prHeadCommit: null,
|
|
491
494
|
prBaseBranch: null,
|
|
492
|
-
nonce: env.TRAVIS_BUILD_ID || null
|
|
495
|
+
nonce: env.TRAVIS_BUILD_ID || null,
|
|
496
|
+
mergeQueue: false
|
|
493
497
|
};
|
|
494
498
|
},
|
|
495
499
|
getMergeBaseCommitSha,
|
|
@@ -526,7 +530,8 @@ var service7 = {
|
|
|
526
530
|
prNumber: null,
|
|
527
531
|
prHeadCommit: null,
|
|
528
532
|
prBaseBranch: null,
|
|
529
|
-
nonce: env.CI_PIPELINE_ID || null
|
|
533
|
+
nonce: env.CI_PIPELINE_ID || null,
|
|
534
|
+
mergeQueue: false
|
|
530
535
|
};
|
|
531
536
|
},
|
|
532
537
|
getMergeBaseCommitSha,
|
|
@@ -559,7 +564,8 @@ var service8 = {
|
|
|
559
564
|
prNumber: null,
|
|
560
565
|
prHeadCommit: null,
|
|
561
566
|
prBaseBranch: null,
|
|
562
|
-
nonce: null
|
|
567
|
+
nonce: null,
|
|
568
|
+
mergeQueue: false
|
|
563
569
|
};
|
|
564
570
|
},
|
|
565
571
|
getMergeBaseCommitSha,
|
|
@@ -810,6 +816,10 @@ var schema = {
|
|
|
810
816
|
env: "ARGOS_SKIPPED",
|
|
811
817
|
format: Boolean,
|
|
812
818
|
default: false
|
|
819
|
+
},
|
|
820
|
+
mergeQueue: {
|
|
821
|
+
format: Boolean,
|
|
822
|
+
default: false
|
|
813
823
|
}
|
|
814
824
|
};
|
|
815
825
|
function createConfig() {
|
|
@@ -851,7 +861,8 @@ async function readConfig(options = {}) {
|
|
|
851
861
|
mode: options.mode || defaultConfig.mode || null,
|
|
852
862
|
ciProvider: ciEnv?.key || null,
|
|
853
863
|
previewBaseUrl: defaultConfig.previewBaseUrl || null,
|
|
854
|
-
skipped: options.skipped ?? defaultConfig.skipped ?? false
|
|
864
|
+
skipped: options.skipped ?? defaultConfig.skipped ?? false,
|
|
865
|
+
mergeQueue: ciEnv?.mergeQueue ?? false
|
|
855
866
|
});
|
|
856
867
|
if (!config.get("branch") || !config.get("commit")) {
|
|
857
868
|
throw new Error(
|
|
@@ -937,7 +948,7 @@ async function finalize(params) {
|
|
|
937
948
|
}
|
|
938
949
|
|
|
939
950
|
// src/upload.ts
|
|
940
|
-
import { createClient as
|
|
951
|
+
import { createClient as createClient3, throwAPIError as throwAPIError3 } from "@argos-ci/api-client";
|
|
941
952
|
|
|
942
953
|
// src/discovery.ts
|
|
943
954
|
import { extname, resolve } from "path";
|
|
@@ -1102,6 +1113,44 @@ function getSnapshotMimeType(filepath) {
|
|
|
1102
1113
|
return type;
|
|
1103
1114
|
}
|
|
1104
1115
|
|
|
1116
|
+
// src/skip.ts
|
|
1117
|
+
import { createClient as createClient2, throwAPIError as throwAPIError2 } from "@argos-ci/api-client";
|
|
1118
|
+
async function skip(params) {
|
|
1119
|
+
const [config, argosSdk] = await Promise.all([
|
|
1120
|
+
getConfigFromOptions(params),
|
|
1121
|
+
getArgosCoreSDKIdentifier()
|
|
1122
|
+
]);
|
|
1123
|
+
const authToken = getAuthToken(config);
|
|
1124
|
+
const apiClient = createClient2({
|
|
1125
|
+
baseUrl: config.apiBaseUrl,
|
|
1126
|
+
authToken
|
|
1127
|
+
});
|
|
1128
|
+
const createBuildResponse = await apiClient.POST("/builds", {
|
|
1129
|
+
body: {
|
|
1130
|
+
commit: config.commit,
|
|
1131
|
+
branch: config.branch,
|
|
1132
|
+
name: config.buildName,
|
|
1133
|
+
mode: config.mode,
|
|
1134
|
+
prNumber: config.prNumber,
|
|
1135
|
+
prHeadCommit: config.prHeadCommit,
|
|
1136
|
+
referenceBranch: config.referenceBranch,
|
|
1137
|
+
referenceCommit: config.referenceCommit,
|
|
1138
|
+
argosSdk,
|
|
1139
|
+
ciProvider: config.ciProvider,
|
|
1140
|
+
runId: config.runId,
|
|
1141
|
+
runAttempt: config.runAttempt,
|
|
1142
|
+
skipped: true,
|
|
1143
|
+
screenshotKeys: [],
|
|
1144
|
+
pwTraceKeys: [],
|
|
1145
|
+
parentCommits: []
|
|
1146
|
+
}
|
|
1147
|
+
});
|
|
1148
|
+
if (createBuildResponse.error) {
|
|
1149
|
+
throwAPIError2(createBuildResponse.error);
|
|
1150
|
+
}
|
|
1151
|
+
return { build: createBuildResponse.data.build };
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1105
1154
|
// src/upload.ts
|
|
1106
1155
|
var CHUNK_SIZE = 10;
|
|
1107
1156
|
async function upload(params) {
|
|
@@ -1111,37 +1160,13 @@ async function upload(params) {
|
|
|
1111
1160
|
getArgosCoreSDKIdentifier()
|
|
1112
1161
|
]);
|
|
1113
1162
|
const authToken = getAuthToken(config);
|
|
1114
|
-
const apiClient =
|
|
1163
|
+
const apiClient = createClient3({
|
|
1115
1164
|
baseUrl: config.apiBaseUrl,
|
|
1116
1165
|
authToken
|
|
1117
1166
|
});
|
|
1118
1167
|
if (config.skipped) {
|
|
1119
|
-
const
|
|
1120
|
-
|
|
1121
|
-
commit: config.commit,
|
|
1122
|
-
branch: config.branch,
|
|
1123
|
-
name: config.buildName,
|
|
1124
|
-
mode: config.mode,
|
|
1125
|
-
parallel: config.parallel,
|
|
1126
|
-
parallelNonce: config.parallelNonce,
|
|
1127
|
-
prNumber: config.prNumber,
|
|
1128
|
-
prHeadCommit: config.prHeadCommit,
|
|
1129
|
-
referenceBranch: config.referenceBranch,
|
|
1130
|
-
referenceCommit: config.referenceCommit,
|
|
1131
|
-
argosSdk,
|
|
1132
|
-
ciProvider: config.ciProvider,
|
|
1133
|
-
runId: config.runId,
|
|
1134
|
-
runAttempt: config.runAttempt,
|
|
1135
|
-
skipped: true,
|
|
1136
|
-
screenshotKeys: [],
|
|
1137
|
-
pwTraceKeys: [],
|
|
1138
|
-
parentCommits: []
|
|
1139
|
-
}
|
|
1140
|
-
});
|
|
1141
|
-
if (createBuildResponse2.error) {
|
|
1142
|
-
throwAPIError2(createBuildResponse2.error);
|
|
1143
|
-
}
|
|
1144
|
-
return { build: createBuildResponse2.data.build, screenshots: [] };
|
|
1168
|
+
const { build } = await skip(params);
|
|
1169
|
+
return { build, screenshots: [] };
|
|
1145
1170
|
}
|
|
1146
1171
|
const previewUrlFormatter = params.previewUrl ?? (config.previewBaseUrl ? { baseUrl: config.previewBaseUrl } : void 0);
|
|
1147
1172
|
const globs = params.files ?? ["**/*.{png,jpg,jpeg}"];
|
|
@@ -1191,7 +1216,7 @@ async function upload(params) {
|
|
|
1191
1216
|
debug("Fetch project");
|
|
1192
1217
|
const projectResponse = await apiClient.GET("/project");
|
|
1193
1218
|
if (projectResponse.error) {
|
|
1194
|
-
|
|
1219
|
+
throwAPIError3(projectResponse.error);
|
|
1195
1220
|
}
|
|
1196
1221
|
debug("Project fetched", projectResponse.data);
|
|
1197
1222
|
const { defaultBaseBranch, hasRemoteContentAccess } = projectResponse.data;
|
|
@@ -1258,11 +1283,12 @@ async function upload(params) {
|
|
|
1258
1283
|
argosSdk,
|
|
1259
1284
|
ciProvider: config.ciProvider,
|
|
1260
1285
|
runId: config.runId,
|
|
1261
|
-
runAttempt: config.runAttempt
|
|
1286
|
+
runAttempt: config.runAttempt,
|
|
1287
|
+
mergeQueue: config.mergeQueue
|
|
1262
1288
|
}
|
|
1263
1289
|
});
|
|
1264
1290
|
if (createBuildResponse.error) {
|
|
1265
|
-
|
|
1291
|
+
throwAPIError3(createBuildResponse.error);
|
|
1266
1292
|
}
|
|
1267
1293
|
const result = createBuildResponse.data;
|
|
1268
1294
|
debug("Got uploads url", result);
|
|
@@ -1318,7 +1344,7 @@ async function upload(params) {
|
|
|
1318
1344
|
}
|
|
1319
1345
|
});
|
|
1320
1346
|
if (uploadBuildResponse.error) {
|
|
1321
|
-
|
|
1347
|
+
throwAPIError3(uploadBuildResponse.error);
|
|
1322
1348
|
}
|
|
1323
1349
|
return { build: uploadBuildResponse.data.build, screenshots: snapshots };
|
|
1324
1350
|
}
|
|
@@ -1360,5 +1386,6 @@ export {
|
|
|
1360
1386
|
finalize,
|
|
1361
1387
|
getConfigFromOptions,
|
|
1362
1388
|
readConfig,
|
|
1389
|
+
skip,
|
|
1363
1390
|
upload
|
|
1364
1391
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@argos-ci/core",
|
|
3
3
|
"description": "Node.js SDK for visual testing with Argos.",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "5.0.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
7
7
|
"exports": {
|
|
@@ -40,23 +40,23 @@
|
|
|
40
40
|
"access": "public"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@argos-ci/api-client": "0.
|
|
43
|
+
"@argos-ci/api-client": "0.15.0",
|
|
44
44
|
"@argos-ci/util": "3.2.0",
|
|
45
45
|
"convict": "^6.2.4",
|
|
46
46
|
"debug": "^4.4.3",
|
|
47
47
|
"fast-glob": "^3.3.3",
|
|
48
|
-
"mime-types": "^3.0.
|
|
49
|
-
"sharp": "^0.34.
|
|
48
|
+
"mime-types": "^3.0.2",
|
|
49
|
+
"sharp": "^0.34.5",
|
|
50
50
|
"tmp": "^0.2.5"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@octokit/webhooks": "^14.
|
|
53
|
+
"@octokit/webhooks": "^14.2.0",
|
|
54
54
|
"@types/convict": "^6.1.6",
|
|
55
55
|
"@types/debug": "^4.1.12",
|
|
56
56
|
"@types/mime-types": "^3.0.1",
|
|
57
57
|
"@types/tmp": "^0.2.6",
|
|
58
58
|
"@vercel/repository-dispatch": "^0.1.0",
|
|
59
|
-
"msw": "^2.
|
|
59
|
+
"msw": "^2.12.4",
|
|
60
60
|
"vitest": "catalog:"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"lint": "eslint .",
|
|
68
68
|
"test": "vitest"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "389e8ae7fe5cd4bf74d2627853b8c62e4b09e86a"
|
|
71
71
|
}
|