@argos-ci/core 1.1.0 → 1.2.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 +6 -2
- package/dist/index.mjs +60 -15
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -38,9 +38,13 @@ declare const upload: (params: UploadParameters) => Promise<{
|
|
|
38
38
|
url: string;
|
|
39
39
|
};
|
|
40
40
|
screenshots: {
|
|
41
|
-
metadata: import("@argos-ci/util").ScreenshotMetadata | null;
|
|
42
|
-
optimizedPath: string;
|
|
43
41
|
hash: string;
|
|
42
|
+
optimizedPath: string;
|
|
43
|
+
metadata: import("@argos-ci/util").ScreenshotMetadata | null;
|
|
44
|
+
pwTrace: {
|
|
45
|
+
path: string;
|
|
46
|
+
hash: string;
|
|
47
|
+
} | null;
|
|
44
48
|
name: string;
|
|
45
49
|
path: string;
|
|
46
50
|
}[];
|
package/dist/index.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import tmp from 'tmp';
|
|
|
10
10
|
import { createHash } from 'node:crypto';
|
|
11
11
|
import axios from 'axios';
|
|
12
12
|
import { readFile } from 'node:fs/promises';
|
|
13
|
-
import { readMetadata } from '@argos-ci/util';
|
|
13
|
+
import { readMetadata, getPlaywrightTracePath } from '@argos-ci/util';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Check if the current directory is a git repository.
|
|
@@ -528,7 +528,7 @@ const upload$1 = async (input)=>{
|
|
|
528
528
|
url: input.url,
|
|
529
529
|
data: file,
|
|
530
530
|
headers: {
|
|
531
|
-
"Content-Type":
|
|
531
|
+
"Content-Type": input.contentType
|
|
532
532
|
}
|
|
533
533
|
});
|
|
534
534
|
};
|
|
@@ -580,27 +580,50 @@ const getConfigFromOptions = ({ parallel, ...options })=>{
|
|
|
580
580
|
debug("Found screenshots", foundScreenshots);
|
|
581
581
|
// Optimize & compute hashes
|
|
582
582
|
const screenshots = await Promise.all(foundScreenshots.map(async (screenshot)=>{
|
|
583
|
-
const [metadata, optimizedPath] = await Promise.all([
|
|
583
|
+
const [metadata, pwTracePath, optimizedPath] = await Promise.all([
|
|
584
584
|
readMetadata(screenshot.path),
|
|
585
|
+
getPlaywrightTracePath(screenshot.path),
|
|
585
586
|
optimizeScreenshot(screenshot.path)
|
|
586
587
|
]);
|
|
587
|
-
const hash = await
|
|
588
|
+
const [hash, pwTraceHash] = await Promise.all([
|
|
589
|
+
hashFile(optimizedPath),
|
|
590
|
+
pwTracePath ? hashFile(pwTracePath) : null
|
|
591
|
+
]);
|
|
588
592
|
return {
|
|
589
593
|
...screenshot,
|
|
590
|
-
|
|
594
|
+
hash,
|
|
591
595
|
optimizedPath,
|
|
592
|
-
|
|
596
|
+
metadata,
|
|
597
|
+
pwTrace: pwTracePath && pwTraceHash ? {
|
|
598
|
+
path: pwTracePath,
|
|
599
|
+
hash: pwTraceHash
|
|
600
|
+
} : null
|
|
593
601
|
};
|
|
594
602
|
}));
|
|
595
603
|
// Create build
|
|
596
604
|
debug("Creating build");
|
|
605
|
+
const screenshotKeys = Array.from(new Set(screenshots.map((screenshot)=>screenshot.hash)));
|
|
606
|
+
const pwTraces = screenshotKeys.reduce((pwTraces, key)=>{
|
|
607
|
+
const screenshot = screenshots.find((screenshot)=>screenshot.hash === key);
|
|
608
|
+
if (!screenshot) {
|
|
609
|
+
throw new Error(`Invariant: screenshot with hash ${key} not found`);
|
|
610
|
+
}
|
|
611
|
+
if (screenshot.pwTrace) {
|
|
612
|
+
pwTraces.push({
|
|
613
|
+
screenshotKey: screenshot.hash,
|
|
614
|
+
traceKey: screenshot.pwTrace.hash
|
|
615
|
+
});
|
|
616
|
+
}
|
|
617
|
+
return pwTraces;
|
|
618
|
+
}, []);
|
|
597
619
|
const result = await apiClient.createBuild({
|
|
598
620
|
commit: config.commit,
|
|
599
621
|
branch: config.branch,
|
|
600
622
|
name: config.buildName,
|
|
601
623
|
parallel: config.parallel,
|
|
602
624
|
parallelNonce: config.parallelNonce,
|
|
603
|
-
screenshotKeys
|
|
625
|
+
screenshotKeys,
|
|
626
|
+
pwTraces,
|
|
604
627
|
prNumber: config.prNumber,
|
|
605
628
|
prHeadCommit: config.prHeadCommit,
|
|
606
629
|
referenceBranch: config.referenceBranch,
|
|
@@ -611,18 +634,36 @@ const getConfigFromOptions = ({ parallel, ...options })=>{
|
|
|
611
634
|
const chunks = chunk(result.screenshots, CHUNK_SIZE);
|
|
612
635
|
debug(`Starting upload of ${chunks.length} chunks`);
|
|
613
636
|
for(let i = 0; i < chunks.length; i++){
|
|
637
|
+
// Upload screenshots
|
|
614
638
|
debug(`Uploading chunk ${i + 1}/${chunks.length}`);
|
|
615
639
|
const timeLabel = `Chunk ${i + 1}/${chunks.length}`;
|
|
616
640
|
debugTime(timeLabel);
|
|
617
|
-
await Promise.all(chunks[i].map(async ({ key, putUrl })=>{
|
|
641
|
+
await Promise.all(chunks[i].map(async ({ key, putUrl, putTraceUrl })=>{
|
|
618
642
|
const screenshot = screenshots.find((s)=>s.hash === key);
|
|
619
643
|
if (!screenshot) {
|
|
620
644
|
throw new Error(`Invariant: screenshot with hash ${key} not found`);
|
|
621
645
|
}
|
|
622
|
-
await
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
646
|
+
await Promise.all([
|
|
647
|
+
// Upload screenshot
|
|
648
|
+
upload$1({
|
|
649
|
+
url: putUrl,
|
|
650
|
+
path: screenshot.optimizedPath,
|
|
651
|
+
contentType: "image/png"
|
|
652
|
+
}),
|
|
653
|
+
// Upload trace
|
|
654
|
+
(async ()=>{
|
|
655
|
+
if (putTraceUrl) {
|
|
656
|
+
if (!screenshot.pwTrace) {
|
|
657
|
+
throw new Error(`Invariant: screenshot with hash ${key} has a putTraceUrl but no pwTrace`);
|
|
658
|
+
}
|
|
659
|
+
await upload$1({
|
|
660
|
+
url: putTraceUrl,
|
|
661
|
+
path: screenshot.pwTrace.path,
|
|
662
|
+
contentType: "application/zip"
|
|
663
|
+
});
|
|
664
|
+
}
|
|
665
|
+
})()
|
|
666
|
+
]);
|
|
626
667
|
}));
|
|
627
668
|
debugTimeEnd(timeLabel);
|
|
628
669
|
}
|
|
@@ -630,11 +671,15 @@ const getConfigFromOptions = ({ parallel, ...options })=>{
|
|
|
630
671
|
debug("Updating build");
|
|
631
672
|
await apiClient.updateBuild({
|
|
632
673
|
buildId: result.build.id,
|
|
633
|
-
screenshots: screenshots.map((screenshot)=>
|
|
674
|
+
screenshots: screenshots.map((screenshot)=>{
|
|
675
|
+
var _screenshot_pwTrace;
|
|
676
|
+
return {
|
|
634
677
|
key: screenshot.hash,
|
|
635
678
|
name: screenshot.name,
|
|
636
|
-
metadata: screenshot.metadata
|
|
637
|
-
|
|
679
|
+
metadata: screenshot.metadata,
|
|
680
|
+
pwTraceKey: ((_screenshot_pwTrace = screenshot.pwTrace) === null || _screenshot_pwTrace === void 0 ? void 0 : _screenshot_pwTrace.hash) ?? null
|
|
681
|
+
};
|
|
682
|
+
}),
|
|
638
683
|
parallel: config.parallel,
|
|
639
684
|
parallelTotal: config.parallelTotal
|
|
640
685
|
});
|
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": "1.
|
|
4
|
+
"version": "1.2.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": "1.
|
|
43
|
+
"@argos-ci/util": "1.1.0",
|
|
44
44
|
"axios": "^1.5.0",
|
|
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": "47a939474ca0c0d55ca5360dcaa5f8912547ed76"
|
|
63
63
|
}
|