diff --git a/ci/github-script/commits.js b/ci/github-script/commits.js index 82fedd608b06..5432d0239a11 100644 --- a/ci/github-script/commits.js +++ b/ci/github-script/commits.js @@ -1,4 +1,4 @@ -module.exports = async function ({ github, context, core, dry }) { +module.exports = async ({ github, context, core, dry }) => { const { execFileSync } = require('node:child_process') const { readFile } = require('node:fs/promises') const { join } = require('node:path') @@ -24,7 +24,7 @@ module.exports = async function ({ github, context, core, dry }) { async function extract({ sha, commit }) { const noCherryPick = Array.from( - commit.message.matchAll(/^Not-cherry-picked-because: (.*)$/g) + commit.message.matchAll(/^Not-cherry-picked-because: (.*)$/g), ).at(0) if (noCherryPick) @@ -148,8 +148,7 @@ module.exports = async function ({ github, context, core, dry }) { const fetch = extracted .filter(({ severity }) => !severity) - .map(({ sha, original_sha }) => [ sha, original_sha ]) - .flat() + .flatMap(({ sha, original_sha }) => [sha, original_sha]) if (fetch.length > 0) { // Fetching all commits we need for diff at once is much faster than any other method. @@ -163,7 +162,9 @@ module.exports = async function ({ github, context, core, dry }) { ]) } - const results = extracted.map(result => result.severity ? result : diff(result)) + const results = extracted.map((result) => + result.severity ? result : diff(result), + ) // Log all results without truncation, with better highlighting and all whitespace changes to the job log. results.forEach(({ sha, commit, severity, message, colored_diff }) => { @@ -217,28 +218,58 @@ module.exports = async function ({ github, context, core, dry }) { if (results.some(({ severity }) => severity == 'error')) process.exitCode = 1 - core.summary.addRaw('This report is automatically generated by the `PR / Check / cherry-pick` CI workflow.', true) + core.summary.addRaw( + 'This report is automatically generated by the `PR / Check / cherry-pick` CI workflow.', + true, + ) core.summary.addEOL() - core.summary.addRaw("Some of the commits in this PR require the author's and reviewer's attention.", true) + core.summary.addRaw( + "Some of the commits in this PR require the author's and reviewer's attention.", + true, + ) core.summary.addEOL() if (results.some(({ type }) => type === 'no-commit-hash')) { - core.summary.addRaw('Please follow the [backporting guidelines](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md#how-to-backport-pull-requests) and cherry-pick with the `-x` flag.', true) - core.summary.addRaw('This requires changes to the unstable `master` and `staging` branches first, before backporting them.', true) + core.summary.addRaw( + 'Please follow the [backporting guidelines](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md#how-to-backport-pull-requests) and cherry-pick with the `-x` flag.', + true, + ) + core.summary.addRaw( + 'This requires changes to the unstable `master` and `staging` branches first, before backporting them.', + true, + ) core.summary.addEOL() - core.summary.addRaw('Occasionally, commits are not cherry-picked at all, for example when updating minor versions of packages which have already advanced to the next major on unstable.', true) - core.summary.addRaw('These commits can optionally be marked with a `Not-cherry-picked-because: ` footer.', true) + core.summary.addRaw( + 'Occasionally, commits are not cherry-picked at all, for example when updating minor versions of packages which have already advanced to the next major on unstable.', + true, + ) + core.summary.addRaw( + 'These commits can optionally be marked with a `Not-cherry-picked-because: ` footer.', + true, + ) core.summary.addEOL() } if (results.some(({ type }) => type === 'diff')) { - core.summary.addRaw('Sometimes it is not possible to cherry-pick exactly the same patch.', true) - core.summary.addRaw('This most frequently happens when resolving merge conflicts.', true) - core.summary.addRaw('The range-diff will help to review the resolution of conflicts.', true) + core.summary.addRaw( + 'Sometimes it is not possible to cherry-pick exactly the same patch.', + true, + ) + core.summary.addRaw( + 'This most frequently happens when resolving merge conflicts.', + true, + ) + core.summary.addRaw( + 'The range-diff will help to review the resolution of conflicts.', + true, + ) core.summary.addEOL() } - core.summary.addRaw('If you need to merge this PR despite the warnings, please [dismiss](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/dismissing-a-pull-request-review) this review shortly before merging.', true) + core.summary.addRaw( + 'If you need to merge this PR despite the warnings, please [dismiss](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/dismissing-a-pull-request-review) this review shortly before merging.', + true, + ) results.forEach(({ severity, message, diff }) => { if (severity == 'info') return @@ -256,7 +287,7 @@ module.exports = async function ({ github, context, core, dry }) { // Whether this is intended or just an implementation detail is unclear. core.summary.addRaw('
') core.summary.addRaw( - `\n\n[!${({ important: 'IMPORTANT', warning: 'WARNING', error: 'CAUTION' })[severity]}]`, + `\n\n[!${{ important: 'IMPORTANT', warning: 'WARNING', error: 'CAUTION' }[severity]}]`, true, ) core.summary.addRaw(`${message}`, true) diff --git a/ci/github-script/labels.js b/ci/github-script/labels.js index d7dbc2b2375c..68b84f6d9dfb 100644 --- a/ci/github-script/labels.js +++ b/ci/github-script/labels.js @@ -1,4 +1,4 @@ -module.exports = async function ({ github, context, core, dry }) { +module.exports = async ({ github, context, core, dry }) => { const path = require('node:path') const { DefaultArtifactClient } = require('@actions/artifact') const { readFile, writeFile } = require('node:fs/promises') @@ -297,7 +297,9 @@ module.exports = async function ({ github, context, core, dry }) { // Go back as far as the last successful run of this workflow to make sure // we are not leaving anyone behind on GHA failures. // Defaults to go back 1 hour on the first run. - new Date(lastRun?.created_at ?? new Date().getTime() - 1 * 60 * 60 * 1000).getTime(), + new Date( + lastRun?.created_at ?? new Date().getTime() - 1 * 60 * 60 * 1000, + ).getTime(), // Go back max. 1 day to prevent hitting all API rate limits immediately, // when GH API returns a wrong workflow by accident. new Date().getTime() - 24 * 60 * 60 * 1000, diff --git a/ci/github-script/prepare.js b/ci/github-script/prepare.js index 60225db0635e..96f433126785 100644 --- a/ci/github-script/prepare.js +++ b/ci/github-script/prepare.js @@ -1,4 +1,4 @@ -module.exports = async function ({ github, context, core }) { +module.exports = async ({ github, context, core }) => { const pull_number = context.payload.pull_request.number for (const retryInterval of [5, 10, 20, 40, 80]) { diff --git a/ci/github-script/withRateLimit.js b/ci/github-script/withRateLimit.js index ff97c7173fcf..f430385fed3a 100644 --- a/ci/github-script/withRateLimit.js +++ b/ci/github-script/withRateLimit.js @@ -1,4 +1,4 @@ -module.exports = async function ({ github, core }, callback) { +module.exports = async ({ github, core }, callback) => { const Bottleneck = require('bottleneck') const stats = { diff --git a/ci/supportedBranches.js b/ci/supportedBranches.js index a8579f96df99..d1a826e89147 100755 --- a/ci/supportedBranches.js +++ b/ci/supportedBranches.js @@ -15,14 +15,18 @@ const typeConfig = { } function split(branch) { - return { ...branch.match(/(?.+?)(-(?\d{2}\.\d{2}|unstable)(?:-(?.*))?)?$/).groups } + return { + ...branch.match( + /(?.+?)(-(?\d{2}\.\d{2}|unstable)(?:-(?.*))?)?$/, + ).groups, + } } function classify(branch) { const { prefix, version } = split(branch) return { stable: (version ?? 'unstable') !== 'unstable', - type: typeConfig[prefix] ?? [ 'wip' ] + type: typeConfig[prefix] ?? ['wip'], } }