diff --git a/.github/workflows/scheduled.yml b/.github/workflows/scheduled.yml index 31898c2e860..ba71d1aca83 100644 --- a/.github/workflows/scheduled.yml +++ b/.github/workflows/scheduled.yml @@ -43,17 +43,3 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} CAPI_KEY: ${{ secrets.CAPI_KEY }} - - - name: Set up Node environment - uses: ./.github/actions/setup-node-env - - - name: DCR peer dependencies tracker - run: | - deno run \ - --allow-read \ - --allow-net \ - --allow-env=HOME,GITHUB_TOKEN \ - --allow-run=yarn,npm \ - scripts/deno/peer-dependencies.ts - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/scripts/deno/peer-dependencies.ts b/scripts/deno/peer-dependencies.ts deleted file mode 100644 index 35526247f13..00000000000 --- a/scripts/deno/peer-dependencies.ts +++ /dev/null @@ -1,99 +0,0 @@ -import { octokit } from './github.ts'; - -const peers = async (cwd: string) => { - const process = new Deno.Command('yarn', { - cwd, - args: ['--force'], - stdout: 'null', - stderr: 'piped', - }); - - const { code, stderr } = await process.output(); - - if (code !== 0) Deno.exit(code); - - const deps = new TextDecoder() - .decode(stderr) - .split('\n') - // keep only incorrect peer dependencies warnings - .filter((line) => line.includes('has incorrect peer dependency')) - // strip out the workspace-aggregator-xyz-012 prefixes - .map((line) => line.replace(/workspace-aggregator-[a-z0-9-]+ > /, '')) - // apps-rendering are not part of the workspace - .map((line) => line.replace('" >', '"@guardian/apps-rendering >')); - - return deps; -}; - -type Workspaces = { dcr: string[]; ar: string[] }; -const initialValue: Workspaces = { dcr: [], ar: [] }; - -const { dcr, ar } = (await Promise.all(['.', './apps-rendering'].map(peers))) - .flat() - .map((line) => { - const matches = line.match( - /warning "(.*?) > (.+?)" has incorrect peer dependency "(.+)"./, - ); - if (!matches) throw new Error('Invalid string'); - - const [, workspace, dependency, peer] = matches; - - return { workspace, dependency, peer }; - }) - .reduce((acc, { workspace, dependency, peer }) => { - const line = `- [ ] \`${dependency}\` requires peer \`${peer}\``; - switch (workspace) { - case '@guardian/dotcom-rendering': - return { - ...acc, - dcr: acc.dcr.concat(line), - }; - - case '@guardian/apps-rendering': - return { - ...acc, - ar: acc.ar.concat(line), - }; - default: - return acc; - } - }, initialValue); - -const body = `## Current peer dependencies mismatch - -### dotcom-rendering -${dcr.length ? dcr.join('\n') : '- [X] all peer deps matched!'} - -### apps-rendering -${ar.length ? ar.join('\n') : '- [X] all peer deps matched!'} -`; - -if (!octokit) { - console.log(body); - Deno.exit(); -} - -/** https://github.com/guardian/dotcom-rendering/issues/6945 */ -const issue_number = 6945; - -try { - const { - data: { html_url }, - } = await octokit.rest.issues.update({ - owner: 'guardian', - repo: 'dotcom-rendering', - issue_number, - body, - }); - - console.info(`Updated list of issues for dotcom-rendering#${issue_number}`); - console.info(html_url); -} catch (error) { - // do_something - console.warn(`Failed to update issue #${issue_number}`); - console.error(error); - - console.log(body); -} - -Deno.exit();