[tests] combine examples e2e into one chunk (#9772)

We don't need 5 chunks of the very fast examples tests. We spend more time in setup for each one. We are also more likely to hit the [usage limit](https://docs.github.com/en/actions/learn-github-actions/usage-limits-billing-and-administration#usage-limits) with these.

This PR combines them into one test suite.
This commit is contained in:
Sean Massa
2023-04-07 18:47:27 -05:00
committed by GitHub
parent 925c8ba18c
commit dc8523998c

30
utils/chunk-tests.js vendored
View File

@@ -16,6 +16,28 @@ const runnersMap = new Map([
['test-dev', { min: 1, max: 5, runners: ['ubuntu-latest', 'macos-latest'] }],
]);
const optionsOverrides = {
examples: { min: 1, max: 1 },
};
function getRunnerOptions(scriptName, packageName) {
let runnerOptions = runnersMap.get(scriptName);
if (optionsOverrides[packageName]) {
runnerOptions = Object.assign(
{},
runnerOptions,
optionsOverrides[packageName]
);
}
return (
runnerOptions || {
min: 1,
max: 1,
runners: ['ubuntu-latest'],
}
);
}
async function getChunkedTests() {
const scripts = [...runnersMap.keys()];
const rootPath = path.resolve(__dirname, '..');
@@ -67,11 +89,9 @@ async function getChunkedTests() {
([packagePathAndName, scriptNames]) => {
const [packagePath, packageName] = packagePathAndName.split(',');
return Object.entries(scriptNames).flatMap(([scriptName, testPaths]) => {
const {
runners = ['ubuntu-latest'],
min = 1,
max = 1,
} = runnersMap.get(scriptName) || {};
const runnerOptions = getRunnerOptions(scriptName, packageName);
const { runners, min, max } = runnerOptions;
const sortedTestPaths = testPaths.sort((a, b) => a.localeCompare(b));
return intoChunks(min, max, sortedTestPaths).flatMap(
(chunk, chunkNumber, allChunks) => {