ci: apply safe formatting with biome
This commit is contained in:
@@ -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 { execFileSync } = require('node:child_process')
|
||||||
const { readFile } = require('node:fs/promises')
|
const { readFile } = require('node:fs/promises')
|
||||||
const { join } = require('node:path')
|
const { join } = require('node:path')
|
||||||
@@ -24,7 +24,7 @@ module.exports = async function ({ github, context, core, dry }) {
|
|||||||
|
|
||||||
async function extract({ sha, commit }) {
|
async function extract({ sha, commit }) {
|
||||||
const noCherryPick = Array.from(
|
const noCherryPick = Array.from(
|
||||||
commit.message.matchAll(/^Not-cherry-picked-because: (.*)$/g)
|
commit.message.matchAll(/^Not-cherry-picked-because: (.*)$/g),
|
||||||
).at(0)
|
).at(0)
|
||||||
|
|
||||||
if (noCherryPick)
|
if (noCherryPick)
|
||||||
@@ -148,8 +148,7 @@ module.exports = async function ({ github, context, core, dry }) {
|
|||||||
|
|
||||||
const fetch = extracted
|
const fetch = extracted
|
||||||
.filter(({ severity }) => !severity)
|
.filter(({ severity }) => !severity)
|
||||||
.map(({ sha, original_sha }) => [ sha, original_sha ])
|
.flatMap(({ sha, original_sha }) => [sha, original_sha])
|
||||||
.flat()
|
|
||||||
|
|
||||||
if (fetch.length > 0) {
|
if (fetch.length > 0) {
|
||||||
// Fetching all commits we need for diff at once is much faster than any other method.
|
// 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.
|
// Log all results without truncation, with better highlighting and all whitespace changes to the job log.
|
||||||
results.forEach(({ sha, commit, severity, message, colored_diff }) => {
|
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'))
|
if (results.some(({ severity }) => severity == 'error'))
|
||||||
process.exitCode = 1
|
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.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()
|
core.summary.addEOL()
|
||||||
|
|
||||||
if (results.some(({ type }) => type === 'no-commit-hash')) {
|
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(
|
||||||
core.summary.addRaw('This requires changes to the unstable `master` and `staging` branches first, before backporting them.', true)
|
'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.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(
|
||||||
core.summary.addRaw('These commits can optionally be marked with a `Not-cherry-picked-because: <reason>` footer.', true)
|
'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: <reason>` footer.',
|
||||||
|
true,
|
||||||
|
)
|
||||||
core.summary.addEOL()
|
core.summary.addEOL()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (results.some(({ type }) => type === 'diff')) {
|
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(
|
||||||
core.summary.addRaw('This most frequently happens when resolving merge conflicts.', true)
|
'Sometimes it is not possible to cherry-pick exactly the same patch.',
|
||||||
core.summary.addRaw('The range-diff will help to review the resolution of conflicts.', true)
|
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.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 }) => {
|
results.forEach(({ severity, message, diff }) => {
|
||||||
if (severity == 'info') return
|
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.
|
// Whether this is intended or just an implementation detail is unclear.
|
||||||
core.summary.addRaw('<blockquote>')
|
core.summary.addRaw('<blockquote>')
|
||||||
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,
|
true,
|
||||||
)
|
)
|
||||||
core.summary.addRaw(`${message}`, true)
|
core.summary.addRaw(`${message}`, true)
|
||||||
|
|||||||
@@ -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 path = require('node:path')
|
||||||
const { DefaultArtifactClient } = require('@actions/artifact')
|
const { DefaultArtifactClient } = require('@actions/artifact')
|
||||||
const { readFile, writeFile } = require('node:fs/promises')
|
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
|
// Go back as far as the last successful run of this workflow to make sure
|
||||||
// we are not leaving anyone behind on GHA failures.
|
// we are not leaving anyone behind on GHA failures.
|
||||||
// Defaults to go back 1 hour on the first run.
|
// 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,
|
// Go back max. 1 day to prevent hitting all API rate limits immediately,
|
||||||
// when GH API returns a wrong workflow by accident.
|
// when GH API returns a wrong workflow by accident.
|
||||||
new Date().getTime() - 24 * 60 * 60 * 1000,
|
new Date().getTime() - 24 * 60 * 60 * 1000,
|
||||||
|
|||||||
@@ -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
|
const pull_number = context.payload.pull_request.number
|
||||||
|
|
||||||
for (const retryInterval of [5, 10, 20, 40, 80]) {
|
for (const retryInterval of [5, 10, 20, 40, 80]) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
module.exports = async function ({ github, core }, callback) {
|
module.exports = async ({ github, core }, callback) => {
|
||||||
const Bottleneck = require('bottleneck')
|
const Bottleneck = require('bottleneck')
|
||||||
|
|
||||||
const stats = {
|
const stats = {
|
||||||
|
|||||||
@@ -15,14 +15,18 @@ const typeConfig = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function split(branch) {
|
function split(branch) {
|
||||||
return { ...branch.match(/(?<prefix>.+?)(-(?<version>\d{2}\.\d{2}|unstable)(?:-(?<suffix>.*))?)?$/).groups }
|
return {
|
||||||
|
...branch.match(
|
||||||
|
/(?<prefix>.+?)(-(?<version>\d{2}\.\d{2}|unstable)(?:-(?<suffix>.*))?)?$/,
|
||||||
|
).groups,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function classify(branch) {
|
function classify(branch) {
|
||||||
const { prefix, version } = split(branch)
|
const { prefix, version } = split(branch)
|
||||||
return {
|
return {
|
||||||
stable: (version ?? 'unstable') !== 'unstable',
|
stable: (version ?? 'unstable') !== 'unstable',
|
||||||
type: typeConfig[prefix] ?? [ 'wip' ]
|
type: typeConfig[prefix] ?? ['wip'],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user