Skip to content

Commit 2849e20

Browse files
committed
ci: auto-label new package PRs with '8.has: package (new)'
1 parent 953d4fd commit 2849e20

2 files changed

Lines changed: 33 additions & 13 deletions

File tree

.github/actions/checkout/action.yml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,13 @@ runs:
9999
break
100100
}
101101
102-
// Create all worktrees in parallel.
103-
await Promise.all(
104-
commits
105-
.filter(({ path }) => Boolean(path))
106-
.map(async ({ sha, path }) => {
107-
await run('git', 'worktree', 'add', join('nixpkgs', path), sha, '--no-checkout')
108-
await run('git', '-C', join('nixpkgs', path), 'sparse-checkout', 'disable')
109-
await run('git', '-C', join('nixpkgs', path), 'checkout', '--progress')
110-
})
111-
)
102+
// Create worktrees sequentially to avoid git lock conflicts.
103+
// Parallel worktree creation can fail with "failed to read .git/worktrees/.../commondir".
104+
for (const { sha, path } of commits.filter(({ path }) => Boolean(path))) {
105+
await run('git', 'worktree', 'add', join('nixpkgs', path), sha, '--no-checkout')
106+
await run('git', '-C', join('nixpkgs', path), 'sparse-checkout', 'disable')
107+
await run('git', '-C', join('nixpkgs', path), 'checkout', '--progress')
108+
}
112109
113110
// Apply pin bump to untrusted worktree
114111
if (pin_bump_sha) {

ci/github-script/bot.js

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,19 @@ module.exports = async ({ github, context, core, dry }) => {
6868

6969
// We get here when none of the 10 commits we looked at contained a maintainer map.
7070
// For the master branch, we don't have any fallback options, so we error out.
71+
// In forks without merge-group history, return empty map to allow testing.
72+
if (branch === 'master') {
73+
const isFork = context.repo.owner !== 'NixOS'
74+
if (isFork) {
75+
core.warning(
76+
'No maintainer map found. Using empty map (expected in forks without merge-group history).',
77+
)
78+
return {}
79+
}
80+
throw new Error('No maintainer map found.')
81+
}
82+
7183
// For other branches, we select a suitable fallback below.
72-
if (branch === 'master') throw new Error('No maintainer map found.')
7384

7485
const { stable, version } = classify(branch)
7586

@@ -109,6 +120,11 @@ module.exports = async ({ github, context, core, dry }) => {
109120
return []
110121
}
111122

123+
// Forks don't have NixOS teams, return empty list
124+
if (context.repo.owner !== 'NixOS') {
125+
return []
126+
}
127+
112128
if (!members[team_slug]) {
113129
members[team_slug] = github.paginate(github.rest.teams.listMembersInOrg, {
114130
org: context.repo.owner,
@@ -304,9 +320,16 @@ module.exports = async ({ github, context, core, dry }) => {
304320
expectedHash: artifact.digest,
305321
})
306322

307-
const evalLabels = JSON.parse(
323+
const changedPaths = JSON.parse(
308324
await readFile(`${pull_number}/changed-paths.json`, 'utf-8'),
309-
).labels
325+
)
326+
const evalLabels = changedPaths.labels
327+
328+
// Label new package PRs when title contains ": init at" pattern
329+
const hasNewPackages = changedPaths.attrdiff?.added?.length > 0
330+
const titleIndicatesNewPackage = /: init at\b/.test(pull_request.title)
331+
evalLabels['8.has: package (new)'] =
332+
hasNewPackages && titleIndicatesNewPackage
310333

311334
// TODO: Get "changed packages" information from list of changed by-name files
312335
// in addition to just the Eval results, to make this work for these packages

0 commit comments

Comments
 (0)