@argos-ci/core 2.2.0 → 2.2.1-alpha.7
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 +5 -0
- package/dist/index.mjs +61 -6
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -25,6 +25,8 @@ interface UploadParameters {
|
|
|
25
25
|
nonce: string;
|
|
26
26
|
/** The number of parallel nodes being ran */
|
|
27
27
|
total: number;
|
|
28
|
+
/** The index of the parallel node */
|
|
29
|
+
index?: number;
|
|
28
30
|
} | false;
|
|
29
31
|
/** Branch used as baseline for screenshot comparison */
|
|
30
32
|
referenceBranch?: string;
|
|
@@ -59,6 +61,7 @@ interface Config {
|
|
|
59
61
|
buildName: string | null;
|
|
60
62
|
parallel: boolean;
|
|
61
63
|
parallelNonce: string | null;
|
|
64
|
+
parallelIndex: number | null;
|
|
62
65
|
parallelTotal: number | null;
|
|
63
66
|
referenceBranch: string | null;
|
|
64
67
|
referenceCommit: string | null;
|
|
@@ -66,9 +69,11 @@ interface Config {
|
|
|
66
69
|
repository: string | null;
|
|
67
70
|
jobId: string | null;
|
|
68
71
|
runId: string | null;
|
|
72
|
+
runAttempt: number | null;
|
|
69
73
|
prNumber: number | null;
|
|
70
74
|
prHeadCommit: string | null;
|
|
71
75
|
mode: "ci" | "monitoring" | null;
|
|
76
|
+
ciProvider: string | null;
|
|
72
77
|
}
|
|
73
78
|
declare function readConfig(options?: Partial<Config>): Promise<Config>;
|
|
74
79
|
export { UploadParameters, upload, Config, readConfig };
|
package/dist/index.mjs
CHANGED
|
@@ -10,13 +10,15 @@ import sharp from 'sharp';
|
|
|
10
10
|
import tmp from 'tmp';
|
|
11
11
|
import { createHash } from 'node:crypto';
|
|
12
12
|
import { readFile } from 'node:fs/promises';
|
|
13
|
-
import { readMetadata, getPlaywrightTracePath } from '@argos-ci/util';
|
|
13
|
+
import { readVersionFromPackage, readMetadata, getPlaywrightTracePath } from '@argos-ci/util';
|
|
14
|
+
import { createRequire } from 'node:module';
|
|
14
15
|
|
|
15
16
|
const getPrNumber$2 = ({ env })=>{
|
|
16
17
|
return env.BITRISE_PULL_REQUEST ? Number(env.BITRISE_PULL_REQUEST) : null;
|
|
17
18
|
};
|
|
18
19
|
const service$7 = {
|
|
19
20
|
name: "Bitrise",
|
|
21
|
+
key: "bitrise",
|
|
20
22
|
detect: ({ env })=>Boolean(env.BITRISE_IO),
|
|
21
23
|
config: ({ env })=>{
|
|
22
24
|
return {
|
|
@@ -26,6 +28,7 @@ const service$7 = {
|
|
|
26
28
|
repository: env.BITRISEIO_GIT_REPOSITORY_SLUG || null,
|
|
27
29
|
jobId: null,
|
|
28
30
|
runId: null,
|
|
31
|
+
runAttempt: null,
|
|
29
32
|
prNumber: getPrNumber$2({
|
|
30
33
|
env
|
|
31
34
|
}),
|
|
@@ -69,6 +72,7 @@ const service$7 = {
|
|
|
69
72
|
|
|
70
73
|
const service$6 = {
|
|
71
74
|
name: "Buildkite",
|
|
75
|
+
key: "buildkite",
|
|
72
76
|
detect: ({ env })=>Boolean(env.BUILDKITE),
|
|
73
77
|
config: ({ env })=>{
|
|
74
78
|
return {
|
|
@@ -79,6 +83,7 @@ const service$6 = {
|
|
|
79
83
|
repository: env.BUILDKITE_PROJECT_SLUG || null,
|
|
80
84
|
jobId: null,
|
|
81
85
|
runId: null,
|
|
86
|
+
runAttempt: null,
|
|
82
87
|
prNumber: env.BUILDKITE_PULL_REQUEST ? Number(env.BUILDKITE_PULL_REQUEST) : null,
|
|
83
88
|
prHeadCommit: null,
|
|
84
89
|
nonce: env.BUILDKITE_BUILD_ID || null
|
|
@@ -88,6 +93,7 @@ const service$6 = {
|
|
|
88
93
|
|
|
89
94
|
const service$5 = {
|
|
90
95
|
name: "Heroku",
|
|
96
|
+
key: "heroku",
|
|
91
97
|
detect: ({ env })=>Boolean(env.HEROKU_TEST_RUN_ID),
|
|
92
98
|
config: ({ env })=>({
|
|
93
99
|
commit: env.HEROKU_TEST_RUN_COMMIT_VERSION || null,
|
|
@@ -96,6 +102,7 @@ const service$5 = {
|
|
|
96
102
|
repository: null,
|
|
97
103
|
jobId: null,
|
|
98
104
|
runId: null,
|
|
105
|
+
runAttempt: null,
|
|
99
106
|
prNumber: null,
|
|
100
107
|
prHeadCommit: null,
|
|
101
108
|
nonce: env.HEROKU_TEST_RUN_ID || null
|
|
@@ -194,6 +201,7 @@ const readEventPayload = ({ env })=>{
|
|
|
194
201
|
};
|
|
195
202
|
const service$4 = {
|
|
196
203
|
name: "GitHub Actions",
|
|
204
|
+
key: "github-actions",
|
|
197
205
|
detect: ({ env })=>Boolean(env.GITHUB_ACTIONS),
|
|
198
206
|
config: async ({ env })=>{
|
|
199
207
|
const payload = readEventPayload({
|
|
@@ -211,6 +219,7 @@ const service$4 = {
|
|
|
211
219
|
}),
|
|
212
220
|
jobId: env.GITHUB_JOB || null,
|
|
213
221
|
runId: env.GITHUB_RUN_ID || null,
|
|
222
|
+
runAttempt: env.GITHUB_RUN_ATTEMPT ? Number(env.GITHUB_RUN_ATTEMPT) : null,
|
|
214
223
|
nonce: `${env.GITHUB_RUN_ID}-${env.GITHUB_RUN_ATTEMPT}` || null
|
|
215
224
|
};
|
|
216
225
|
// If the job is triggered by from a "deployment" or a "deployment_status"
|
|
@@ -250,6 +259,7 @@ const getPrNumber$1 = ({ env })=>{
|
|
|
250
259
|
};
|
|
251
260
|
const service$3 = {
|
|
252
261
|
name: "CircleCI",
|
|
262
|
+
key: "circleci",
|
|
253
263
|
detect: ({ env })=>Boolean(env.CIRCLECI),
|
|
254
264
|
config: ({ env })=>{
|
|
255
265
|
return {
|
|
@@ -259,6 +269,7 @@ const service$3 = {
|
|
|
259
269
|
repository: env.CIRCLE_PROJECT_REPONAME || null,
|
|
260
270
|
jobId: null,
|
|
261
271
|
runId: null,
|
|
272
|
+
runAttempt: null,
|
|
262
273
|
prNumber: getPrNumber$1({
|
|
263
274
|
env
|
|
264
275
|
}),
|
|
@@ -282,6 +293,7 @@ const getPrNumber = ({ env })=>{
|
|
|
282
293
|
};
|
|
283
294
|
const service$2 = {
|
|
284
295
|
name: "Travis CI",
|
|
296
|
+
key: "travis",
|
|
285
297
|
detect: ({ env })=>Boolean(env.TRAVIS),
|
|
286
298
|
config: (ctx)=>{
|
|
287
299
|
const { env } = ctx;
|
|
@@ -292,6 +304,7 @@ const service$2 = {
|
|
|
292
304
|
repository: getRepository(ctx),
|
|
293
305
|
jobId: null,
|
|
294
306
|
runId: null,
|
|
307
|
+
runAttempt: null,
|
|
295
308
|
prNumber: getPrNumber(ctx),
|
|
296
309
|
prHeadCommit: null,
|
|
297
310
|
nonce: env.TRAVIS_BUILD_ID || null
|
|
@@ -301,6 +314,7 @@ const service$2 = {
|
|
|
301
314
|
|
|
302
315
|
const service$1 = {
|
|
303
316
|
name: "GitLab",
|
|
317
|
+
key: "gitlab",
|
|
304
318
|
detect: ({ env })=>env.GITLAB_CI === "true",
|
|
305
319
|
config: ({ env })=>{
|
|
306
320
|
return {
|
|
@@ -310,6 +324,7 @@ const service$1 = {
|
|
|
310
324
|
repository: null,
|
|
311
325
|
jobId: null,
|
|
312
326
|
runId: null,
|
|
327
|
+
runAttempt: null,
|
|
313
328
|
prNumber: null,
|
|
314
329
|
prHeadCommit: null,
|
|
315
330
|
nonce: env.CI_PIPELINE_ID || null
|
|
@@ -319,6 +334,7 @@ const service$1 = {
|
|
|
319
334
|
|
|
320
335
|
const service = {
|
|
321
336
|
name: "Git",
|
|
337
|
+
key: "git",
|
|
322
338
|
detect: ()=>checkIsGitRepository(),
|
|
323
339
|
config: ()=>{
|
|
324
340
|
return {
|
|
@@ -328,6 +344,7 @@ const service = {
|
|
|
328
344
|
repository: null,
|
|
329
345
|
jobId: null,
|
|
330
346
|
runId: null,
|
|
347
|
+
runAttempt: null,
|
|
331
348
|
prNumber: null,
|
|
332
349
|
prHeadCommit: null,
|
|
333
350
|
nonce: null
|
|
@@ -361,6 +378,7 @@ async function getCiEnvironment({ env = process.env } = {}) {
|
|
|
361
378
|
const variables = await service.config(ctx);
|
|
362
379
|
const ciEnvironment = {
|
|
363
380
|
name: service.name,
|
|
381
|
+
key: service.key,
|
|
364
382
|
...variables
|
|
365
383
|
};
|
|
366
384
|
debug("CI environment", ciEnvironment);
|
|
@@ -449,6 +467,12 @@ const schema = {
|
|
|
449
467
|
default: null,
|
|
450
468
|
nullable: true
|
|
451
469
|
},
|
|
470
|
+
parallelIndex: {
|
|
471
|
+
env: "ARGOS_PARALLEL_INDEX",
|
|
472
|
+
format: "nat",
|
|
473
|
+
default: null,
|
|
474
|
+
nullable: true
|
|
475
|
+
},
|
|
452
476
|
parallelTotal: {
|
|
453
477
|
env: "ARGOS_PARALLEL_TOTAL",
|
|
454
478
|
format: "nat",
|
|
@@ -482,6 +506,11 @@ const schema = {
|
|
|
482
506
|
default: null,
|
|
483
507
|
nullable: true
|
|
484
508
|
},
|
|
509
|
+
runAttempt: {
|
|
510
|
+
format: String,
|
|
511
|
+
default: null,
|
|
512
|
+
nullable: true
|
|
513
|
+
},
|
|
485
514
|
owner: {
|
|
486
515
|
format: String,
|
|
487
516
|
default: null,
|
|
@@ -491,6 +520,11 @@ const schema = {
|
|
|
491
520
|
format: String,
|
|
492
521
|
default: null,
|
|
493
522
|
nullable: true
|
|
523
|
+
},
|
|
524
|
+
ciProvider: {
|
|
525
|
+
format: String,
|
|
526
|
+
default: null,
|
|
527
|
+
nullable: true
|
|
494
528
|
}
|
|
495
529
|
};
|
|
496
530
|
const createConfig = ()=>{
|
|
@@ -516,10 +550,13 @@ async function readConfig(options = {}) {
|
|
|
516
550
|
repository: ciEnv?.repository || null,
|
|
517
551
|
jobId: ciEnv?.jobId || null,
|
|
518
552
|
runId: ciEnv?.runId || null,
|
|
553
|
+
runAttempt: ciEnv?.runAttempt || null,
|
|
519
554
|
parallel: options.parallel ?? config.get("parallel") ?? false,
|
|
520
555
|
parallelNonce: options.parallelNonce || config.get("parallelNonce") || ciEnv?.nonce || null,
|
|
521
556
|
parallelTotal: options.parallelTotal || config.get("parallelTotal") || null,
|
|
522
|
-
|
|
557
|
+
parallelIndex: options.parallelIndex || config.get("parallelIndex") || null,
|
|
558
|
+
mode: options.mode || config.get("mode") || null,
|
|
559
|
+
ciProvider: ciEnv?.key || null
|
|
523
560
|
});
|
|
524
561
|
config.validate();
|
|
525
562
|
return config.get();
|
|
@@ -666,6 +703,15 @@ const upload$1 = async (input)=>{
|
|
|
666
703
|
return result;
|
|
667
704
|
};
|
|
668
705
|
|
|
706
|
+
const require = createRequire(import.meta.url);
|
|
707
|
+
/**
|
|
708
|
+
* Get the version of the @argos-ci/core package.
|
|
709
|
+
*/ async function getArgosCoreSDKIdentifier() {
|
|
710
|
+
const pkgPath = require.resolve("@argos-ci/core/package.json");
|
|
711
|
+
const version = await readVersionFromPackage(pkgPath);
|
|
712
|
+
return `@argos-ci/core@${version}`;
|
|
713
|
+
}
|
|
714
|
+
|
|
669
715
|
/**
|
|
670
716
|
* Size of the chunks used to upload screenshots to Argos.
|
|
671
717
|
*/ const CHUNK_SIZE = 10;
|
|
@@ -674,7 +720,8 @@ async function getConfigFromOptions({ parallel, ...options }) {
|
|
|
674
720
|
...options,
|
|
675
721
|
parallel: Boolean(parallel),
|
|
676
722
|
parallelNonce: parallel ? parallel.nonce : null,
|
|
677
|
-
parallelTotal: parallel ? parallel.total : null
|
|
723
|
+
parallelTotal: parallel ? parallel.total : null,
|
|
724
|
+
parallelIndex: parallel ? parallel.index : null
|
|
678
725
|
});
|
|
679
726
|
}
|
|
680
727
|
async function uploadFilesToS3(files) {
|
|
@@ -705,7 +752,10 @@ async function uploadFilesToS3(files) {
|
|
|
705
752
|
*/ async function upload(params) {
|
|
706
753
|
debug("Starting upload with params", params);
|
|
707
754
|
// Read config
|
|
708
|
-
const config = await
|
|
755
|
+
const [config, argosSdk] = await Promise.all([
|
|
756
|
+
getConfigFromOptions(params),
|
|
757
|
+
getArgosCoreSDKIdentifier()
|
|
758
|
+
]);
|
|
709
759
|
const files = params.files ?? [
|
|
710
760
|
"**/*.{png,jpg,jpeg}"
|
|
711
761
|
];
|
|
@@ -771,7 +821,11 @@ async function uploadFilesToS3(files) {
|
|
|
771
821
|
prNumber: config.prNumber,
|
|
772
822
|
prHeadCommit: config.prHeadCommit,
|
|
773
823
|
referenceBranch: config.referenceBranch,
|
|
774
|
-
referenceCommit: config.referenceCommit
|
|
824
|
+
referenceCommit: config.referenceCommit,
|
|
825
|
+
argosSdk,
|
|
826
|
+
ciProvider: config.ciProvider,
|
|
827
|
+
runId: config.runId,
|
|
828
|
+
runAttempt: config.runAttempt
|
|
775
829
|
});
|
|
776
830
|
debug("Got uploads url", result);
|
|
777
831
|
const uploadFiles = [
|
|
@@ -810,7 +864,8 @@ async function uploadFilesToS3(files) {
|
|
|
810
864
|
pwTraceKey: screenshot.pwTrace?.hash ?? null
|
|
811
865
|
})),
|
|
812
866
|
parallel: config.parallel,
|
|
813
|
-
parallelTotal: config.parallelTotal
|
|
867
|
+
parallelTotal: config.parallelTotal,
|
|
868
|
+
parallelIndex: config.parallelIndex
|
|
814
869
|
});
|
|
815
870
|
return {
|
|
816
871
|
build: result.build,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@argos-ci/core",
|
|
3
3
|
"description": "Visual testing solution to avoid visual regression. The core component of Argos SDK that handles build creation.",
|
|
4
|
-
"version": "2.2.
|
|
4
|
+
"version": "2.2.1-alpha.7+d1a818a",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"build": "rollup -c",
|
|
60
60
|
"e2e": "node ./e2e/upload.cjs && node ./e2e/upload.mjs"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "d1a818aeee5bcba93c0492be43704f8c3682222e"
|
|
63
63
|
}
|