@argos-ci/core 2.3.0 → 2.4.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 CHANGED
@@ -1,25 +1,51 @@
1
1
  interface UploadParameters {
2
- /** Globs matching image file paths to upload */
2
+ /**
3
+ * Globs matching image file paths to upload
4
+ */
3
5
  files?: string[];
4
- /** Root directory to look for image to upload (default to current directory) */
6
+ /**
7
+ * Root directory to look for image to upload
8
+ * @default process.cwd()
9
+ */
5
10
  root?: string;
6
- /** Globs matching image file paths to ignore (default to "**\/*.\{png,jpg,jpeg\}") */
11
+ /**
12
+ * Globs matching image file paths to ignore
13
+ * @default ["**\/*.\{png,jpg,jpeg\}"]
14
+ */
7
15
  ignore?: string[];
8
- /** Base URL of Argos API (default to "https://api.argos-ci.com/v2/") */
16
+ /**
17
+ * Base URL of Argos API
18
+ * @default "https://api.argos-ci.com/v2/"
19
+ */
9
20
  apiBaseUrl?: string;
10
- /** Git commit */
21
+ /**
22
+ * Git commit
23
+ */
11
24
  commit?: string;
12
- /** Git branch */
25
+ /**
26
+ * Git branch
27
+ */
13
28
  branch?: string;
14
- /** Argos repository token */
29
+ /**
30
+ * Argos repository token
31
+ */
15
32
  token?: string;
16
- /** Pull-request number */
33
+ /**
34
+ * Pull-request number
35
+ */
17
36
  prNumber?: number;
18
- /** Name of the build used to trigger multiple Argos builds on one commit */
37
+ /**
38
+ * Name of the build used to trigger multiple Argos builds on one commit
39
+ */
19
40
  buildName?: string;
20
- /** Mode of comparison applied */
41
+ /**
42
+ * Mode of comparison applied
43
+ * @default "ci"
44
+ */
21
45
  mode?: "ci" | "monitoring";
22
- /** Parallel test suite mode */
46
+ /**
47
+ Parallel test suite mode
48
+ */
23
49
  parallel?: {
24
50
  /** Unique build ID for this parallel build */
25
51
  nonce: string;
@@ -28,13 +54,23 @@ interface UploadParameters {
28
54
  /** The index of the parallel node */
29
55
  index?: number;
30
56
  } | false;
31
- /** Branch used as baseline for screenshot comparison */
57
+ /**
58
+ * Branch used as baseline for screenshot comparison
59
+ */
32
60
  referenceBranch?: string;
33
- /** Commit used as baseline for screenshot comparison */
61
+ /**
62
+ * Commit used as baseline for screenshot comparison
63
+ */
34
64
  referenceCommit?: string;
65
+ /**
66
+ * Sensitivity threshold between 0 and 1.
67
+ * The higher the threshold, the less sensitive the diff will be.
68
+ * @default 0.5
69
+ */
70
+ threshold?: number;
35
71
  }
36
72
  /**
37
- * Upload screenshots to argos-ci.com.
73
+ * Upload screenshots to Argos.
38
74
  */
39
75
  declare function upload(params: UploadParameters): Promise<{
40
76
  build: {
@@ -45,6 +81,8 @@ declare function upload(params: UploadParameters): Promise<{
45
81
  hash: string;
46
82
  optimizedPath: string;
47
83
  metadata: import("@argos-ci/util").ScreenshotMetadata | null;
84
+ threshold: number | null;
85
+ baseName: string | null;
48
86
  pwTrace: {
49
87
  path: string;
50
88
  hash: string;
@@ -74,6 +112,7 @@ interface Config {
74
112
  prHeadCommit: string | null;
75
113
  mode: "ci" | "monitoring" | null;
76
114
  ciProvider: string | null;
115
+ threshold: number | null;
77
116
  }
78
117
  declare function readConfig(options?: Partial<Config>): Promise<Config>;
79
118
  export { UploadParameters, upload, Config, readConfig };
package/dist/index.mjs CHANGED
@@ -408,6 +408,17 @@ const mustBeArgosToken = (value)=>{
408
408
  throw new Error("Invalid Argos repository token (must be 40 characters)");
409
409
  }
410
410
  };
411
+ convict.addFormat({
412
+ name: "float-percent",
413
+ validate: function(val) {
414
+ if (val !== 0 && (!val || val > 1 || val < 0)) {
415
+ throw new Error("Must be a float between 0 and 1, inclusive.");
416
+ }
417
+ },
418
+ coerce: function(val) {
419
+ return parseFloat(val);
420
+ }
421
+ });
411
422
  const schema = {
412
423
  apiBaseUrl: {
413
424
  env: "ARGOS_API_BASE_URL",
@@ -520,6 +531,12 @@ const schema = {
520
531
  format: String,
521
532
  default: null,
522
533
  nullable: true
534
+ },
535
+ threshold: {
536
+ env: "ARGOS_THRESHOLD",
537
+ format: "float-percent",
538
+ default: null,
539
+ nullable: true
523
540
  }
524
541
  };
525
542
  const createConfig = ()=>{
@@ -742,7 +759,7 @@ async function uploadFilesToS3(files) {
742
759
  }
743
760
  }
744
761
  /**
745
- * Upload screenshots to argos-ci.com.
762
+ * Upload screenshots to Argos.
746
763
  */ async function upload(params) {
747
764
  debug("Starting upload with params", params);
748
765
  // Read config
@@ -775,11 +792,18 @@ async function uploadFilesToS3(files) {
775
792
  hashFile(optimizedPath),
776
793
  pwTracePath ? hashFile(pwTracePath) : null
777
794
  ]);
795
+ const threshold = metadata?.transient?.threshold ?? null;
796
+ const baseName = metadata?.transient?.baseName ?? null;
797
+ if (metadata) {
798
+ delete metadata.transient;
799
+ }
778
800
  return {
779
801
  ...screenshot,
780
802
  hash,
781
803
  optimizedPath,
782
804
  metadata,
805
+ threshold,
806
+ baseName,
783
807
  pwTrace: pwTracePath && pwTraceHash ? {
784
808
  path: pwTracePath,
785
809
  hash: pwTraceHash
@@ -855,7 +879,9 @@ async function uploadFilesToS3(files) {
855
879
  key: screenshot.hash,
856
880
  name: screenshot.name,
857
881
  metadata: screenshot.metadata,
858
- pwTraceKey: screenshot.pwTrace?.hash ?? null
882
+ pwTraceKey: screenshot.pwTrace?.hash ?? null,
883
+ threshold: screenshot.threshold ?? config?.threshold ?? null,
884
+ baseName: screenshot.baseName
859
885
  })),
860
886
  parallel: config.parallel,
861
887
  parallelTotal: config.parallelTotal,
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.3.0",
4
+ "version": "2.4.1",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
7
7
  "types": "./dist/index.d.ts",
@@ -40,7 +40,7 @@
40
40
  "access": "public"
41
41
  },
42
42
  "dependencies": {
43
- "@argos-ci/util": "2.0.0",
43
+ "@argos-ci/util": "2.1.0",
44
44
  "axios": "^1.6.8",
45
45
  "convict": "^6.2.4",
46
46
  "debug": "^4.3.4",
@@ -59,5 +59,5 @@
59
59
  "build": "rollup -c",
60
60
  "e2e": "node ./e2e/upload.cjs && node ./e2e/upload.mjs"
61
61
  },
62
- "gitHead": "0c328bfcd6475ad625c0335cab11e912e856173c"
62
+ "gitHead": "8fbd0bb85ba9df1e8ca39d46acfe9903264d0b51"
63
63
  }