mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-18 03:30:45 +00:00
workflows/check-by-name: Slim down and prepare for --base
Now that we have a script to run the check locally, there's no real need to output the information to reproduce anymore, which allows cleaning up the CI workflow. Furthermore, this prepares the CI workflow to be passed `--base`, as introduced recently.
This commit is contained in:
parent
9e03178865
commit
1ad45e503f
92
.github/workflows/check-by-name.yml
vendored
92
.github/workflows/check-by-name.yml
vendored
|
@ -1,5 +1,7 @@
|
|||
# Checks pkgs/by-name (see pkgs/by-name/README.md)
|
||||
# using the nixpkgs-check-by-name tool (see pkgs/test/nixpkgs-check-by-name)
|
||||
#
|
||||
# When you make changes to this workflow, also update pkgs/test/nixpkgs-check-by-name/scripts/run-local.sh adequately
|
||||
name: Check pkgs/by-name
|
||||
|
||||
# The pre-built tool is fetched from a channel,
|
||||
|
@ -75,92 +77,20 @@ jobs:
|
|||
ref: ${{ env.mergedSha }}
|
||||
# Fetches the merge commit and its parents
|
||||
fetch-depth: 2
|
||||
- name: Determining PR git hashes
|
||||
- name: Checking out base branch
|
||||
run: |
|
||||
# For pull_request_target this is the same as $GITHUB_SHA
|
||||
echo "baseSha=$(git rev-parse HEAD^1)" >> "$GITHUB_ENV"
|
||||
|
||||
echo "headSha=$(git rev-parse HEAD^2)" >> "$GITHUB_ENV"
|
||||
base=$(mktemp -d)
|
||||
git worktree add "$base" "$(git rev-parse HEAD^1)"
|
||||
echo "base=$base" >> "$GITHUB_ENV"
|
||||
- uses: cachix/install-nix-action@7ac1ec25491415c381d9b62f0657c7a028df52a7 # v24
|
||||
- name: Fetching the tool
|
||||
run: pkgs/test/nixpkgs-check-by-name/scripts/fetch-tool.sh "$GITHUB_BASE_REF" result
|
||||
- name: Running nixpkgs-check-by-name
|
||||
run: |
|
||||
echo "Checking whether the check succeeds on the base branch $GITHUB_BASE_REF"
|
||||
git checkout -q "$baseSha"
|
||||
if baseOutput=$(result/bin/nixpkgs-check-by-name . 2>&1); then
|
||||
baseSuccess=1
|
||||
if result/bin/nixpkgs-check-by-name .; then
|
||||
exit 0
|
||||
else
|
||||
baseSuccess=
|
||||
exitCode=$?
|
||||
echo "To run locally: ./pkgs/test/nixpkgs-check-by-name/scripts/run-local.sh $GITHUB_BASE_REF https://github.com/$GITHUB_REPOSITORY.git"
|
||||
exit "$exitCode"
|
||||
fi
|
||||
printf "%s\n" "$baseOutput"
|
||||
|
||||
echo "Checking whether the check would succeed after merging this pull request"
|
||||
git checkout -q "$mergedSha"
|
||||
if mergedOutput=$(result/bin/nixpkgs-check-by-name . 2>&1); then
|
||||
mergedSuccess=1
|
||||
exitCode=0
|
||||
else
|
||||
mergedSuccess=
|
||||
exitCode=1
|
||||
fi
|
||||
printf "%s\n" "$mergedOutput"
|
||||
|
||||
resultToEmoji() {
|
||||
if [[ -n "$1" ]]; then
|
||||
echo ":heavy_check_mark:"
|
||||
else
|
||||
echo ":x:"
|
||||
fi
|
||||
}
|
||||
|
||||
# Print a markdown summary in GitHub actions
|
||||
{
|
||||
echo "| Nixpkgs version | Check result |"
|
||||
echo "| --- | --- |"
|
||||
echo "| Latest base commit | $(resultToEmoji "$baseSuccess") |"
|
||||
echo "| After merging this PR | $(resultToEmoji "$mergedSuccess") |"
|
||||
echo ""
|
||||
|
||||
if [[ -n "$baseSuccess" ]]; then
|
||||
if [[ -n "$mergedSuccess" ]]; then
|
||||
echo "The check succeeds on both the base branch and after merging this PR"
|
||||
else
|
||||
echo "The check succeeds on the base branch, but would fail after merging this PR:"
|
||||
echo "\`\`\`"
|
||||
echo "$mergedOutput"
|
||||
echo "\`\`\`"
|
||||
echo ""
|
||||
fi
|
||||
else
|
||||
if [[ -n "$mergedSuccess" ]]; then
|
||||
echo "The check fails on the base branch, but this PR fixes it, nicely done!"
|
||||
else
|
||||
echo "The check fails on both the base branch and after merging this PR, unknown if only this PRs changes would satisfy the check, the base branch needs to be fixed first."
|
||||
echo ""
|
||||
echo "Failure on the base branch:"
|
||||
echo "\`\`\`"
|
||||
echo "$baseOutput"
|
||||
echo "\`\`\`"
|
||||
echo ""
|
||||
echo "Failure after merging this PR:"
|
||||
echo "\`\`\`"
|
||||
echo "$mergedOutput"
|
||||
echo "\`\`\`"
|
||||
echo ""
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "### Details"
|
||||
echo "- nixpkgs-check-by-name tool:"
|
||||
echo " - Channel: $channel"
|
||||
echo " - Nixpkgs commit: [$rev](https://github.com/${GITHUB_REPOSITORY}/commit/$rev)"
|
||||
echo " - Store path: \`$(realpath result)\`"
|
||||
echo "- Tested Nixpkgs:"
|
||||
echo " - Base branch: $GITHUB_BASE_REF"
|
||||
echo " - Latest base branch commit: [$baseSha](https://github.com/${GITHUB_REPOSITORY}/commit/$baseSha)"
|
||||
echo " - Latest PR commit: [$headSha](https://github.com/${GITHUB_REPOSITORY}/commit/$headSha)"
|
||||
echo " - Merge commit: [$mergedSha](https://github.com/${GITHUB_REPOSITORY}/commit/$mergedSha)"
|
||||
} >> "$GITHUB_STEP_SUMMARY"
|
||||
|
||||
exit "$exitCode"
|
||||
|
|
Loading…
Reference in a new issue