Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce matched peer dependencies in CI #7003

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion .github/workflows/dcr-dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,14 @@ jobs:
deno-version: v1.29.4

- name: Check @types/ dependencies
run: deno run --allow-env="GITHUB_TOKEN" scripts/deno/types-dependencies.ts --ci
run: |
deno run \
--allow-env=GITHUB_TOKEN \
scripts/deno/types-dependencies.ts --ci

- name: Check peer dependencies
run: |
deno run \
--allow-env=GITHUB_TOKEN \
--allow-run=yarn \
scripts/deno/peer-dependencies.ts --ci
43 changes: 37 additions & 6 deletions scripts/deno/peer-dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ const peers = async (cwd: string) => {
type Workspaces = { dcr: string[]; cr: string[]; ar: string[] };
const initialValue: Workspaces = { dcr: [], cr: [], ar: [] };

const { dcr, ar, cr } = (
await Promise.all(['.', './apps-rendering'].map(peers))
)
const mismatches = (await Promise.all(['.', './apps-rendering'].map(peers)))
.flat()
.map((line) => {
const matches = line.match(
Expand All @@ -44,8 +42,39 @@ const { dcr, ar, cr } = (
const [, workspace, dependency, peer] = matches;

return { workspace, dependency, peer };
})
.reduce<Workspaces>((acc, { workspace, dependency, peer }) => {
});

if (Deno.args[0] === '--ci') {
/** The following peer deps have known issues */
const knownErrors = [
'@guardian/[email protected]', // apps-rendering should bump to v12
'@guardian/[email protected]', // apps-rendering should bump to v11
'@guardian/[email protected]', // This should be fixed upstream to accept newer versions of @guardian/source-react-components-development-kitchen
'[email protected]', // this plugin is no longer needed in Webpack 5: https://github.com/mattlewis92/webpack-filter-warnings-plugin/pull/26#issuecomment-758802442
'@guardian/[email protected]', // dotcom-rendering should bump to v12
'@guardian/[email protected]', // I don’t think TS 4.8.4 was picked for any particular reason https://github.com/guardian/atoms-rendering/commit/9a95286f0b286d0392bcac022c83bcc6aca51ac8#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519R148
'@guardian/[email protected]', // the @guardian/types are now part of libs, but until common-rendering is removed, this is bound to stick around
];

const worryingErrors = mismatches
// Ignore @guardian/common-rendering package
.filter(({ workspace }) => workspace !== '@guardian/common-rendering')
.filter(({ dependency }) => !knownErrors.includes(dependency));

if (worryingErrors.length > 0) {
console.error(
'The following peer dependencies mismatches must be resolved:',
);
console.warn(worryingErrors);
Deno.exit(worryingErrors.length);
} else {
console.info('No new peer dependencies mismatch!');
Deno.exit();
}
}

const { dcr, ar, cr } = mismatches.reduce<Workspaces>(
(acc, { workspace, dependency, peer }) => {
const line = `- [ ] \`${dependency}\` requires peer \`${peer}\``;
switch (workspace) {
case '@guardian/dotcom-rendering':
Expand All @@ -68,7 +97,9 @@ const { dcr, ar, cr } = (
default:
return acc;
}
}, initialValue);
},
initialValue,
);

const body = `## Current peer dependencies mismatch

Expand Down