2024-01-16 18:30:21 +01:00
|
|
|
#!/usr/bin/env nix-shell
|
2024-01-29 13:39:26 +01:00
|
|
|
#!nix-shell -i bash -p jq
|
2023-12-16 03:13:12 +01:00
|
|
|
|
2023-12-21 23:05:14 +01:00
|
|
|
set -o pipefail -o errexit -o nounset
|
2023-12-16 03:13:12 +01:00
|
|
|
|
2023-12-21 23:05:14 +01:00
|
|
|
trace() { echo >&2 "$@"; }
|
|
|
|
|
|
|
|
tmp=$(mktemp -d)
|
2023-12-16 03:13:12 +01:00
|
|
|
cleanup() {
|
2023-12-21 23:05:14 +01:00
|
|
|
# Don't exit early if anything fails to cleanup
|
|
|
|
set +o errexit
|
|
|
|
|
|
|
|
trace -n "Cleaning up.. "
|
|
|
|
|
|
|
|
[[ -e "$tmp/base" ]] && git worktree remove --force "$tmp/base"
|
|
|
|
[[ -e "$tmp/merged" ]] && git worktree remove --force "$tmp/merged"
|
|
|
|
|
|
|
|
rm -rf "$tmp"
|
|
|
|
|
|
|
|
trace "Done"
|
2023-12-16 03:13:12 +01:00
|
|
|
}
|
|
|
|
trap cleanup exit
|
|
|
|
|
|
|
|
|
|
|
|
repo=https://github.com/NixOS/nixpkgs.git
|
|
|
|
|
|
|
|
if (( $# != 0 )); then
|
|
|
|
baseBranch=$1
|
|
|
|
shift
|
|
|
|
else
|
2023-12-21 23:05:14 +01:00
|
|
|
trace "Usage: $0 BASE_BRANCH [REPOSITORY]"
|
|
|
|
trace "BASE_BRANCH: The base branch to use, e.g. master or release-23.11"
|
|
|
|
trace "REPOSITORY: The repository to fetch the base branch from, defaults to $repo"
|
2023-12-16 03:13:12 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if (( $# != 0 )); then
|
|
|
|
repo=$1
|
|
|
|
shift
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -n "$(git status --porcelain)" ]]; then
|
2023-12-21 23:05:14 +01:00
|
|
|
trace -e "\e[33mWarning: Dirty tree, uncommitted changes won't be taken into account\e[0m"
|
2023-12-16 03:13:12 +01:00
|
|
|
fi
|
|
|
|
headSha=$(git rev-parse HEAD)
|
2023-12-21 23:05:14 +01:00
|
|
|
trace -e "Using HEAD commit \e[34m$headSha\e[0m"
|
2023-12-16 03:13:12 +01:00
|
|
|
|
2023-12-21 23:05:14 +01:00
|
|
|
trace -n "Creating Git worktree for the HEAD commit in $tmp/merged.. "
|
2023-12-16 03:13:12 +01:00
|
|
|
git worktree add --detach -q "$tmp/merged" HEAD
|
2023-12-21 23:05:14 +01:00
|
|
|
trace "Done"
|
2023-12-16 03:13:12 +01:00
|
|
|
|
2023-12-21 23:05:14 +01:00
|
|
|
trace -n "Fetching base branch $baseBranch to compare against.. "
|
2023-12-16 03:13:12 +01:00
|
|
|
git fetch -q "$repo" refs/heads/"$baseBranch"
|
|
|
|
baseSha=$(git rev-parse FETCH_HEAD)
|
2023-12-21 23:05:14 +01:00
|
|
|
trace -e "\e[34m$baseSha\e[0m"
|
2023-12-16 03:13:12 +01:00
|
|
|
|
2023-12-21 23:05:14 +01:00
|
|
|
trace -n "Creating Git worktree for the base branch in $tmp/base.. "
|
2023-12-16 03:13:12 +01:00
|
|
|
git worktree add -q "$tmp/base" "$baseSha"
|
2023-12-21 23:05:14 +01:00
|
|
|
trace "Done"
|
2023-12-16 03:13:12 +01:00
|
|
|
|
2023-12-21 23:05:14 +01:00
|
|
|
trace -n "Merging base branch into the HEAD commit in $tmp/merged.. "
|
2023-12-16 03:13:12 +01:00
|
|
|
git -C "$tmp/merged" merge -q --no-edit "$baseSha"
|
2023-12-21 23:05:14 +01:00
|
|
|
trace -e "\e[34m$(git -C "$tmp/merged" rev-parse HEAD)\e[0m"
|
2023-12-16 03:13:12 +01:00
|
|
|
|
2024-03-22 02:20:08 +01:00
|
|
|
trace -n "Reading pinned nixpkgs-check-by-name version from pinned-version.txt.. "
|
|
|
|
toolVersion=$(<"$tmp/merged/pkgs/test/check-by-name/pinned-version.txt")
|
|
|
|
trace -e "\e[34m$toolVersion\e[0m"
|
2024-01-16 23:04:26 +01:00
|
|
|
|
2024-03-22 02:20:08 +01:00
|
|
|
trace -n "Building tool.. "
|
|
|
|
nix-build https://github.com/NixOS/nixpkgs-check-by-name/tarball/"$toolVersion" -o "$tmp/tool" -A build
|
2023-12-16 03:13:12 +01:00
|
|
|
|
2023-12-21 23:05:14 +01:00
|
|
|
trace "Running nixpkgs-check-by-name.."
|
2023-12-19 23:12:41 +01:00
|
|
|
"$tmp/tool/bin/nixpkgs-check-by-name" --base "$tmp/base" "$tmp/merged"
|