From 8ea3a59601ae4841bca2e418186b7e0e0b356256 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Thu, 21 Nov 2024 09:08:25 +0100 Subject: [PATCH 1/7] ci: use nix 2.24 (cherry picked from commit d65d18f1e48709dfdc7ca70b8945a1818aa870b5) --- ci/eval/default.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ci/eval/default.nix b/ci/eval/default.nix index 5bd2b48d710d9..1855efc79f5e8 100644 --- a/ci/eval/default.nix +++ b/ci/eval/default.nix @@ -5,7 +5,7 @@ linkFarm, time, procps, - nix, + nixVersions, jq, sta, }: @@ -29,6 +29,8 @@ let ); }; + nix = nixVersions.nix_2_24; + supportedSystems = import ../supportedSystems.nix; attrpathsSuperset = From e4e9f713cb501775d6c21e2e739d0ac7bb8c6044 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Fri, 29 Nov 2024 21:31:24 +0100 Subject: [PATCH 2/7] ci/eval: don't allow IFD (cherry picked from commit 5978e7fa2fbec36ba253fb78e5ffaab13f7192bc) --- ci/eval/default.nix | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ci/eval/default.nix b/ci/eval/default.nix index 1855efc79f5e8..efd8d6637a2dd 100644 --- a/ci/eval/default.nix +++ b/ci/eval/default.nix @@ -50,8 +50,12 @@ let export GC_INITIAL_HEAP_SIZE=4g command time -v \ nix-instantiate --eval --strict --json --show-trace \ - $src/pkgs/top-level/release-attrpaths-superset.nix -A paths \ - --arg enableWarnings false > $out/paths.json + "$src/pkgs/top-level/release-attrpaths-superset.nix" \ + -A paths \ + -I "$src" \ + --option restrict-eval true \ + --option allow-import-from-derivation false \ + --arg enableWarnings false > $out/paths.json mv "$supportedSystemsPath" $out/systems.json ''; @@ -84,6 +88,8 @@ let set +e command time -f "Chunk $myChunk on $system done [%MKB max resident, %Es elapsed] %C" \ nix-env -f "${nixpkgs}/pkgs/top-level/release-attrpaths-parallel.nix" \ + --option restrict-eval true \ + --option allow-import-from-derivation false \ --query --available \ --no-name --attr-path --out-path \ --show-trace \ @@ -93,6 +99,8 @@ let --arg systems "[ \"$system\" ]" \ --arg checkMeta ${lib.boolToString checkMeta} \ --arg includeBroken ${lib.boolToString includeBroken} \ + -I ${nixpkgs} \ + -I ${attrpathFile} \ > "$outputDir/result/$myChunk" exitCode=$? set -e From 9f8839dcaec2d4d23b5c1bca366bea5d194d9250 Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Sat, 30 Nov 2024 02:01:34 +0100 Subject: [PATCH 3/7] workflows/eval: Make sure to compare against the push run For PRs whose commits end up as HEAD of master like https://github.com/NixOS/nixpkgs/commit/bcc5c141bf43460909b83740e96ceeea6d0f7e12, there might be workflow runs associated with both PRs and pushes. Only the push event is the one that will run fully and should be used to compare against. So far it didn't distinguish between the two events, causing it to sometimes pick the wrong one and then fail to download non-existent artifacts: https://github.com/NixOS/nixpkgs/actions/runs/12092053414/job/33721377179 This commit fixes that by ensuring that the push event result is compared against (cherry picked from commit b3e8e251f3087eaa971a087f9948bbf21ae3d14d) --- .github/workflows/eval.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/eval.yml b/.github/workflows/eval.yml index 90be4670e414b..1494d97141bb4 100644 --- a/.github/workflows/eval.yml +++ b/.github/workflows/eval.yml @@ -168,7 +168,7 @@ jobs: run: | # Get the latest eval.yml workflow run for the PR's base commit if ! run=$(gh api --method GET /repos/"$REPOSITORY"/actions/workflows/eval.yml/runs \ - -f head_sha="$BASE_SHA" \ + -f head_sha="$BASE_SHA" -f event=push \ --jq '.workflow_runs | sort_by(.run_started_at) | .[-1]') \ || [[ -z "$run" ]]; then echo "Could not find an eval.yml workflow run for $BASE_SHA, cannot make comparison" From 9771416c965fb7bdd37a1727ea6045a5638faed5 Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Sat, 30 Nov 2024 02:49:40 +0100 Subject: [PATCH 4/7] workflows/eval: Clear unnecessary rebuild labels Previously the labels would never be removed, even if the number of rebuilds changed (cherry picked from commit ea65e3038a72e0fc5700c40e45ae4b8642401c59) --- .github/workflows/eval.yml | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/.github/workflows/eval.yml b/.github/workflows/eval.yml index 1494d97141bb4..c318acad7bca9 100644 --- a/.github/workflows/eval.yml +++ b/.github/workflows/eval.yml @@ -237,9 +237,33 @@ jobs: - name: Tagging pull request run: | + # Get all currently set rebuild labels gh api \ - --method POST \ - /repos/${{ github.repository }}/issues/${{ github.event.number }}/labels \ - --input <(jq -c '{ labels: .labels }' comparison/changed-paths.json) + /repos/"$REPOSITORY"/issues/"$NUMBER"/labels \ + --jq '.[].name | select(startswith("10.rebuild"))' \ + | sort > before + + # And the labels that should be there + jq -r '.labels[]' comparison/changed-paths.json \ + | sort > after + + # Remove the ones not needed anymore + while read -r toRemove; do + echo "Removing label $toRemove" + gh api \ + --method DELETE \ + /repos/"$REPOSITORY"/issues/"$NUMBER"/labels/"$toRemove" + done < <(comm -23 before after) + + # And add the ones that aren't set already + while read -r toAdd; do + echo "Adding label $toAdd" + gh api \ + --method POST \ + /repos/"$REPOSITORY"/issues/"$NUMBER"/labels \ + -f "labels[]=$toAdd" + done < <(comm -13 before after) env: GH_TOKEN: ${{ github.token }} + REPOSITORY: ${{ github.repository }} + NUMBER: ${{ github.event.number }} From 432bc2ceacd6d801fb74acebe6093fa00cb11be4 Mon Sep 17 00:00:00 2001 From: Noa Aarts Date: Sat, 30 Nov 2024 08:58:30 +0100 Subject: [PATCH 5/7] github/workflows/eval: add markdown of added, removed and changed (cherry picked from commit 0e27bc3f9e23c20ad1e2f0b7399be165710dc5e6) --- .github/workflows/eval.yml | 2 +- ci/eval/default.nix | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/eval.yml b/.github/workflows/eval.yml index c318acad7bca9..3a061961a0cdf 100644 --- a/.github/workflows/eval.yml +++ b/.github/workflows/eval.yml @@ -210,7 +210,7 @@ jobs: --arg beforeResultDir ./baseResult \ --arg afterResultDir ./prResult \ -o comparison - + cat comparison/step-summary.md >> "$GITHUB_STEP_SUMMARY" # TODO: Request reviews from maintainers for packages whose files are modified in the PR - name: Upload the combined results diff --git a/ci/eval/default.nix b/ci/eval/default.nix index efd8d6637a2dd..775b259bfa873 100644 --- a/ci/eval/default.nix +++ b/ci/eval/default.nix @@ -261,6 +261,11 @@ let --slurpfile after ${afterResultDir}/outpaths.json \ > $out/changed-paths.json + jq -r ' + "## Added\n" + (.attrdiff.added | map("- \(. )") | join("\n")) + "\n" + + "## Removed\n" + (.attrdiff.removed | map("- \(. )") | join("\n")) + "\n" + + "## Changed\n" + (.attrdiff.changed | map("- \(. )") | join("\n")) + "\n" + ' < $out/changed-paths.json > $out/step-summary.md # TODO: Compare eval stats ''; From bd1bcde2ecc01fe0fc3a42e8b8a93187165ed471 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sun, 1 Dec 2024 07:15:22 +0100 Subject: [PATCH 6/7] github/workflows/eval: limit number of packages in markdown (cherry picked from commit 8b7ed6e105f377e01f5da3c3a022b65d3b03a023) --- ci/eval/default.nix | 6 +----- ci/eval/generate-step-summary.jq | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 ci/eval/generate-step-summary.jq diff --git a/ci/eval/default.nix b/ci/eval/default.nix index 775b259bfa873..ef107d4ce517a 100644 --- a/ci/eval/default.nix +++ b/ci/eval/default.nix @@ -261,11 +261,7 @@ let --slurpfile after ${afterResultDir}/outpaths.json \ > $out/changed-paths.json - jq -r ' - "## Added\n" + (.attrdiff.added | map("- \(. )") | join("\n")) + "\n" + - "## Removed\n" + (.attrdiff.removed | map("- \(. )") | join("\n")) + "\n" + - "## Changed\n" + (.attrdiff.changed | map("- \(. )") | join("\n")) + "\n" - ' < $out/changed-paths.json > $out/step-summary.md + jq -r -f ${./generate-step-summary.jq} < $out/changed-paths.json > $out/step-summary.md # TODO: Compare eval stats ''; diff --git a/ci/eval/generate-step-summary.jq b/ci/eval/generate-step-summary.jq new file mode 100644 index 0000000000000..f76ea15e365fd --- /dev/null +++ b/ci/eval/generate-step-summary.jq @@ -0,0 +1,14 @@ +def truncate(xs; n): + if xs | length > n then xs[:n] + ["..."] + else xs + end; + +def itemize_packages(xs): + truncate(xs; 3000) | map("- \(. )") | join("\n"); + +def section(title; xs): + "## " + title + " (" + (xs | length | tostring) + ")\n" + itemize_packages(xs); + +section("Added"; .attrdiff.added) + "\n\n" + +section("Removed"; .attrdiff.removed) + "\n\n" + +section("Changed"; .attrdiff.changed) From 7ea19651d6607742efc31eab9a35e9558f2699b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sun, 1 Dec 2024 11:58:30 +0100 Subject: [PATCH 7/7] github/workflows/eval: add nixos package search links and wrap sections in a summary list (cherry picked from commit 006691de3c82d0a0701f66242afc674ba3d9a89b) --- ci/eval/generate-step-summary.jq | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ci/eval/generate-step-summary.jq b/ci/eval/generate-step-summary.jq index f76ea15e365fd..28597eaec371f 100644 --- a/ci/eval/generate-step-summary.jq +++ b/ci/eval/generate-step-summary.jq @@ -4,11 +4,12 @@ def truncate(xs; n): end; def itemize_packages(xs): - truncate(xs; 3000) | map("- \(. )") | join("\n"); + # we truncate the list to stay below the GitHub limit of 1MB per step summary. + truncate(xs; 3000) | map("- [\(.)](https://search.nixos.org/packages?channel=unstable&show=\(.)&from=0&size=50&sort=relevance&type=packages&query=\(.))") | join("\n"); def section(title; xs): - "## " + title + " (" + (xs | length | tostring) + ")\n" + itemize_packages(xs); + "
" + title + " (" + (xs | length | tostring) + ")\n\n" + itemize_packages(xs) + "
"; -section("Added"; .attrdiff.added) + "\n\n" + -section("Removed"; .attrdiff.removed) + "\n\n" + -section("Changed"; .attrdiff.changed) +section("Added packages"; .attrdiff.added) + "\n\n" + +section("Removed packages"; .attrdiff.removed) + "\n\n" + +section("Changed packages"; .attrdiff.changed)