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"