From f7ea336cb2bd403bb0bc8ce9ce48479a1427de18 Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Fri, 22 Mar 2024 02:20:08 +0100 Subject: [PATCH] workflows/check-by-name.yml: Switch to new separate repo The nixpkgs-check-by-name tooling is [being moved](https://github.com/NixOS/nixpkgs/issues/286559#issuecomment-2000466124) to a [separate repo](https://github.com/NixOS/nixpkgs-check-by-name). This commit updates Nixpkgs CI to use it instead of the tree inside Nixpkgs No changes have been made to the tooling locally since it was moved: - [Exported history](https://github.com/NixOS/nixpkgs/commits/55bf02190ee57fcf83490fd7b6bf7834e28c9c86/pkgs/test/nixpkgs-check-by-name) - [Imported history](https://github.com/NixOS/nixpkgs-check-by-name/commits/d579e1821d56c79fd90dab34b991cc7bdab7a5c6/) --- .github/workflows/check-by-name.yml | 20 +++++----- maintainers/scripts/README.md | 2 +- maintainers/scripts/check-by-name.sh | 2 +- nixos/release-combined.nix | 5 --- pkgs/by-name/README.md | 6 +-- .../scripts => check-by-name}/README.md | 17 +++----- pkgs/test/check-by-name/pinned-version.txt | 1 + .../scripts => check-by-name}/run-local.sh | 19 +++------ pkgs/test/check-by-name/update-pinned-tool.sh | 22 ++++++++++ .../scripts/update-pinned-tool.sh | 40 ------------------- 10 files changed, 48 insertions(+), 86 deletions(-) rename pkgs/test/{nixpkgs-check-by-name/scripts => check-by-name}/README.md (60%) create mode 100644 pkgs/test/check-by-name/pinned-version.txt rename pkgs/test/{nixpkgs-check-by-name/scripts => check-by-name}/run-local.sh (73%) create mode 100755 pkgs/test/check-by-name/update-pinned-tool.sh delete mode 100755 pkgs/test/nixpkgs-check-by-name/scripts/update-pinned-tool.sh diff --git a/.github/workflows/check-by-name.yml b/.github/workflows/check-by-name.yml index bf6acf3701da..bdc223e3d32c 100644 --- a/.github/workflows/check-by-name.yml +++ b/.github/workflows/check-by-name.yml @@ -1,11 +1,9 @@ # Checks pkgs/by-name (see pkgs/by-name/README.md) -# using the nixpkgs-check-by-name tool (see pkgs/test/nixpkgs-check-by-name) +# using the nixpkgs-check-by-name tool (see https://github.com/NixOS/nixpkgs-check-by-name) # -# When you make changes to this workflow, also update pkgs/test/nixpkgs-check-by-name/scripts/run-local.sh adequately +# When you make changes to this workflow, also update pkgs/test/check-by-name/run-local.sh adequately name: Check pkgs/by-name -# The tool is pinned to a pre-built version on Hydra, -# see pkgs/test/nixpkgs-check-by-name/scripts/README.md on: # Using pull_request_target instead of pull_request avoids having to approve first time contributors pull_request_target: @@ -24,8 +22,7 @@ permissions: jobs: check: - # This is x86_64-linux, for which the tool is always prebuilt on the nixos-* channels, - # as specified in nixos/release-combined.nix + # This needs to be x86_64-linux, because we depend on the tooling being pre-built in the GitHub releases runs-on: ubuntu-latest # This should take 1 minute at most, but let's be generous. # The default of 6 hours is definitely too long @@ -100,11 +97,14 @@ jobs: echo "base=$base" >> "$GITHUB_ENV" - uses: cachix/install-nix-action@8887e596b4ee1134dae06b98d573bd674693f47c # v26 - name: Fetching the pinned tool - # Update the pinned version using pkgs/test/nixpkgs-check-by-name/scripts/update-pinned-tool.sh + # Update the pinned version using pkgs/test/check-by-name/update-pinned-tool.sh run: | - # Get the direct /nix/store path from the pin to avoid having to evaluate Nixpkgs - toolPath=$(jq -r '."ci-path"' pkgs/test/nixpkgs-check-by-name/scripts/pinned-tool.json) - # This asks the substituter for the path, which should be there because Hydra will have pre-built and pushed it + # The pinned version of the tooling to use + toolVersion=$(&2 "$@"; } + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +repository=NixOS/nixpkgs-check-by-name +pin_file=$SCRIPT_DIR/pinned-version.txt + +trace -n "Fetching latest release of $repository.. " +latestRelease=$(curl -sSfL \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/"$repository"/releases/latest) +latestVersion=$(jq .tag_name -r <<< "$latestRelease") +trace "$latestVersion" + +trace "Updating $pin_file" +echo "$latestVersion" > "$pin_file" diff --git a/pkgs/test/nixpkgs-check-by-name/scripts/update-pinned-tool.sh b/pkgs/test/nixpkgs-check-by-name/scripts/update-pinned-tool.sh deleted file mode 100755 index dbc6e91df08a..000000000000 --- a/pkgs/test/nixpkgs-check-by-name/scripts/update-pinned-tool.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env nix-shell -#!nix-shell -i bash -p jq - -set -o pipefail -o errexit -o nounset - -trace() { echo >&2 "$@"; } - -SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) - -# Determined by `runs-on: ubuntu-latest` in .github/workflows/check-by-name.yml -CI_SYSTEM=x86_64-linux - -channel=nixos-unstable -pin_file=$SCRIPT_DIR/pinned-tool.json - -trace -n "Fetching latest version of channel $channel.. " -# This is probably the easiest way to get Nix to output the path to a downloaded channel! -nixpkgs=$(nix-instantiate --find-file nixpkgs -I nixpkgs=channel:"$channel") -trace "$nixpkgs" - -# This file only exists in channels -rev=$(<"$nixpkgs/.git-revision") -trace -e "Git revision of channel $channel is \e[34m$rev\e[0m" - -trace -n "Fetching the prebuilt version of nixpkgs-check-by-name for $CI_SYSTEM.. " -# This is the architecture used by CI, we want to prefetch the exact path to avoid having to evaluate Nixpkgs -ci_path=$(nix-build --no-out-link "$nixpkgs" \ - -A tests.nixpkgs-check-by-name \ - --arg config '{}' \ - --argstr system "$CI_SYSTEM" \ - --arg overlays '[]' \ - -j 0 \ - | tee /dev/stderr) - -trace "Updating $pin_file" -jq -n \ - --arg rev "$rev" \ - --arg ci-path "$ci_path" \ - '$ARGS.named' \ - > "$pin_file"