@argos-ci/core 2.1.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 CHANGED
@@ -17,12 +17,16 @@ interface UploadParameters {
17
17
  prNumber?: number;
18
18
  /** Name of the build used to trigger multiple Argos builds on one commit */
19
19
  buildName?: string;
20
+ /** Mode of comparison applied */
21
+ mode?: "ci" | "monitoring";
20
22
  /** Parallel test suite mode */
21
23
  parallel?: {
22
24
  /** Unique build ID for this parallel build */
23
25
  nonce: string;
24
26
  /** The number of parallel nodes being ran */
25
27
  total: number;
28
+ /** The index of the parallel node */
29
+ index?: number;
26
30
  } | false;
27
31
  /** Branch used as baseline for screenshot comparison */
28
32
  referenceBranch?: string;
@@ -57,6 +61,7 @@ interface Config {
57
61
  buildName: string | null;
58
62
  parallel: boolean;
59
63
  parallelNonce: string | null;
64
+ parallelIndex: number | null;
60
65
  parallelTotal: number | null;
61
66
  referenceBranch: string | null;
62
67
  referenceCommit: string | null;
@@ -64,8 +69,11 @@ interface Config {
64
69
  repository: string | null;
65
70
  jobId: string | null;
66
71
  runId: string | null;
72
+ runAttempt: number | null;
67
73
  prNumber: number | null;
68
74
  prHeadCommit: string | null;
75
+ mode: "ci" | "monitoring" | null;
76
+ ciProvider: string | null;
69
77
  }
70
78
  declare function readConfig(options?: Partial<Config>): Promise<Config>;
71
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);
@@ -417,6 +435,15 @@ const schema = {
417
435
  format: String,
418
436
  nullable: true
419
437
  },
438
+ mode: {
439
+ env: "ARGOS_MODE",
440
+ format: [
441
+ "ci",
442
+ "monitoring"
443
+ ],
444
+ default: null,
445
+ nullable: true
446
+ },
420
447
  prNumber: {
421
448
  env: "ARGOS_PR_NUMBER",
422
449
  format: Number,
@@ -440,6 +467,12 @@ const schema = {
440
467
  default: null,
441
468
  nullable: true
442
469
  },
470
+ parallelIndex: {
471
+ env: "ARGOS_PARALLEL_INDEX",
472
+ format: "nat",
473
+ default: null,
474
+ nullable: true
475
+ },
443
476
  parallelTotal: {
444
477
  env: "ARGOS_PARALLEL_TOTAL",
445
478
  format: "nat",
@@ -473,6 +506,11 @@ const schema = {
473
506
  default: null,
474
507
  nullable: true
475
508
  },
509
+ runAttempt: {
510
+ format: String,
511
+ default: null,
512
+ nullable: true
513
+ },
476
514
  owner: {
477
515
  format: String,
478
516
  default: null,
@@ -482,6 +520,11 @@ const schema = {
482
520
  format: String,
483
521
  default: null,
484
522
  nullable: true
523
+ },
524
+ ciProvider: {
525
+ format: String,
526
+ default: null,
527
+ nullable: true
485
528
  }
486
529
  };
487
530
  const createConfig = ()=>{
@@ -507,9 +550,13 @@ async function readConfig(options = {}) {
507
550
  repository: ciEnv?.repository || null,
508
551
  jobId: ciEnv?.jobId || null,
509
552
  runId: ciEnv?.runId || null,
553
+ runAttempt: ciEnv?.runAttempt || null,
510
554
  parallel: options.parallel ?? config.get("parallel") ?? false,
511
555
  parallelNonce: options.parallelNonce || config.get("parallelNonce") || ciEnv?.nonce || null,
512
- parallelTotal: options.parallelTotal || config.get("parallelTotal") || null
556
+ parallelTotal: options.parallelTotal || config.get("parallelTotal") || null,
557
+ parallelIndex: options.parallelIndex || config.get("parallelIndex") || null,
558
+ mode: options.mode || config.get("mode") || null,
559
+ ciProvider: ciEnv?.key || null
513
560
  });
514
561
  config.validate();
515
562
  return config.get();
@@ -656,6 +703,15 @@ const upload$1 = async (input)=>{
656
703
  return result;
657
704
  };
658
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
+
659
715
  /**
660
716
  * Size of the chunks used to upload screenshots to Argos.
661
717
  */ const CHUNK_SIZE = 10;
@@ -664,7 +720,8 @@ async function getConfigFromOptions({ parallel, ...options }) {
664
720
  ...options,
665
721
  parallel: Boolean(parallel),
666
722
  parallelNonce: parallel ? parallel.nonce : null,
667
- parallelTotal: parallel ? parallel.total : null
723
+ parallelTotal: parallel ? parallel.total : null,
724
+ parallelIndex: parallel ? parallel.index : null
668
725
  });
669
726
  }
670
727
  async function uploadFilesToS3(files) {
@@ -695,7 +752,10 @@ async function uploadFilesToS3(files) {
695
752
  */ async function upload(params) {
696
753
  debug("Starting upload with params", params);
697
754
  // Read config
698
- const config = await getConfigFromOptions(params);
755
+ const [config, argosSdk] = await Promise.all([
756
+ getConfigFromOptions(params),
757
+ getArgosCoreSDKIdentifier()
758
+ ]);
699
759
  const files = params.files ?? [
700
760
  "**/*.{png,jpg,jpeg}"
701
761
  ];
@@ -753,6 +813,7 @@ async function uploadFilesToS3(files) {
753
813
  commit: config.commit,
754
814
  branch: config.branch,
755
815
  name: config.buildName,
816
+ mode: config.mode,
756
817
  parallel: config.parallel,
757
818
  parallelNonce: config.parallelNonce,
758
819
  screenshotKeys,
@@ -760,7 +821,11 @@ async function uploadFilesToS3(files) {
760
821
  prNumber: config.prNumber,
761
822
  prHeadCommit: config.prHeadCommit,
762
823
  referenceBranch: config.referenceBranch,
763
- referenceCommit: config.referenceCommit
824
+ referenceCommit: config.referenceCommit,
825
+ argosSdk,
826
+ ciProvider: config.ciProvider,
827
+ runId: config.runId,
828
+ runAttempt: config.runAttempt
764
829
  });
765
830
  debug("Got uploads url", result);
766
831
  const uploadFiles = [
@@ -799,7 +864,8 @@ async function uploadFilesToS3(files) {
799
864
  pwTraceKey: screenshot.pwTrace?.hash ?? null
800
865
  })),
801
866
  parallel: config.parallel,
802
- parallelTotal: config.parallelTotal
867
+ parallelTotal: config.parallelTotal,
868
+ parallelIndex: config.parallelIndex
803
869
  });
804
870
  return {
805
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.1.0",
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": "1d91294d32a09302aa8890807ddd810e14e9950b"
62
+ "gitHead": "d1a818aeee5bcba93c0492be43704f8c3682222e"
63
63
  }