6969 default : false
7070
7171jobs :
72+ prepare :
73+ runs-on : ubuntu-latest
74+ outputs :
75+ pr : ${{ steps.pr.outputs.pr }}
76+ head : ${{ steps.pr.outputs.head }}
77+ merge : ${{ steps.pr.outputs.merge }}
78+
79+ steps :
80+ - name : get pr
81+ id : pr
82+ run : |
83+ while true; do
84+ pr="$(gh api "/repos/NixOS/nixpkgs/pulls/$PR_NUMBER")"
85+ jq -e '.mergeable_state == "unknown" and (.merged | not)' <<< "$pr" > /dev/null || break
86+ echo "mergeable state not known yet, retrying..."
87+ sleep 2
88+ done
89+ jq <<< "$pr"
90+ if [[ "$(jq '.merged or .mergeable' <<< "$pr")" != "true" ]]; then
91+ echo "::error::PR is not mergeable"
92+ exit 1
93+ fi
94+ echo "pr=$pr" >> "$GITHUB_OUTPUT"
95+ echo "head=$(jq -r '.head.sha' <<< "$pr")" >> "$GITHUB_OUTPUT"
96+ echo "merge=$(jq -r '.merge_commit_sha' <<< "$pr")" >> "$GITHUB_OUTPUT"
97+ env :
98+ GH_TOKEN : ${{ github.token }}
99+
72100 review :
101+ needs : [prepare]
73102 strategy :
74103 fail-fast : false
75104 matrix :
@@ -101,7 +130,9 @@ jobs:
101130 steps :
102131 - uses : actions/checkout@v4
103132 with :
104- sparse-checkout : .github/actions
133+ sparse-checkout : |
134+ .github/actions
135+ packages.nix
105136
106137 - name : setup nix
107138 uses : ./.github/actions/setup-nix
@@ -122,9 +153,7 @@ jobs:
122153 elif [[ ${{ inputs.push-to-cache && vars.CACHIX_CACHE != '' }} = true ]]; then
123154 pkgs+=(cachix)
124155 fi
125- args=()
126- for pkg in ${pkgs[@]}; do args+=("github:nixos/nixpkgs/nixpkgs-unstable#$pkg"); done
127- nix profile install ${args[@]}
156+ nix profile install -f packages.nix ${pkgs[@]}
128157
129158 - name : clone nixpkgs
130159 uses : actions/checkout@v4
@@ -141,12 +170,14 @@ jobs:
141170 --no-headers \
142171 --print-result \
143172 --build-args="-L" \
173+ --pr-json="$PR_JSON" \
144174 $EXTRA_ARGS \
145175 || true
146176 working-directory : nixpkgs
147177 env :
148178 GITHUB_TOKEN : ${{ github.token }}
149179 EXTRA_ARGS : ${{ inputs.extra-args }}
180+ PR_JSON : ${{ needs.prepare.outputs.pr }}
150181
151182 - name : push results to cache
152183 if : ${{ inputs.push-to-cache && ((vars.ATTIC_SERVER != '' && vars.ATTIC_CACHE != '') || vars.CACHIX_CACHE != '') }}
@@ -227,7 +258,7 @@ jobs:
227258
228259 report :
229260 runs-on : ubuntu-latest
230- needs : [review]
261+ needs : [prepare, review]
231262 outputs :
232263 report : ${{ steps.report.outputs.report }}
233264 success : ${{ steps.report.outputs.success }}
@@ -238,7 +269,9 @@ jobs:
238269 run : |
239270 echo -e "## \`nixpkgs-review\` result\n" >> report.md
240271 echo -e "Generated using [\`nixpkgs-review-gha\`](https://github.com/Defelo/nixpkgs-review-gha)\n" >> report.md
241- echo -e "Command: \`nixpkgs-review pr ${PR_NUMBER}${EXTRA_ARGS:+ $EXTRA_ARGS}\`\n" >> report.md
272+ echo -e "Command: \`nixpkgs-review pr ${PR_NUMBER}${EXTRA_ARGS:+ $EXTRA_ARGS}\`" >> report.md
273+ echo -e "Commit: [\`$HEAD\`](https://github.com/NixOS/nixpkgs/commit/$HEAD) ([subsequent changes](https://github.com/NixOS/nixpkgs/compare/$HEAD..pull/$PR_NUMBER/head))" >> report.md
274+ echo -e "Merge: [\`$MERGE\`](https://github.com/NixOS/nixpkgs/commit/$MERGE)\n" >> report.md
242275 echo -e "Logs: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\n" >> report.md
243276
244277 mkdir .tmp
@@ -276,6 +309,8 @@ jobs:
276309 echo success=$(jq -s 'all(.[].result[]; .failed==[])' reports/*.json) >> "$GITHUB_OUTPUT"
277310 sed '1s|$| for [#'"$PR_NUMBER"'](https://github.com/NixOS/nixpkgs/pull/'"$PR_NUMBER"')|' report.md >> $GITHUB_STEP_SUMMARY
278311 env :
312+ HEAD : ${{ needs.prepare.outputs.head }}
313+ MERGE : ${{ needs.prepare.outputs.merge }}
279314 EXTRA_ARGS : ${{ inputs.extra-args }}
280315 FETCH_CMD_X86_64_LINUX : ${{ needs.review.outputs.fetch_cmd_x86_64-linux }}
281316 FETCH_CMD_AARCH64_LINUX : ${{ needs.review.outputs.fetch_cmd_aarch64-linux }}
0 commit comments