From 221930c60ceb6f5eedefbd83cc94371279d83337 Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Mon, 17 Aug 2026 21:08:16 -0400 Subject: [PATCH] ci/github-script/check-target-branch: check staging-nixos mass rebuilds Assisted-by: Codex gpt-5.6-sol medium --- .../check-target-branch-policy.test.ts | 20 +++++++++---------- .../check-target-branch-policy.ts | 18 +++++++++++++---- ci/github-script/check-target-branch.ts | 11 ++++++---- 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/ci/github-script/check-target-branch-policy.test.ts b/ci/github-script/check-target-branch-policy.test.ts index 7329fc3f6d3a..f272379f37d6 100644 --- a/ci/github-script/check-target-branch-policy.test.ts +++ b/ci/github-script/check-target-branch-policy.test.ts @@ -53,14 +53,14 @@ const cases: Array<{ expected: 'mass-rebuild', }, { - name: 'does not check mass rebuilds on staging-nixos', + name: 'flags a mass rebuild on staging-nixos', facts: { base: 'staging-nixos', maxRebuildCount: 24_000 }, - expected: 'dismiss', + expected: 'mass-rebuild', }, { - name: 'does not check mass rebuilds on a release staging-nixos branch', + name: 'flags a mass rebuild on a release staging-nixos branch', facts: { base: 'staging-nixos-26.05', maxRebuildCount: 1000 }, - expected: 'dismiss', + expected: 'mass-rebuild', }, { name: 'allows mass rebuilds on staging', @@ -97,9 +97,9 @@ const cases: Array<{ expected: 'dismiss', }, { - name: 'does not check possible mass rebuilds on staging-nixos', + name: 'flags other possible mass rebuilds on staging-nixos', facts: { base: 'staging-nixos', maxRebuildCount: 500 }, - expected: 'dismiss', + expected: 'possible-mass-rebuild', }, { name: 'skips staging into master', @@ -127,13 +127,13 @@ const cases: Array<{ expected: 'skip-development-merge', }, { - name: 'skips staging into staging-nixos', + name: 'checks staging into staging-nixos', facts: { base: 'staging-nixos', head: 'staging', maxRebuildCount: 24_000, }, - expected: 'skip-development-merge', + expected: 'mass-rebuild', }, { name: 'skips release staging-nixos into its release branch', @@ -154,13 +154,13 @@ const cases: Array<{ expected: 'skip-development-merge', }, { - name: 'skips release staging into its staging-nixos branch', + name: 'checks release staging into its staging-nixos branch', facts: { base: 'staging-nixos-26.05', head: 'staging-26.05', maxRebuildCount: 24_000, }, - expected: 'skip-development-merge', + expected: 'mass-rebuild', }, { name: 'kernel exemption suppresses a possible mass rebuild', diff --git a/ci/github-script/check-target-branch-policy.ts b/ci/github-script/check-target-branch-policy.ts index 7ef8865903e3..c3671929373d 100644 --- a/ci/github-script/check-target-branch-policy.ts +++ b/ci/github-script/check-target-branch-policy.ts @@ -1,4 +1,4 @@ -const { classify } = require('../supportedBranches.js') +const { classify, split } = require('../supportedBranches.js') type TargetBranchPolicyFacts = { base: string @@ -20,12 +20,17 @@ function getTargetBranchPolicy({ base, head }: { base: string; head: string }) { const baseClassification = classify(base) const headClassification = classify(head) const isPrimaryBase = baseClassification.type.includes('primary') + const isPrimaryHead = headClassification.type.includes('primary') + const isStagingNixosBase = split(base).prefix === 'staging-nixos' + const isDevelopmentHead = headClassification.type.includes('development') const shouldSkipDevelopmentMerge = - headClassification.type.includes('development') + isDevelopmentHead && (!isStagingNixosBase || isPrimaryHead) return { + isStagingNixosBase, shouldSkipDevelopmentMerge, - shouldCheckMassRebuild: !shouldSkipDevelopmentMerge && isPrimaryBase, + shouldCheckMassRebuild: + !shouldSkipDevelopmentMerge && (isPrimaryBase || isStagingNixosBase), shouldCheckNixosRebuild: !shouldSkipDevelopmentMerge && isPrimaryBase, } } @@ -39,6 +44,7 @@ function decideTargetBranchReview({ isExemptHomeAssistantUpdate, }: TargetBranchPolicyFacts): TargetBranchReviewDecision { const { + isStagingNixosBase, shouldSkipDevelopmentMerge, shouldCheckMassRebuild, shouldCheckNixosRebuild, @@ -61,7 +67,11 @@ function decideTargetBranchReview({ !isMassRebuild && !isExemptKernelUpdate && !isExemptHomeAssistantUpdate - if (shouldCheckMassRebuild && isPossibleMassRebuild) { + if ( + shouldCheckMassRebuild && + isPossibleMassRebuild && + !(rebuildsAllTests && isStagingNixosBase) + ) { return 'possible-mass-rebuild' } diff --git a/ci/github-script/check-target-branch.ts b/ci/github-script/check-target-branch.ts index 4b190df67033..e8fc51e178b2 100644 --- a/ci/github-script/check-target-branch.ts +++ b/ci/github-script/check-target-branch.ts @@ -53,10 +53,14 @@ type TargetBranchReviewFacts = { maxRebuildCount: number } +function getStagingBranch(base: string) { + const version = split(base).version + return version ? `staging-${version}` : 'staging' +} + async function postMassRebuildReview(facts: TargetBranchReviewFacts) { const { github, context, core, dry, base, maxRebuildCount } = facts - const desiredBranch = - base === 'master' ? 'staging' : `staging-${split(base).version}` + const desiredBranch = getStagingBranch(base) const body = [ `The PR's base branch is set to \`${base}\`, but this PR causes ${maxRebuildCount} rebuilds.`, 'It is therefore considered a mass rebuild.', @@ -107,8 +111,7 @@ async function postNixosRebuildReview(facts: TargetBranchReviewFacts) { async function postPossibleMassRebuildReview(facts: TargetBranchReviewFacts) { const { github, context, core, dry, base, maxRebuildCount } = facts - const stagingBranch = - base === 'master' ? 'staging' : `staging-${split(base).version}` + const stagingBranch = getStagingBranch(base) const body = [ `The PR's base branch is set to \`${base}\`, and this PR causes ${maxRebuildCount} rebuilds.`, `Please consider whether this PR causes a mass rebuild according to [our conventions](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md#branch-conventions).`,