Skip to content

Commit d263613

Browse files
Merge master into staging-next
2 parents 597354d + b436008 commit d263613

File tree

256 files changed

+1355
-8371
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

256 files changed

+1355
-8371
lines changed

.github/actions/checkout/action.yml

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ description: 'Checkout into trusted / untrusted / pinned folders consistently.'
55
inputs:
66
merged-as-untrusted-at:
77
description: "Whether and which SHA to checkout for the merge commit in the ./untrusted folder."
8-
pinned-from:
9-
description: "Whether to checkout the pinned nixpkgs for CI and from where (trusted, untrusted)."
108
target-as-trusted-at:
119
description: "Whether and which SHA to checkout for the target commit in the ./trusted folder."
1210

@@ -16,7 +14,6 @@ runs:
1614
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
1715
env:
1816
MERGED_SHA: ${{ inputs.merged-as-untrusted-at }}
19-
PINNED_FROM: ${{ inputs.pinned-from }}
2017
TARGET_SHA: ${{ inputs.target-as-trusted-at }}
2118
with:
2219
script: |
@@ -45,6 +42,7 @@ runs:
4542
// A single fetch call comes with a lot less overhead. The fetch takes essentially the
4643
// same time no matter whether its 1, 2 or 3 commits at once.
4744
async function getPinnedSha(ref) {
45+
if (!ref) return undefined
4846
const { content, encoding } = (await github.rest.repos.getContent({
4947
...context.repo,
5048
path: 'ci/pinned.json',
@@ -60,16 +58,16 @@ runs:
6058
path: 'untrusted',
6159
},
6260
{
63-
sha: process.env.PINNED_FROM === 'untrusted' && (await getPinnedSha(process.env.MERGED_SHA)),
64-
path: 'pinned'
61+
sha: await getPinnedSha(process.env.MERGED_SHA),
62+
path: 'untrusted-pinned'
6563
},
6664
{
6765
sha: process.env.TARGET_SHA,
6866
path: 'trusted',
6967
},
7068
{
71-
sha: process.env.PINNED_FROM === 'trusted' && (await getPinnedSha(process.env.TARGET_SHA)),
72-
path: 'pinned'
69+
sha: await getPinnedSha(process.env.TARGET_SHA),
70+
path: 'trusted-pinned'
7371
}
7472
].filter(({ sha }) => Boolean(sha))
7573
@@ -79,22 +77,20 @@ runs:
7977
// This would fail without --refetch, because the we had a partial clone before, but changed it above.
8078
await run('git', 'fetch', '--depth=1', '--refetch', 'origin', ...(commits.map(({ sha }) => sha)))
8179
80+
// Checking out onto tmpfs takes 1s and is faster by at least factor 10x.
81+
await run('mkdir', 'nixpkgs')
82+
switch (process.env.RUNNER_OS) {
83+
case 'macOS':
84+
await run('sudo', 'mount_tmpfs', 'nixpkgs')
85+
break
86+
case 'Linux':
87+
await run('sudo', 'mount', '-t', 'tmpfs', 'tmpfs', 'nixpkgs')
88+
break
89+
}
90+
8291
// Create all worktrees in parallel.
8392
await Promise.all(commits.map(async ({ sha, path }) => {
84-
// Checking out onto tmpfs takes 1s and is faster by at least factor 10x.
85-
await run('mkdir', path)
86-
switch (process.env.RUNNER_OS) {
87-
case 'macOS':
88-
await run('sudo', 'mount_tmpfs', path)
89-
// macOS creates this hidden folder to log file system activity.
90-
// This trips up git when adding a worktree below, because the target folder is not empty.
91-
await run('sudo', 'rm', '-rf', join(path, '.fseventsd'))
92-
break
93-
case 'Linux':
94-
await run('sudo', 'mount', '-t', 'tmpfs', 'tmpfs', path)
95-
break
96-
}
97-
await run('git', 'worktree', 'add', path, sha, '--no-checkout', '--force')
98-
await run('git', '-C', path, 'sparse-checkout', 'disable')
99-
await run('git', '-C', path, 'checkout', '--progress')
93+
await run('git', 'worktree', 'add', join('nixpkgs', path), sha, '--no-checkout')
94+
await run('git', '-C', join('nixpkgs', path), 'sparse-checkout', 'disable')
95+
await run('git', '-C', join('nixpkgs', path), 'checkout', '--progress')
10096
}))

.github/workflows/build.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ jobs:
5151
uses: ./.github/actions/checkout
5252
with:
5353
merged-as-untrusted-at: ${{ inputs.mergedSha }}
54-
pinned-from: untrusted
5554

5655
- uses: cachix/install-nix-action@fc6e360bedc9ee72d75e701397f0bb30dce77568 # v31
5756
with:
@@ -66,33 +65,33 @@ jobs:
6665
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
6766
pushFilter: '(-source$|-nixpkgs-tarball-)'
6867

69-
- run: nix-env --install -f pinned -A nix-build-uncached
68+
- run: nix-env --install -f nixpkgs/untrusted-pinned -A nix-build-uncached
7069

7170
- name: Build shell
7271
if: contains(matrix.builds, 'shell')
73-
run: echo "${{ matrix.systems }}" | xargs -n1 nix-build-uncached untrusted/ci --arg nixpkgs ./pinned -A shell --argstr system
72+
run: echo "${{ matrix.systems }}" | xargs -n1 nix-build-uncached nixpkgs/untrusted/ci --arg nixpkgs ./nixpkgs/untrusted-pinned -A shell --argstr system
7473

7574
- name: Build NixOS manual
7675
if: |
7776
contains(matrix.builds, 'manual-nixos') && !cancelled() &&
7877
contains(fromJSON(inputs.baseBranch).type, 'primary')
79-
run: nix-build-uncached untrusted/ci --arg nixpkgs ./pinned -A manual-nixos --out-link nixos-manual
78+
run: nix-build-uncached nixpkgs/untrusted/ci --arg nixpkgs ./nixpkgs/untrusted-pinned -A manual-nixos --out-link nixos-manual
8079

8180
- name: Build Nixpkgs manual
8281
if: contains(matrix.builds, 'manual-nixpkgs') && !cancelled()
83-
run: nix-build-uncached untrusted/ci --arg nixpkgs ./pinned -A manual-nixpkgs -A manual-nixpkgs-tests
82+
run: nix-build-uncached nixpkgs/untrusted/ci --arg nixpkgs ./nixpkgs/untrusted-pinned -A manual-nixpkgs -A manual-nixpkgs-tests
8483

8584
- name: Build Nixpkgs manual tests
8685
if: contains(matrix.builds, 'manual-nixpkgs-tests') && !cancelled()
87-
run: nix-build-uncached untrusted/ci --arg nixpkgs ./pinned -A manual-nixpkgs-tests
86+
run: nix-build-uncached nixpkgs/untrusted/ci --arg nixpkgs ./nixpkgs/untrusted-pinned -A manual-nixpkgs-tests
8887

8988
- name: Build lib tests
9089
if: contains(matrix.builds, 'lib-tests') && !cancelled()
91-
run: nix-build-uncached untrusted/ci --arg nixpkgs ./pinned -A lib-tests
90+
run: nix-build-uncached nixpkgs/untrusted/ci --arg nixpkgs ./nixpkgs/untrusted-pinned -A lib-tests
9291

9392
- name: Build tarball
9493
if: contains(matrix.builds, 'tarball') && !cancelled()
95-
run: nix-build-uncached untrusted/ci --arg nixpkgs ./pinned -A tarball
94+
run: nix-build-uncached nixpkgs/untrusted/ci --arg nixpkgs ./nixpkgs/untrusted-pinned -A tarball
9695

9796
- name: Upload NixOS manual
9897
if: |

.github/workflows/check.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ jobs:
103103
uses: ./.github/actions/checkout
104104
with:
105105
merged-as-untrusted-at: ${{ inputs.mergedSha }}
106-
pinned-from: trusted
107106
target-as-trusted-at: ${{ inputs.targetSha }}
108107

109108
- uses: cachix/install-nix-action@fc6e360bedc9ee72d75e701397f0bb30dce77568 # v31
@@ -117,7 +116,7 @@ jobs:
117116
pushFilter: -source$
118117

119118
- name: Build codeowners validator
120-
run: nix-build trusted/ci --arg nixpkgs ./pinned -A codeownersValidator
119+
run: nix-build nixpkgs/trusted/ci --arg nixpkgs ./nixpkgs/trusted-pinned -A codeownersValidator
121120

122121
- uses: actions/create-github-app-token@0f859bf9e69e887678d5bbfbee594437cb440ffe # v2.1.0
123122
if: github.event_name == 'pull_request_target' && vars.OWNER_RO_APP_ID
@@ -137,9 +136,9 @@ jobs:
137136
- name: Validate codeowners
138137
if: steps.app-token.outputs.token
139138
env:
140-
OWNERS_FILE: untrusted/ci/OWNERS
139+
OWNERS_FILE: nixpkgs/untrusted/ci/OWNERS
141140
GITHUB_ACCESS_TOKEN: ${{ steps.app-token.outputs.token }}
142-
REPOSITORY_PATH: untrusted
141+
REPOSITORY_PATH: nixpkgs/untrusted
143142
OWNER_CHECKER_REPOSITORY: ${{ github.repository }}
144143
# Set this to "notowned,avoid-shadowing" to check that all files are owned by somebody
145144
EXPERIMENTAL_CHECKS: "avoid-shadowing"

.github/workflows/eval.yml

Lines changed: 43 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ jobs:
7171
# to not interrupt main Eval's compare step.
7272
continue-on-error: ${{ matrix.version != '' }}
7373
name: ${{ matrix.system }}${{ matrix.version && format(' @ {0}', matrix.version) || '' }}
74-
outputs:
75-
targetRunId: ${{ steps.targetRunId.outputs.targetRunId }}
7674
timeout-minutes: 15
7775
steps:
7876
# This is not supposed to be used and just acts as a fallback.
@@ -89,11 +87,11 @@ jobs:
8987
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
9088
with:
9189
sparse-checkout: .github/actions
92-
- name: Check out the PR at the test merge commit
90+
- name: Check out the PR at merged and target commits
9391
uses: ./.github/actions/checkout
9492
with:
9593
merged-as-untrusted-at: ${{ inputs.mergedSha }}
96-
pinned-from: untrusted
94+
target-as-trusted-at: ${{ inputs.targetSha }}
9795

9896
- name: Install Nix
9997
uses: cachix/install-nix-action@fc6e360bedc9ee72d75e701397f0bb30dce77568 # v31
@@ -106,98 +104,64 @@ jobs:
106104
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
107105
pushFilter: '(-source|-single-chunk)$'
108106

109-
- name: Evaluate the ${{ matrix.system }} output paths for all derivation attributes
107+
- name: Evaluate the ${{ matrix.system }} output paths at the merge commit
110108
env:
111109
MATRIX_SYSTEM: ${{ matrix.system }}
112110
MATRIX_VERSION: ${{ matrix.version || 'nixVersions.latest' }}
113111
run: |
114-
nix-build untrusted/ci --arg nixpkgs ./pinned -A eval.singleSystem \
112+
nix-build nixpkgs/untrusted/ci --arg nixpkgs ./nixpkgs/untrusted-pinned -A eval.singleSystem \
115113
--argstr evalSystem "$MATRIX_SYSTEM" \
116114
--arg chunkSize 8000 \
117115
--argstr nixPath "$MATRIX_VERSION" \
118116
--out-link merged
119-
# If it uses too much memory, slightly decrease chunkSize
120-
121-
- name: Upload the output paths and eval stats
122-
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
123-
with:
124-
name: ${{ matrix.version && format('{0}-', matrix.version) || '' }}merged-${{ matrix.system }}
125-
path: merged/*
126-
127-
- name: Log current API rate limits
117+
# If it uses too much memory, slightly decrease chunkSize.
118+
# Note: Keep the same further down in sync!
119+
120+
# Running the attrpath generation step separately from the outpath step afterwards.
121+
# The idea is that, *if* Eval on the target branch has not finished, yet, we will
122+
# generate the attrpaths in the meantime - and the separate command command afterwards
123+
# will check cachix again for whether Eval has finished. If no Eval result from the
124+
# target branch can be found the second time, we proceed to run it in here. Attrpaths
125+
# generation takes roughly 30 seconds, so for every normal use-case this should be more
126+
# than enough of a head start for Eval on the target branch to finish.
127+
# This edge-case, that Eval on the target branch is delayed is unlikely to happen anyway:
128+
# For a commit to become the target commit of a PR, it must *already* be on the branch.
129+
# Normally, CI should always start running on that push event *before* it starts running
130+
# on the PR.
131+
- name: Evaluate the ${{ matrix.system }} attribute paths at the target commit
132+
if: inputs.targetSha
128133
env:
129-
GH_TOKEN: ${{ github.token }}
130-
run: gh api /rate_limit | jq
134+
MATRIX_SYSTEM: ${{ matrix.system }}
135+
run: |
136+
nix-build nixpkgs/trusted/ci --arg nixpkgs ./nixpkgs/trusted-pinned -A eval.attrpathsSuperset \
137+
--argstr evalSystem "$MATRIX_SYSTEM" \
138+
--argstr nixPath "nixVersions.latest"
131139
132-
- name: Get target run id
140+
- name: Evaluate the ${{ matrix.system }} output paths at the target commit
133141
if: inputs.targetSha
134-
id: targetRunId
135-
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
136142
env:
137143
MATRIX_SYSTEM: ${{ matrix.system }}
138-
TARGET_SHA: ${{ inputs.targetSha }}
139-
with:
140-
script: |
141-
const system = process.env.MATRIX_SYSTEM
142-
const targetSha = process.env.TARGET_SHA
143-
144-
let run_id
145-
try {
146-
run_id = (await github.rest.actions.listWorkflowRuns({
147-
...context.repo,
148-
workflow_id: 'push.yml',
149-
event: 'push',
150-
head_sha: targetSha
151-
})).data.workflow_runs[0].id
152-
} catch {
153-
throw new Error(`Could not find a push.yml workflow run for ${targetSha}.`)
154-
}
155-
156-
// Waiting 120 * 5 sec = 10 min. max.
157-
// Eval takes max 5-6 minutes, normally.
158-
for (let i = 0; i < 120; i++) {
159-
const result = await github.rest.actions.listWorkflowRunArtifacts({
160-
...context.repo,
161-
run_id,
162-
name: `merged-${system}`
163-
})
164-
if (result.data.total_count > 0) {
165-
core.setOutput('targetRunId', run_id)
166-
return
167-
}
168-
await new Promise(resolve => setTimeout(resolve, 5000))
169-
}
170-
// No artifact found at this stage. This usually means that Eval failed on the target branch.
171-
// This should only happen when Eval is broken on the target branch and this PR fixes it.
172-
// Continue without targetRunId to skip the remaining steps, but pass the job.
173-
174-
- name: Log current API rate limits
175-
env:
176-
GH_TOKEN: ${{ github.token }}
177-
run: gh api /rate_limit | jq
178-
179-
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
180-
if: steps.targetRunId.outputs.targetRunId
181-
with:
182-
run-id: ${{ steps.targetRunId.outputs.targetRunId }}
183-
name: merged-${{ matrix.system }}
184-
path: target
185-
github-token: ${{ github.token }}
186-
merge-multiple: true
144+
# This should be very quick, because it pulls the eval results from Cachix.
145+
run: |
146+
nix-build nixpkgs/trusted/ci --arg nixpkgs ./nixpkgs/trusted-pinned -A eval.singleSystem \
147+
--argstr evalSystem "$MATRIX_SYSTEM" \
148+
--arg chunkSize 8000 \
149+
--argstr nixPath "nixVersions.latest" \
150+
--out-link target
187151
188152
- name: Compare outpaths against the target branch
189-
if: steps.targetRunId.outputs.targetRunId
153+
if: inputs.targetSha
190154
env:
191155
MATRIX_SYSTEM: ${{ matrix.system }}
192156
run: |
193-
nix-build untrusted/ci --arg nixpkgs ./pinned -A eval.diff \
194-
--arg beforeDir ./target \
157+
nix-build nixpkgs/untrusted/ci --arg nixpkgs ./nixpkgs/untrusted-pinned -A eval.diff \
158+
--arg beforeDir "$(readlink ./target)" \
195159
--arg afterDir "$(readlink ./merged)" \
196160
--argstr evalSystem "$MATRIX_SYSTEM" \
197161
--out-link diff
198162
199163
- name: Upload outpaths diff and stats
200-
if: steps.targetRunId.outputs.targetRunId
164+
if: inputs.targetSha
201165
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
202166
with:
203167
name: ${{ matrix.version && format('{0}-', matrix.version) || '' }}diff-${{ matrix.system }}
@@ -206,7 +170,7 @@ jobs:
206170
compare:
207171
runs-on: ubuntu-24.04-arm
208172
needs: [eval]
209-
if: needs.eval.outputs.targetRunId && !cancelled() && !failure()
173+
if: inputs.targetSha && !cancelled() && !failure()
210174
permissions:
211175
statuses: write
212176
timeout-minutes: 5
@@ -219,7 +183,6 @@ jobs:
219183
with:
220184
merged-as-untrusted-at: ${{ inputs.mergedSha }}
221185
target-as-trusted-at: ${{ inputs.targetSha }}
222-
pinned-from: trusted
223186

224187
- name: Download output paths and eval stats for all systems
225188
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
@@ -233,19 +196,19 @@ jobs:
233196

234197
- name: Combine all output paths and eval stats
235198
run: |
236-
nix-build trusted/ci --arg nixpkgs ./pinned -A eval.combine \
199+
nix-build nixpkgs/trusted/ci --arg nixpkgs ./nixpkgs/trusted-pinned -A eval.combine \
237200
--arg diffDir ./diff \
238201
--out-link combined
239202
240203
- name: Compare against the target branch
241204
env:
242205
AUTHOR_ID: ${{ github.event.pull_request.user.id }}
243206
run: |
244-
git -C trusted diff --name-only ${{ inputs.mergedSha }} \
207+
git -C nixpkgs/trusted diff --name-only ${{ inputs.mergedSha }} \
245208
| jq --raw-input --slurp 'split("\n")[:-1]' > touched-files.json
246209
247210
# Use the target branch to get accurate maintainer info
248-
nix-build trusted/ci --arg nixpkgs ./pinned -A eval.compare \
211+
nix-build nixpkgs/trusted/ci --arg nixpkgs ./nixpkgs/trusted-pinned -A eval.compare \
249212
--arg combinedDir "$(realpath ./combined)" \
250213
--arg touchedFilesJson ./touched-files.json \
251214
--argstr githubAuthorId "$AUTHOR_ID" \
@@ -392,8 +355,8 @@ jobs:
392355
uses: cachix/install-nix-action@fc6e360bedc9ee72d75e701397f0bb30dce77568 # v31
393356

394357
- name: Ensure flake outputs on all systems still evaluate
395-
run: nix flake check --all-systems --no-build './untrusted?shallow=1'
358+
run: nix flake check --all-systems --no-build './nixpkgs/untrusted?shallow=1'
396359

397360
- name: Query nixpkgs with aliases enabled to check for basic syntax errors
398361
run: |
399-
time nix-env -I ./untrusted -f ./untrusted -qa '*' --option restrict-eval true --option allow-import-from-derivation false >/dev/null
362+
time nix-env -I ./nixpkgs/untrusted -f ./nixpkgs/untrusted -qa '*' --option restrict-eval true --option allow-import-from-derivation false >/dev/null

0 commit comments

Comments
 (0)