1 #!/usr/bin/env nix-shell
2 #!nix-shell -i bash -p jq
4 set -o pipefail
-o errexit
-o nounset
6 trace
() { echo >&2 "$@"; }
10 # Don't exit early if anything fails to cleanup
13 trace
-n "Cleaning up.. "
15 [[ -e "$tmp/base" ]] && git worktree remove
--force "$tmp/base"
16 [[ -e "$tmp/merged" ]] && git worktree remove
--force "$tmp/merged"
25 repo
=https
://github.com
/NixOS
/nixpkgs.git
27 if (( $# != 0 )); then
31 trace
"Usage: $0 BASE_BRANCH [REPOSITORY]"
32 trace
"BASE_BRANCH: The base branch to use, e.g. master or release-23.11"
33 trace
"REPOSITORY: The repository to fetch the base branch from, defaults to $repo"
37 if (( $# != 0 )); then
42 if [[ -n "$(git status --porcelain)" ]]; then
43 trace
-e "\e[33mWarning: Dirty tree, uncommitted changes won't be taken into account\e[0m"
45 headSha
=$
(git rev-parse HEAD
)
46 trace
-e "Using HEAD commit \e[34m$headSha\e[0m"
48 trace
-n "Creating Git worktree for the HEAD commit in $tmp/merged.. "
49 git worktree add
--detach -q "$tmp/merged" HEAD
52 trace
-n "Fetching base branch $baseBranch to compare against.. "
53 git fetch
-q "$repo" refs
/heads
/"$baseBranch"
54 baseSha
=$
(git rev-parse FETCH_HEAD
)
55 trace
-e "\e[34m$baseSha\e[0m"
57 trace
-n "Creating Git worktree for the base branch in $tmp/base.. "
58 git worktree add
-q "$tmp/base" "$baseSha"
61 trace
-n "Merging base branch into the HEAD commit in $tmp/merged.. "
62 git
-C "$tmp/merged" merge
-q --no-edit "$baseSha"
63 trace
-e "\e[34m$(git -C "$tmp/merged
" rev-parse HEAD)\e[0m"
65 trace
-n "Reading pinned nixpkgs-check-by-name version from pinned-version.txt.. "
66 toolVersion
=$
(<"$tmp/merged/pkgs/test/check-by-name/pinned-version.txt")
67 trace
-e "\e[34m$toolVersion\e[0m"
69 trace
-n "Building tool.. "
70 nix-build https
://github.com
/NixOS
/nixpkgs-check-by-name
/tarball
/"$toolVersion" -o "$tmp/tool" -A build
72 trace
"Running nixpkgs-check-by-name.."
73 "$tmp/tool/bin/nixpkgs-check-by-name" --base "$tmp/base" "$tmp/merged"