Skip to content

Commit

Permalink
Run example check in parallel with 5 at most (#7275)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy authored Jun 2, 2023
1 parent 96ae37e commit 6721b1f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
"esbuild": "^0.17.12",
"globby": "^12.2.0",
"kleur": "^4.1.4",
"p-limit": "^4.0.0",
"svelte": "^3.48.0",
"tar": "^6.1.11"
},
"devDependencies": {
"@octokit/action": "^3.18.1",
"del": "^7.0.0",
"execa": "^6.1.0",
"esbuild-plugin-copy": "^2.0.2",
"execa": "^6.1.0",
"tsconfig-resolver": "^3.0.1"
}
}
16 changes: 12 additions & 4 deletions scripts/smoke/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { spawn } from 'child_process';
import { readdirSync, readFileSync, writeFileSync } from 'fs';
import * as path from 'path';
import pLimit from 'p-limit';
import { tsconfigResolverSync } from 'tsconfig-resolver';

function checkExamples() {
Expand All @@ -11,9 +12,13 @@ function checkExamples() {

console.log(`Running astro check on ${examples.length} examples...`);

Promise.all(
examples.map(
(example) =>
// Run astro check in parallel with 5 at most
const checkPromises = [];
const limit = pLimit(5);

for (const example of examples) {
checkPromises.push(
limit(() =>
new Promise((resolve) => {
const originalConfig = prepareExample(example.name);
let data = '';
Expand All @@ -36,8 +41,11 @@ function checkExamples() {
resolve(code);
});
})
)
)
).then((codes) => {
}

Promise.all(checkPromises).then((codes) => {
if (codes.some((code) => code !== 0)) {
process.exit(1);
}
Expand Down

0 comments on commit 6721b1f

Please sign in to comment.