Skip to content

Commit 8187fe5

Browse files
author
Adam Joseph
committed
implement @infinisil feedback from #266937 (review)
1 parent 81cb101 commit 8187fe5

2 files changed

Lines changed: 47 additions & 3 deletions

File tree

.github/workflows/check-by-name.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,27 +32,47 @@ jobs:
3232
fetch-depth: 2
3333
- name: Determining PR git hashes
3434
run: |
35+
# Please don't put any logic here. To ensure local
36+
# reproducibility, this file should only print diagnostics
37+
# (`env`, `set -x`) and execute scripts found elsewhere in
38+
# nixpkgs.
3539
env
3640
set -x
3741
exec pkgs/test/nixpkgs-check-by-name/workflows/check-by-name/determine-pr-hashes.sh
3842
- uses: cachix/install-nix-action@v23
3943
- name: Determining channel to use for dependencies
4044
run: |
45+
# Please don't put any logic here. To ensure local
46+
# reproducibility, this file should only print diagnostics
47+
# (`env`, `set -x`) and execute scripts found elsewhere in
48+
# nixpkgs.
4149
env
4250
set -x
4351
exec pkgs/test/nixpkgs-check-by-name/workflows/check-by-name/determine-channel-for-dependencies.sh
4452
- name: Fetching latest version of channel
4553
run: |
54+
# Please don't put any logic here. To ensure local
55+
# reproducibility, this file should only print diagnostics
56+
# (`env`, `set -x`) and execute scripts found elsewhere in
57+
# nixpkgs.
4658
env
4759
set -x
4860
exec pkgs/test/nixpkgs-check-by-name/workflows/check-by-name/fetch-latest-version-of-channel.sh
4961
- name: Fetching pre-built nixpkgs-check-by-name from the channel
5062
run: |
63+
# Please don't put any logic here. To ensure local
64+
# reproducibility, this file should only print diagnostics
65+
# (`env`, `set -x`) and execute scripts found elsewhere in
66+
# nixpkgs.
5167
env
5268
set -x
5369
exec pkgs/test/nixpkgs-check-by-name/workflows/check-by-name/fetch-pre-built-by-name-from-channel.sh
5470
- name: Running nixpkgs-check-by-name
5571
run: |
72+
# Please don't put any logic here. To ensure local
73+
# reproducibility, this file should only print diagnostics
74+
# (`env`, `set -x`) and execute scripts found elsewhere in
75+
# nixpkgs.
5676
env
5777
set -x
58-
exec pkgs/test/nixpkgs-check-by-name/workflows/check-by-name/run-nixpkgs-check-by-name.sh
78+
exec pkgs/test/nixpkgs-check-by-name/workflows/check-by-name/reproduce.sh "$baseSha" "$toolingSha" "$headSha"

pkgs/test/nixpkgs-check-by-name/workflows/check-by-name/reproduce.sh

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,28 @@
11
#!/usr/bin/env bash
2+
3+
set -e
4+
# Usage: pkgs/test/nixpkgs-check-by-name/reproduce.sh <base SHA> <tooling SHA> <merged SHA>
5+
6+
# TODO(amjoseph): allow omitting the final argument, since it is
7+
# often a commit which exists only in github (and is difficult to
8+
# `git fetch` from github before the PR is merged).
9+
10+
baseSha="$1"
11+
toolingBinariesSha="$2"
12+
mergedSha="$3"
13+
14+
nixpkgs_for_tooling_binaries=$(nix-instantiate --eval --expr "builtins.fetchTarball \"https://github.com/nixos/nixpkgs/archive/$toolingBinariesSha.tar.gz\"" | tr -d '"')
15+
16+
nix-store --realise --add-root nixpkgs-for-tooling-binaries $nixpkgs_for_tooling_binaries
17+
18+
echo "Fetching pre-built nixpkgs-check-by-name from channel $channel at revision $toolingBinariesSha"
19+
nix-build \
20+
--option extra-substituters https://cache.nixos.org \
21+
--option trusted-public-keys 'cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=' \
22+
nixpkgs-for-tooling-binaries \
23+
-A tests.nixpkgs-check-by-name \
24+
--max-jobs 0
25+
226
echo "Checking whether the check succeeds on the base branch $GITHUB_BASE_REF"
327
git checkout -q "$baseSha"
428
if baseOutput=$(result/bin/nixpkgs-check-by-name . 2>&1); then
@@ -70,10 +94,10 @@ resultToEmoji() {
7094
echo " - Tooling binaries built at nixpkgs commit: [$toolingBinariesSha](https://github.com/${GITHUB_REPOSITORY}/commit/$toolingBinariesSha)"
7195
echo " - Store path: \`$(realpath result)\`"
7296
echo "- Tested Nixpkgs:"
73-
echo " - Base branch: $GITHUB_BASE_REF"
97+
echo " - Base branch: $BASE_SHA"
7498
echo " - Latest base branch commit: [$baseSha](https://github.com/${GITHUB_REPOSITORY}/commit/$baseSha)"
7599
echo " - Latest PR commit: [$headSha](https://github.com/${GITHUB_REPOSITORY}/commit/$headSha)"
76100
echo " - Merge commit: [$mergedSha](https://github.com/${GITHUB_REPOSITORY}/commit/$mergedSha)"
77-
} >> "$GITHUB_STEP_SUMMARY"
101+
} | tee -a "${GITHUB_STEP_SUMMARY:-/dev/null}"
78102

79103
exit "$exitCode"

0 commit comments

Comments
 (0)