@argos-ci/core 4.5.0 → 5.0.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.
- package/dist/index.d.ts +13 -6
- package/dist/index.js +75 -52
- package/package.json +7 -7
- package/LICENSE +0 -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,
|
|
@@ -851,7 +857,8 @@ async function readConfig(options = {}) {
|
|
|
851
857
|
mode: options.mode || defaultConfig.mode || null,
|
|
852
858
|
ciProvider: ciEnv?.key || null,
|
|
853
859
|
previewBaseUrl: defaultConfig.previewBaseUrl || null,
|
|
854
|
-
skipped: options.skipped ?? defaultConfig.skipped ?? false
|
|
860
|
+
skipped: options.skipped ?? defaultConfig.skipped ?? false,
|
|
861
|
+
mergeQueue: ciEnv?.mergeQueue ?? false
|
|
855
862
|
});
|
|
856
863
|
if (!config.get("branch") || !config.get("commit")) {
|
|
857
864
|
throw new Error(
|
|
@@ -937,7 +944,7 @@ async function finalize(params) {
|
|
|
937
944
|
}
|
|
938
945
|
|
|
939
946
|
// src/upload.ts
|
|
940
|
-
import { createClient as
|
|
947
|
+
import { createClient as createClient3, throwAPIError as throwAPIError3 } from "@argos-ci/api-client";
|
|
941
948
|
|
|
942
949
|
// src/discovery.ts
|
|
943
950
|
import { extname, resolve } from "path";
|
|
@@ -1102,6 +1109,44 @@ function getSnapshotMimeType(filepath) {
|
|
|
1102
1109
|
return type;
|
|
1103
1110
|
}
|
|
1104
1111
|
|
|
1112
|
+
// src/skip.ts
|
|
1113
|
+
import { createClient as createClient2, throwAPIError as throwAPIError2 } from "@argos-ci/api-client";
|
|
1114
|
+
async function skip(params) {
|
|
1115
|
+
const [config, argosSdk] = await Promise.all([
|
|
1116
|
+
getConfigFromOptions(params),
|
|
1117
|
+
getArgosCoreSDKIdentifier()
|
|
1118
|
+
]);
|
|
1119
|
+
const authToken = getAuthToken(config);
|
|
1120
|
+
const apiClient = createClient2({
|
|
1121
|
+
baseUrl: config.apiBaseUrl,
|
|
1122
|
+
authToken
|
|
1123
|
+
});
|
|
1124
|
+
const createBuildResponse = await apiClient.POST("/builds", {
|
|
1125
|
+
body: {
|
|
1126
|
+
commit: config.commit,
|
|
1127
|
+
branch: config.branch,
|
|
1128
|
+
name: config.buildName,
|
|
1129
|
+
mode: config.mode,
|
|
1130
|
+
prNumber: config.prNumber,
|
|
1131
|
+
prHeadCommit: config.prHeadCommit,
|
|
1132
|
+
referenceBranch: config.referenceBranch,
|
|
1133
|
+
referenceCommit: config.referenceCommit,
|
|
1134
|
+
argosSdk,
|
|
1135
|
+
ciProvider: config.ciProvider,
|
|
1136
|
+
runId: config.runId,
|
|
1137
|
+
runAttempt: config.runAttempt,
|
|
1138
|
+
skipped: true,
|
|
1139
|
+
screenshotKeys: [],
|
|
1140
|
+
pwTraceKeys: [],
|
|
1141
|
+
parentCommits: []
|
|
1142
|
+
}
|
|
1143
|
+
});
|
|
1144
|
+
if (createBuildResponse.error) {
|
|
1145
|
+
throwAPIError2(createBuildResponse.error);
|
|
1146
|
+
}
|
|
1147
|
+
return { build: createBuildResponse.data.build };
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1105
1150
|
// src/upload.ts
|
|
1106
1151
|
var CHUNK_SIZE = 10;
|
|
1107
1152
|
async function upload(params) {
|
|
@@ -1111,37 +1156,13 @@ async function upload(params) {
|
|
|
1111
1156
|
getArgosCoreSDKIdentifier()
|
|
1112
1157
|
]);
|
|
1113
1158
|
const authToken = getAuthToken(config);
|
|
1114
|
-
const apiClient =
|
|
1159
|
+
const apiClient = createClient3({
|
|
1115
1160
|
baseUrl: config.apiBaseUrl,
|
|
1116
1161
|
authToken
|
|
1117
1162
|
});
|
|
1118
1163
|
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: [] };
|
|
1164
|
+
const { build } = await skip(params);
|
|
1165
|
+
return { build, screenshots: [] };
|
|
1145
1166
|
}
|
|
1146
1167
|
const previewUrlFormatter = params.previewUrl ?? (config.previewBaseUrl ? { baseUrl: config.previewBaseUrl } : void 0);
|
|
1147
1168
|
const globs = params.files ?? ["**/*.{png,jpg,jpeg}"];
|
|
@@ -1191,7 +1212,7 @@ async function upload(params) {
|
|
|
1191
1212
|
debug("Fetch project");
|
|
1192
1213
|
const projectResponse = await apiClient.GET("/project");
|
|
1193
1214
|
if (projectResponse.error) {
|
|
1194
|
-
|
|
1215
|
+
throwAPIError3(projectResponse.error);
|
|
1195
1216
|
}
|
|
1196
1217
|
debug("Project fetched", projectResponse.data);
|
|
1197
1218
|
const { defaultBaseBranch, hasRemoteContentAccess } = projectResponse.data;
|
|
@@ -1258,11 +1279,12 @@ async function upload(params) {
|
|
|
1258
1279
|
argosSdk,
|
|
1259
1280
|
ciProvider: config.ciProvider,
|
|
1260
1281
|
runId: config.runId,
|
|
1261
|
-
runAttempt: config.runAttempt
|
|
1282
|
+
runAttempt: config.runAttempt,
|
|
1283
|
+
mergeQueue: config.mergeQueue
|
|
1262
1284
|
}
|
|
1263
1285
|
});
|
|
1264
1286
|
if (createBuildResponse.error) {
|
|
1265
|
-
|
|
1287
|
+
throwAPIError3(createBuildResponse.error);
|
|
1266
1288
|
}
|
|
1267
1289
|
const result = createBuildResponse.data;
|
|
1268
1290
|
debug("Got uploads url", result);
|
|
@@ -1318,7 +1340,7 @@ async function upload(params) {
|
|
|
1318
1340
|
}
|
|
1319
1341
|
});
|
|
1320
1342
|
if (uploadBuildResponse.error) {
|
|
1321
|
-
|
|
1343
|
+
throwAPIError3(uploadBuildResponse.error);
|
|
1322
1344
|
}
|
|
1323
1345
|
return { build: uploadBuildResponse.data.build, screenshots: snapshots };
|
|
1324
1346
|
}
|
|
@@ -1360,5 +1382,6 @@ export {
|
|
|
1360
1382
|
finalize,
|
|
1361
1383
|
getConfigFromOptions,
|
|
1362
1384
|
readConfig,
|
|
1385
|
+
skip,
|
|
1363
1386
|
upload
|
|
1364
1387
|
};
|
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.0",
|
|
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": "d460ccc12fe75b1d9389d58647f1906bee7d5e0d"
|
|
71
71
|
}
|
package/LICENSE
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
Copyright 2022 Smooth Code
|
|
2
|
-
|
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
-
|
|
5
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
-
|
|
7
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|