Skip to content

Commit 9aa8cd8

Browse files
authored
workflows/eval: remove attrs step (#406266)
2 parents 0b1b111 + af6faf8 commit 9aa8cd8

File tree

11 files changed

+44
-80
lines changed

11 files changed

+44
-80
lines changed

.github/workflows/eval.yml

Lines changed: 9 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -19,54 +19,14 @@ jobs:
1919
get-merge-commit:
2020
uses: ./.github/workflows/get-merge-commit.yml
2121

22-
attrs:
23-
name: Attributes
24-
runs-on: ubuntu-24.04-arm
25-
needs: get-merge-commit
26-
if: needs.get-merge-commit.outputs.mergedSha
27-
outputs:
28-
targetSha: ${{ steps.targetSha.outputs.targetSha }}
29-
systems: ${{ steps.systems.outputs.systems }}
30-
steps:
31-
- name: Check out the PR at the test merge commit
32-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
33-
with:
34-
ref: ${{ needs.get-merge-commit.outputs.mergedSha }}
35-
fetch-depth: 2
36-
path: nixpkgs
37-
38-
- name: Determine target commit
39-
if: github.event_name == 'pull_request_target'
40-
id: targetSha
41-
run: |
42-
targetSha=$(git -C nixpkgs rev-parse HEAD^1)
43-
echo "targetSha=$targetSha" >> "$GITHUB_OUTPUT"
44-
45-
- name: Install Nix
46-
uses: cachix/install-nix-action@526118121621777ccd86f79b04685a9319637641 # v31
47-
with:
48-
extra_nix_config: sandbox = true
49-
50-
- name: Evaluate the list of all attributes and get the systems matrix
51-
id: systems
52-
run: |
53-
nix-build nixpkgs/ci -A eval.attrpathsSuperset
54-
echo "systems=$(<result/systems.json)" >> "$GITHUB_OUTPUT"
55-
56-
- name: Upload the list of all attributes
57-
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
58-
with:
59-
name: paths
60-
path: result/*
61-
6222
outpaths:
6323
name: Outpaths
6424
runs-on: ubuntu-24.04-arm
65-
needs: [ attrs, get-merge-commit ]
25+
needs: [ get-merge-commit ]
6626
strategy:
6727
fail-fast: false
6828
matrix:
69-
system: ${{ fromJSON(needs.attrs.outputs.systems) }}
29+
system: ${{ fromJSON(needs.get-merge-commit.outputs.systems) }}
7030
steps:
7131
- name: Enable swap
7232
run: |
@@ -75,12 +35,6 @@ jobs:
7535
sudo mkswap /swap
7636
sudo swapon /swap
7737
78-
- name: Download the list of all attributes
79-
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
80-
with:
81-
name: paths
82-
path: paths
83-
8438
- name: Check out the PR at the test merge commit
8539
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
8640
with:
@@ -98,7 +52,6 @@ jobs:
9852
run: |
9953
nix-build nixpkgs/ci -A eval.singleSystem \
10054
--argstr evalSystem "$MATRIX_SYSTEM" \
101-
--arg attrpathFile ./paths/paths.json \
10255
--arg chunkSize 10000
10356
# If it uses too much memory, slightly decrease chunkSize
10457
@@ -111,7 +64,7 @@ jobs:
11164
process:
11265
name: Process
11366
runs-on: ubuntu-24.04-arm
114-
needs: [ outpaths, attrs, get-merge-commit ]
67+
needs: [ outpaths, get-merge-commit ]
11568
outputs:
11669
targetRunId: ${{ steps.targetRunId.outputs.targetRunId }}
11770
steps:
@@ -146,7 +99,7 @@ jobs:
14699
path: prResult/*
147100

148101
- name: Get target run id
149-
if: needs.attrs.outputs.targetSha
102+
if: needs.get-merge-commit.outputs.targetSha
150103
id: targetRunId
151104
run: |
152105
# Get the latest eval.yml workflow run for the PR's target commit
@@ -175,7 +128,7 @@ jobs:
175128
echo "targetRunId=$runId" >> "$GITHUB_OUTPUT"
176129
env:
177130
REPOSITORY: ${{ github.repository }}
178-
TARGET_SHA: ${{ needs.attrs.outputs.targetSha }}
131+
TARGET_SHA: ${{ needs.get-merge-commit.outputs.targetSha }}
179132
GH_TOKEN: ${{ github.token }}
180133

181134
- uses: actions/download-artifact@v4
@@ -189,8 +142,8 @@ jobs:
189142
- name: Compare against the target branch
190143
if: steps.targetRunId.outputs.targetRunId
191144
run: |
192-
git -C nixpkgs worktree add ../target ${{ needs.attrs.outputs.targetSha }}
193-
git -C nixpkgs diff --name-only ${{ needs.attrs.outputs.targetSha }} \
145+
git -C nixpkgs worktree add ../target ${{ needs.get-merge-commit.outputs.targetSha }}
146+
git -C nixpkgs diff --name-only ${{ needs.get-merge-commit.outputs.targetSha }} \
194147
| jq --raw-input --slurp 'split("\n")[:-1]' > touched-files.json
195148
196149
# Use the target branch to get accurate maintainer info
@@ -213,7 +166,7 @@ jobs:
213166
tag:
214167
name: Tag
215168
runs-on: ubuntu-24.04-arm
216-
needs: [ attrs, process ]
169+
needs: [ process ]
217170
if: needs.process.outputs.targetRunId
218171
permissions:
219172
pull-requests: write
@@ -244,7 +197,7 @@ jobs:
244197
- name: Check out Nixpkgs at the base commit
245198
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
246199
with:
247-
ref: ${{ needs.attrs.outputs.targetSha }}
200+
ref: ${{ needs.get-merge-commit.outputs.targetSha }}
248201
path: base
249202
sparse-checkout: ci
250203

.github/workflows/get-merge-commit.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ on:
66
mergedSha:
77
description: "The merge commit SHA"
88
value: ${{ jobs.resolve-merge-commit.outputs.mergedSha }}
9+
targetSha:
10+
description: "The target commit SHA"
11+
value: ${{ jobs.resolve-merge-commit.outputs.targetSha }}
12+
systems:
13+
description: "The supported systems"
14+
value: ${{ jobs.resolve-merge-commit.outputs.systems }}
915

1016
permissions: {}
1117

@@ -14,6 +20,8 @@ jobs:
1420
runs-on: ubuntu-24.04-arm
1521
outputs:
1622
mergedSha: ${{ steps.merged.outputs.mergedSha }}
23+
targetSha: ${{ steps.merged.outputs.targetSha }}
24+
systems: ${{ steps.systems.outputs.systems }}
1725
steps:
1826
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1927
with:
@@ -31,13 +39,17 @@ jobs:
3139
echo "mergedSha=${{ github.sha }}" >> "$GITHUB_OUTPUT"
3240
;;
3341
pull_request_target)
34-
if mergedSha=$(base/ci/get-merge-commit.sh ${{ github.repository }} ${{ github.event.number }}); then
35-
echo "Checking the merge commit $mergedSha"
36-
echo "mergedSha=$mergedSha" >> "$GITHUB_OUTPUT"
42+
if commits=$(base/ci/get-merge-commit.sh ${{ github.repository }} ${{ github.event.number }}); then
43+
echo "Checking the commits:\n$commits"
44+
echo "$commits" >> "$GITHUB_OUTPUT"
3745
else
3846
# Skipping so that no notifications are sent
3947
echo "Skipping the rest..."
4048
fi
4149
;;
4250
esac
43-
rm -rf base
51+
52+
- name: Load supported systems
53+
id: systems
54+
run: |
55+
echo "systems=$(jq -c <base/ci/supportedSystems.json)" >> "$GITHUB_OUTPUT"

ci/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ Why not just build the tooling right from the PRs Nixpkgs version?
4444
## `get-merge-commit.sh GITHUB_REPO PR_NUMBER`
4545

4646
Check whether a PR is mergeable and return the test merge commit as
47-
[computed by GitHub](https://docs.github.com/en/rest/guides/using-the-rest-api-to-interact-with-your-git-database?apiVersion=2022-11-28#checking-mergeability-of-pull-requests).
47+
[computed by GitHub](https://docs.github.com/en/rest/guides/using-the-rest-api-to-interact-with-your-git-database?apiVersion=2022-11-28#checking-mergeability-of-pull-requests) and its parent.
4848

4949
Arguments:
5050
- `GITHUB_REPO`: The repository of the PR, e.g. `NixOS/nixpkgs`
5151
- `PR_NUMBER`: The PR number, e.g. `1234`
5252

5353
Exit codes:
54-
- 0: The PR can be merged, the test merge commit hash is returned on stdout
54+
- 0: The PR can be merged, the hashes of the test merge commit and the target commit are returned on stdout
5555
- 1: The PR cannot be merged because it's not open anymore
5656
- 2: The PR cannot be merged because it has a merge conflict
5757
- 3: The merge commit isn't being computed, GitHub is likely having internal issues, unknown if the PR is mergeable

ci/eval/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ nix-build ci -A eval.full \
1111
--arg evalSystems '["x86_64-linux" "aarch64-darwin"]'
1212
```
1313

14-
- `--max-jobs`: The maximum number of derivations to run at the same time. Only each [supported system](../supportedSystems.nix) gets a separate derivation, so it doesn't make sense to set this higher than that number.
14+
- `--max-jobs`: The maximum number of derivations to run at the same time. Only each [supported system](../supportedSystems.json) gets a separate derivation, so it doesn't make sense to set this higher than that number.
1515
- `--cores`: The number of cores to use for each job. Recommended to set this to the amount of cores on your system divided by `--max-jobs`.
1616
- `chunkSize`: The number of attributes that are evaluated simultaneously on a single core. Lowering this decreases memory usage at the cost of increased evaluation time. If this is too high, there won't be enough chunks to process them in parallel, and will also increase evaluation time.
1717
- `evalSystems`: The set of systems for which `nixpkgs` should be evaluated. Defaults to the four official platforms (`x86_64-linux`, `aarch64-linux`, `x86_64-darwin` and `aarch64-darwin`).

ci/eval/default.nix

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ let
2626
"nixos"
2727
"pkgs"
2828
".version"
29-
"ci/supportedSystems.nix"
29+
"ci/supportedSystems.json"
3030
]
3131
);
3232
};
3333

3434
nix = nixVersions.nix_2_24;
3535

36-
supportedSystems = import ../supportedSystems.nix;
36+
supportedSystems = builtins.fromJSON (builtins.readFile ../supportedSystems.json);
3737

3838
attrpathsSuperset =
3939
runCommand "attrpaths-superset.json"
@@ -43,8 +43,6 @@ let
4343
nix
4444
time
4545
];
46-
env.supportedSystems = builtins.toJSON supportedSystems;
47-
passAsFile = [ "supportedSystems" ];
4846
}
4947
''
5048
export NIX_STATE_DIR=$(mktemp -d)
@@ -58,7 +56,6 @@ let
5856
--option restrict-eval true \
5957
--option allow-import-from-derivation false \
6058
--arg enableWarnings false > $out/paths.json
61-
mv "$supportedSystemsPath" $out/systems.json
6259
'';
6360

6461
singleSystem =
@@ -68,7 +65,7 @@ let
6865
# because `--argstr system` would only be passed to the ci/default.nix file!
6966
evalSystem,
7067
# The path to the `paths.json` file from `attrpathsSuperset`
71-
attrpathFile,
68+
attrpathFile ? "${attrpathsSuperset}/paths.json",
7269
# The number of attributes per chunk, see ./README.md for more info.
7370
chunkSize,
7471
checkMeta ? true,
@@ -289,7 +286,6 @@ let
289286
name = evalSystem;
290287
path = singleSystem {
291288
inherit quickTest evalSystem chunkSize;
292-
attrpathFile = attrpathsSuperset + "/paths.json";
293289
};
294290
}) evalSystems
295291
);

ci/get-merge-commit.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ done
5555

5656
if [[ "$mergeable" == "true" ]]; then
5757
log "The PR can be merged"
58-
jq -r .merge_commit_sha <<< "$prInfo"
58+
mergedSha="$(jq -r .merge_commit_sha <<< "$prInfo")"
59+
echo "mergedSha=$mergedSha"
60+
targetSha="$(gh api "/repos/$repo/commits/$mergedSha" --jq '.parents[0].sha')"
61+
echo "targetSha=$targetSha"
5962
else
6063
log "The PR has a merge conflict"
6164
exit 2

ci/supportedSystems.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[
2+
"aarch64-linux",
3+
"aarch64-darwin",
4+
"x86_64-linux",
5+
"x86_64-darwin"
6+
]

ci/supportedSystems.nix

Lines changed: 0 additions & 6 deletions
This file was deleted.

pkgs/top-level/release-haskell.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
$ hydra-eval-jobs -I . pkgs/top-level/release-haskell.nix
1111
*/
1212
{
13-
supportedSystems ? import ../../ci/supportedSystems.nix,
13+
supportedSystems ? builtins.fromJSON (builtins.readFile ../../ci/supportedSystems.json),
1414
}:
1515

1616
let

pkgs/top-level/release-outpaths.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
attrNamesOnly ? false,
1414

1515
# Set this to `null` to build for builtins.currentSystem only
16-
systems ? import ../../ci/supportedSystems.nix,
16+
systems ? builtins.fromJSON (builtins.readFile ../../ci/supportedSystems.json),
1717
}:
1818
let
1919
lib = import (path + "/lib");

0 commit comments

Comments
 (0)