Skip to content

Commit

Permalink
ci: Work around npm behavior changes to fix CI on main (#206)
Browse files Browse the repository at this point in the history
* ci: Prevent recursive prepare script invocations

A change between npm 8.9 and 8.10 started running the main package's
`prepare` script as part of the examples' installs. This broke CI when
the install step launched a fork bomb and got killed after several
minutes.

This change should fix builds on `main`.

* ci: Link with legacy peer deps

Something about peer dependencies changed between npm 8.5.5 and 8.6.0
that is causing CI to fail on `main` with ESLint 6 on the test matrix.

This works around the issue.
  • Loading branch information
btmills committed Jun 21, 2022
1 parent 87c2b53 commit 6570c82
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
28 changes: 17 additions & 11 deletions npm-prepare.js
Expand Up @@ -6,17 +6,23 @@

"use strict";

const childProcess = require("child_process");
const fs = require("fs");
const path = require("path");
if (!process.env.NO_RECURSIVE_PREPARE) {
const childProcess = require("child_process");
const fs = require("fs");
const path = require("path");

const examplesDir = path.resolve(__dirname, "examples");
const examples = fs.readdirSync(examplesDir)
.filter(exampleDir => fs.statSync(path.join(examplesDir, exampleDir)).isDirectory())
.filter(exampleDir => fs.existsSync(path.join(examplesDir, exampleDir, "package.json")));
const examplesDir = path.resolve(__dirname, "examples");
const examples = fs.readdirSync(examplesDir)
.filter(exampleDir => fs.statSync(path.join(examplesDir, exampleDir)).isDirectory())
.filter(exampleDir => fs.existsSync(path.join(examplesDir, exampleDir, "package.json")));

for (const example of examples) {
childProcess.execSync("npm install", {
cwd: path.resolve(examplesDir, example)
});
for (const example of examples) {
childProcess.execSync("npm install", {
cwd: path.resolve(examplesDir, example),
env: {
...process.env,
NO_RECURSIVE_PREPARE: "true"
}
});
}
}
2 changes: 1 addition & 1 deletion tests/lib/plugin.js
Expand Up @@ -82,7 +82,7 @@ describe("recommended config", () => {
// eslint-disable-next-line no-invalid-this
this.timeout(30000);

execSync("npm link && npm link eslint-plugin-markdown");
execSync("npm link && npm link eslint-plugin-markdown --legacy-peer-deps");
} else {
throw error;
}
Expand Down

0 comments on commit 6570c82

Please sign in to comment.