|
@ -1,17 +1,15 @@ |
|
|
// Thanks to material-ui ❤️
|
|
|
// Thanks to material-ui ❤️
|
|
|
// Create chunks for Argos: https://github.com/mui/material-ui/pull/23518
|
|
|
// Create chunks for Argos: https://github.com/mui/material-ui/pull/23518
|
|
|
// https://github.com/mui/material-ui/blob/af81aae3b292ed180e7652a665fad1be2b38a7b3/scripts/pushArgos.js
|
|
|
// https://github.com/mui/material-ui/blob/af81aae3b292ed180e7652a665fad1be2b38a7b3/scripts/pushArgos.js
|
|
|
const util = require('util'); |
|
|
import argos from '@argos-ci/core'; |
|
|
const glob = require('fast-glob'); |
|
|
import childProcess from 'child_process'; |
|
|
const lodashChunk = require('lodash/chunk'); |
|
|
import glob from 'fast-glob'; |
|
|
const childProcess = require('child_process'); |
|
|
import lodashChunk from 'lodash/chunk'; |
|
|
|
|
|
import util from 'util'; |
|
|
// eslint-disable-next-line import/no-unresolved
|
|
|
|
|
|
const argos = require('@argos-ci/core'); |
|
|
|
|
|
|
|
|
|
|
|
const execFileNode = util.promisify(childProcess.execFile); |
|
|
const execFileNode = util.promisify(childProcess.execFile); |
|
|
|
|
|
|
|
|
function execFile(command, args) { |
|
|
function execFile(command: string, args: string[]) { |
|
|
return execFileNode(command, args, { |
|
|
return execFileNode(command, args, { |
|
|
cwd: process.cwd(), |
|
|
cwd: process.cwd(), |
|
|
env: process.env, |
|
|
env: process.env, |
|
@ -23,19 +21,21 @@ const screenshotsBase = 'imageSnapshots'; |
|
|
const screenshotsChunks = `imageSnapshots-chunks`; |
|
|
const screenshotsChunks = `imageSnapshots-chunks`; |
|
|
const BATCH_SIZE = 200; |
|
|
const BATCH_SIZE = 200; |
|
|
|
|
|
|
|
|
async function cpToTemp(screenshot, target) { |
|
|
async function cpToTemp(screenshot: string, target: string) { |
|
|
await execFile('mkdir', ['-p', target]); |
|
|
await execFile('mkdir', ['-p', target]); |
|
|
await execFile('cp', [screenshot, target]); |
|
|
await execFile('cp', [screenshot, target]); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
async function run() { |
|
|
async function run() { |
|
|
const screenshots = await glob(`${screenshotsBase}/**/*`); |
|
|
const screenshots = await glob(`${screenshotsBase}/**/*`); |
|
|
const chunks = lodashChunk(screenshots, BATCH_SIZE); |
|
|
const chunks = lodashChunk<string>(screenshots, BATCH_SIZE); |
|
|
|
|
|
|
|
|
await Promise.all( |
|
|
await Promise.all( |
|
|
chunks.map((chunk, chunkIndex) => |
|
|
chunks.map((chunk, chunkIndex) => |
|
|
Promise.all( |
|
|
Promise.all( |
|
|
chunk.map((screenshot) => cpToTemp(screenshot, `${screenshotsChunks}/${chunkIndex}`)), |
|
|
chunk.map<Promise<void>>((screenshot) => |
|
|
|
|
|
cpToTemp(screenshot, `${screenshotsChunks}/${chunkIndex}`), |
|
|
|
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
); |
|
|
); |
|
@ -47,7 +47,7 @@ async function run() { |
|
|
token: process.env.ARGOS_TOKEN, |
|
|
token: process.env.ARGOS_TOKEN, |
|
|
parallel: { |
|
|
parallel: { |
|
|
total: chunks.length, |
|
|
total: chunks.length, |
|
|
nonce: process.env.ARGOS_PARALLEL_NONCE || process.env.CIRCLE_BUILD_NUM, |
|
|
nonce: process.env.ARGOS_PARALLEL_NONCE || process.env.CIRCLE_BUILD_NUM || '', |
|
|
}, |
|
|
}, |
|
|
}); |
|
|
}); |
|
|
// eslint-disable-next-line no-console -- pipe stdout
|
|
|
// eslint-disable-next-line no-console -- pipe stdout
|