Skip to content

Commit

Permalink
workflows/check-by-name: Better error when base branch also fails
Browse files Browse the repository at this point in the history
Previously, even if the check also failed on the base branch, it looked
like the PR introduced the failure.

We can easily have a better error message for such cases.

Meanwhile this also paves the road for something like
NixOS#256788
  • Loading branch information
infinisil committed Sep 27, 2023
1 parent 5bf3c43 commit e933748
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion .github/workflows/check-by-name.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ jobs:
with:
# pull_request_target checks out the base branch by default
ref: refs/pull/${{ github.event.pull_request.number }}/merge
# Fetches the merge commit and its parents
fetch-depth: 2
path: merged
- name: Check out the base commit
# The base commit is the merge commits first parent
run: git -C merged worktree add ../base HEAD^1
- uses: cachix/install-nix-action@v23
- name: Determining channel to use for dependencies
run: |
Expand Down Expand Up @@ -51,4 +57,17 @@ jobs:
# Passing --max-jobs 0 makes sure that we won't build anything
nix-build "$nixpkgs" -A tests.nixpkgs-check-by-name --max-jobs 0
- name: Running nixpkgs-check-by-name
run: result/bin/nixpkgs-check-by-name .
run: |
echo "Checking whether the check succeeds on the base branch $GITHUB_BASE_REF"
if result/bin/nixpkgs-check-by-name base; then
echo "The check succeeds on the base branch $GITHUB_BASE_REF, now checking the PR"
result/bin/nixpkgs-check-by-name merged
else
echo "The check fails on the base branch $GITHUB_BASE_REF, now checking the PR"
if result/bin/nixpkgs-check-by-name merged; then
echo "The check succeeds on the PR, so this fixes the base branch $GITHUB_BASE_REF, nicely done!"
else
echo "The check also fails on the PR, unknown if only this PRs changes would satisfy the check, the base branch $GITHUB_BASE_REF needs to be fixed"
false
fi
fi

0 comments on commit e933748

Please sign in to comment.