@argos-ci/core 2.2.1-alpha.7 → 2.4.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 +9 -0
- package/dist/index.mjs +33 -13
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -32,6 +32,12 @@ interface UploadParameters {
|
|
|
32
32
|
referenceBranch?: string;
|
|
33
33
|
/** Commit used as baseline for screenshot comparison */
|
|
34
34
|
referenceCommit?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Sensitivity threshold between 0 and 1.
|
|
37
|
+
* The higher the threshold, the less sensitive the diff will be.
|
|
38
|
+
* @default 0.5
|
|
39
|
+
*/
|
|
40
|
+
threshold?: number;
|
|
35
41
|
}
|
|
36
42
|
/**
|
|
37
43
|
* Upload screenshots to argos-ci.com.
|
|
@@ -45,6 +51,8 @@ declare function upload(params: UploadParameters): Promise<{
|
|
|
45
51
|
hash: string;
|
|
46
52
|
optimizedPath: string;
|
|
47
53
|
metadata: import("@argos-ci/util").ScreenshotMetadata | null;
|
|
54
|
+
threshold: number | null;
|
|
55
|
+
baseName: string | null;
|
|
48
56
|
pwTrace: {
|
|
49
57
|
path: string;
|
|
50
58
|
hash: string;
|
|
@@ -74,6 +82,7 @@ interface Config {
|
|
|
74
82
|
prHeadCommit: string | null;
|
|
75
83
|
mode: "ci" | "monitoring" | null;
|
|
76
84
|
ciProvider: string | null;
|
|
85
|
+
threshold: number | null;
|
|
77
86
|
}
|
|
78
87
|
declare function readConfig(options?: Partial<Config>): Promise<Config>;
|
|
79
88
|
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",
|
|
@@ -491,11 +502,6 @@ const schema = {
|
|
|
491
502
|
default: null,
|
|
492
503
|
nullable: true
|
|
493
504
|
},
|
|
494
|
-
ciService: {
|
|
495
|
-
format: String,
|
|
496
|
-
default: null,
|
|
497
|
-
nullable: true
|
|
498
|
-
},
|
|
499
505
|
jobId: {
|
|
500
506
|
format: String,
|
|
501
507
|
default: null,
|
|
@@ -507,7 +513,7 @@ const schema = {
|
|
|
507
513
|
nullable: true
|
|
508
514
|
},
|
|
509
515
|
runAttempt: {
|
|
510
|
-
format:
|
|
516
|
+
format: "nat",
|
|
511
517
|
default: null,
|
|
512
518
|
nullable: true
|
|
513
519
|
},
|
|
@@ -525,6 +531,12 @@ const schema = {
|
|
|
525
531
|
format: String,
|
|
526
532
|
default: null,
|
|
527
533
|
nullable: true
|
|
534
|
+
},
|
|
535
|
+
threshold: {
|
|
536
|
+
env: "ARGOS_THRESHOLD",
|
|
537
|
+
format: "float-percent",
|
|
538
|
+
default: null,
|
|
539
|
+
nullable: true
|
|
528
540
|
}
|
|
529
541
|
};
|
|
530
542
|
const createConfig = ()=>{
|
|
@@ -545,7 +557,6 @@ async function readConfig(options = {}) {
|
|
|
545
557
|
prHeadCommit: config.get("prHeadCommit") || ciEnv?.prHeadCommit || null,
|
|
546
558
|
referenceBranch: options.referenceBranch || config.get("referenceBranch") || null,
|
|
547
559
|
referenceCommit: options.referenceCommit || config.get("referenceCommit") || null,
|
|
548
|
-
ciService: ciEnv?.name || null,
|
|
549
560
|
owner: ciEnv?.owner || null,
|
|
550
561
|
repository: ciEnv?.repository || null,
|
|
551
562
|
jobId: ciEnv?.jobId || null,
|
|
@@ -611,13 +622,13 @@ const hashFile = async (filepath)=>{
|
|
|
611
622
|
};
|
|
612
623
|
|
|
613
624
|
const base64Encode = (obj)=>Buffer.from(JSON.stringify(obj), "utf8").toString("base64");
|
|
614
|
-
|
|
625
|
+
function getBearerToken({ token, ciProvider, owner, repository, jobId, runId, prNumber }) {
|
|
615
626
|
if (token) return `Bearer ${token}`;
|
|
616
|
-
switch(
|
|
617
|
-
case "
|
|
627
|
+
switch(ciProvider){
|
|
628
|
+
case "github-actions":
|
|
618
629
|
{
|
|
619
630
|
if (!owner || !repository || !jobId || !runId) {
|
|
620
|
-
throw new Error(`Automatic
|
|
631
|
+
throw new Error(`Automatic GitHub Actions variables detection failed. Please add the 'ARGOS_TOKEN'`);
|
|
621
632
|
}
|
|
622
633
|
return `Bearer tokenless-github-${base64Encode({
|
|
623
634
|
owner,
|
|
@@ -630,7 +641,7 @@ const getBearerToken = ({ token, ciService, owner, repository, jobId, runId, prN
|
|
|
630
641
|
default:
|
|
631
642
|
throw new Error("Missing Argos repository token 'ARGOS_TOKEN'");
|
|
632
643
|
}
|
|
633
|
-
}
|
|
644
|
+
}
|
|
634
645
|
const createArgosApiClient = (options)=>{
|
|
635
646
|
const axiosInstance = axios.create({
|
|
636
647
|
baseURL: options.baseUrl,
|
|
@@ -781,11 +792,18 @@ async function uploadFilesToS3(files) {
|
|
|
781
792
|
hashFile(optimizedPath),
|
|
782
793
|
pwTracePath ? hashFile(pwTracePath) : null
|
|
783
794
|
]);
|
|
795
|
+
const threshold = metadata?.transient?.threshold ?? null;
|
|
796
|
+
const baseName = metadata?.transient?.baseName ?? null;
|
|
797
|
+
if (metadata) {
|
|
798
|
+
delete metadata.transient;
|
|
799
|
+
}
|
|
784
800
|
return {
|
|
785
801
|
...screenshot,
|
|
786
802
|
hash,
|
|
787
803
|
optimizedPath,
|
|
788
804
|
metadata,
|
|
805
|
+
threshold,
|
|
806
|
+
baseName,
|
|
789
807
|
pwTrace: pwTracePath && pwTraceHash ? {
|
|
790
808
|
path: pwTracePath,
|
|
791
809
|
hash: pwTraceHash
|
|
@@ -861,7 +879,9 @@ async function uploadFilesToS3(files) {
|
|
|
861
879
|
key: screenshot.hash,
|
|
862
880
|
name: screenshot.name,
|
|
863
881
|
metadata: screenshot.metadata,
|
|
864
|
-
pwTraceKey: screenshot.pwTrace?.hash ?? null
|
|
882
|
+
pwTraceKey: screenshot.pwTrace?.hash ?? null,
|
|
883
|
+
threshold: screenshot.threshold ?? config?.threshold ?? null,
|
|
884
|
+
baseName: screenshot.baseName
|
|
865
885
|
})),
|
|
866
886
|
parallel: config.parallel,
|
|
867
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.
|
|
4
|
+
"version": "2.4.0",
|
|
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.
|
|
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": "
|
|
62
|
+
"gitHead": "aca82cf842a6d8310611a8594c581794df85cbd8"
|
|
63
63
|
}
|