forked from mui/material-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpushArgos.mjs
50 lines (44 loc) · 1.33 KB
/
pushArgos.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* eslint-disable no-console */
import glob from 'fast-glob';
import fse from 'fs-extra';
import lodashChunk from 'lodash/chunk.js';
import { upload } from '@argos-ci/core';
const screenshotsBase = 'test/regressions/screenshots/chrome';
const screenshotsTmp = 'test/regressions/screenshots/argos';
const BATCH_SIZE = 200;
async function run() {
const screenshots = await glob(`${screenshotsBase}/**/*`);
const chunks = lodashChunk(screenshots, BATCH_SIZE);
await Promise.all(
chunks.map((chunk, chunkIndex) =>
Promise.all(
chunk.map((screenshot) => {
return fse.move(
screenshot,
`${screenshotsTmp}/${chunkIndex}/${screenshot.replace(screenshotsBase, '')}`,
);
}),
),
),
);
for (let i = 0; i < chunks.length; i += 1) {
// eslint-disable-next-line no-await-in-loop
const result = await upload({
root: `${screenshotsTmp}/${i}`,
commit: process.env.CIRCLE_SHA1,
branch: process.env.CIRCLE_BRANCH,
token: process.env.ARGOS_TOKEN,
parallel: {
total: chunks.length,
nonce: process.env.CIRCLE_BUILD_NUM,
},
});
console.log(
`Batch of ${chunks[i].length} screenshots uploaded. Build URL: ${result.build.url}`,
);
}
}
run().catch((error) => {
console.error(error);
process.exit(1);
});