workflows: rename baseSha to targetSha

We currently use two different "base" commits, but the same name. One of
them is the commit in which context the pull_request_target runs. The
other is the parent of the merge commit. Those are **not** necessarily
the same - see README introduced in the next commit for details.

Renaming one of them for clarity. Since the pull_request_target related
base commit is also called like that in GitHub Actions terminology, we
rename the other. The best I could come up with is "target".

+9 -9
.github/workflows/check-nix-format.yml
···
# Fetches the merge commit and its parents
fetch-depth: 2
-
- name: Checking out base branch
+
- name: Checking out target branch
run: |
-
base=$(mktemp -d)
-
baseRev=$(git rev-parse HEAD^1)
-
git worktree add "$base" "$baseRev"
-
echo "baseRev=$baseRev" >> "$GITHUB_ENV"
-
echo "base=$base" >> "$GITHUB_ENV"
+
target=$(mktemp -d)
+
targetRev=$(git rev-parse HEAD^1)
+
git worktree add "$target" "$targetRev"
+
echo "targetRev=$targetRev" >> "$GITHUB_ENV"
+
echo "target=$target" >> "$GITHUB_ENV"
- name: Get Nixpkgs revision for nixfmt
run: |
···
esac
# Ignore files that weren't already formatted
-
if [[ -n "$source" ]] && ! nixfmt --check ${{ env.base }}/"$source" 2>/dev/null; then
-
echo "Ignoring file $file because it's not formatted in the base commit"
+
if [[ -n "$source" ]] && ! nixfmt --check ${{ env.target }}/"$source" 2>/dev/null; then
+
echo "Ignoring file $file because it's not formatted in the target commit"
elif ! nixfmt --check "$dest"; then
unformattedFiles+=("$dest")
fi
-
done < <(git diff -z --name-status ${{ env.baseRev }} -- '*.nix')
+
done < <(git diff -z --name-status ${{ env.targetRev }} -- '*.nix')
if (( "${#unformattedFiles[@]}" > 0 )); then
echo "Some new/changed Nix files are not properly formatted"
+9 -9
.github/workflows/check-nixf-tidy.yml
···
# Fetches the merge commit and its parents
fetch-depth: 2
-
- name: Checking out base branch
+
- name: Checking out target branch
run: |
-
base=$(mktemp -d)
-
baseRev=$(git rev-parse HEAD^1)
-
git worktree add "$base" "$baseRev"
-
echo "baseRev=$baseRev" >> "$GITHUB_ENV"
-
echo "base=$base" >> "$GITHUB_ENV"
+
target=$(mktemp -d)
+
targetRev=$(git rev-parse HEAD^1)
+
git worktree add "$target" "$targetRev"
+
echo "targetRev=$targetRev" >> "$GITHUB_ENV"
+
echo "target=$target" >> "$GITHUB_ENV"
- name: Get Nixpkgs revision for nixf
run: |
···
continue
esac
-
if [[ -n "$source" ]] && [[ "$(nixf_wrapper ${{ env.base }}/"$source")" != '[]' ]] 2>/dev/null; then
-
echo "Ignoring file $file because it doesn't pass nixf-tidy in the base commit"
+
if [[ -n "$source" ]] && [[ "$(nixf_wrapper ${{ env.target }}/"$source")" != '[]' ]] 2>/dev/null; then
+
echo "Ignoring file $file because it doesn't pass nixf-tidy in the target commit"
echo # insert blank line
else
nixf_report="$(nixf_wrapper "$dest")"
···
failedFiles+=("$dest")
fi
fi
-
done < <(git diff -z --name-status ${{ env.baseRev }} -- '*.nix')
+
done < <(git diff -z --name-status ${{ env.targetRev }} -- '*.nix')
if [[ -n "$DONT_REPORT_ERROR" ]]; then
echo "Edited the PR but didn't change the base branch, only the description/title."
+25 -25
.github/workflows/eval.yml
···
# Skip this and dependent steps if the PR can't be merged
if: needs.get-merge-commit.outputs.mergedSha
outputs:
-
baseSha: ${{ steps.baseSha.outputs.baseSha }}
+
targetSha: ${{ steps.targetSha.outputs.targetSha }}
systems: ${{ steps.systems.outputs.systems }}
steps:
- name: Check out the PR at the test merge commit
···
fetch-depth: 2
path: nixpkgs
-
- name: Determine base commit
+
- name: Determine target commit
if: github.event_name == 'pull_request_target'
-
id: baseSha
+
id: targetSha
run: |
-
baseSha=$(git -C nixpkgs rev-parse HEAD^1)
-
echo "baseSha=$baseSha" >> "$GITHUB_OUTPUT"
+
targetSha=$(git -C nixpkgs rev-parse HEAD^1)
+
echo "targetSha=$targetSha" >> "$GITHUB_OUTPUT"
- name: Install Nix
uses: cachix/install-nix-action@08dcb3a5e62fa31e2da3d490afc4176ef55ecd72 # v30
···
runs-on: ubuntu-24.04
needs: [ outpaths, attrs, get-merge-commit ]
outputs:
-
baseRunId: ${{ steps.baseRunId.outputs.baseRunId }}
+
targetRunId: ${{ steps.targetRunId.outputs.targetRunId }}
steps:
- name: Download output paths and eval stats for all systems
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
···
name: result
path: prResult/*
-
- name: Get base run id
-
if: needs.attrs.outputs.baseSha
-
id: baseRunId
+
- name: Get target run id
+
if: needs.attrs.outputs.targetSha
+
id: targetRunId
run: |
-
# Get the latest eval.yml workflow run for the PR's base commit
+
# Get the latest eval.yml workflow run for the PR's target commit
if ! run=$(gh api --method GET /repos/"$REPOSITORY"/actions/workflows/eval.yml/runs \
-f head_sha="$BASE_SHA" -f event=push \
--jq '.workflow_runs | sort_by(.run_started_at) | .[-1]') \
···
exit 0
fi
-
echo "baseRunId=$runId" >> "$GITHUB_OUTPUT"
+
echo "targetRunId=$runId" >> "$GITHUB_OUTPUT"
env:
REPOSITORY: ${{ github.repository }}
-
BASE_SHA: ${{ needs.attrs.outputs.baseSha }}
+
BASE_SHA: ${{ needs.attrs.outputs.targetSha }}
GH_TOKEN: ${{ github.token }}
- uses: actions/download-artifact@v4
-
if: steps.baseRunId.outputs.baseRunId
+
if: steps.targetRunId.outputs.targetRunId
with:
name: result
-
path: baseResult
+
path: targetResult
github-token: ${{ github.token }}
-
run-id: ${{ steps.baseRunId.outputs.baseRunId }}
+
run-id: ${{ steps.targetRunId.outputs.targetRunId }}
-
- name: Compare against the base branch
-
if: steps.baseRunId.outputs.baseRunId
+
- name: Compare against the target branch
+
if: steps.targetRunId.outputs.targetRunId
run: |
-
git -C nixpkgs worktree add ../base ${{ needs.attrs.outputs.baseSha }}
-
git -C nixpkgs diff --name-only ${{ needs.attrs.outputs.baseSha }} \
+
git -C nixpkgs worktree add ../target ${{ needs.attrs.outputs.targetSha }}
+
git -C nixpkgs diff --name-only ${{ needs.attrs.outputs.targetSha }} \
| jq --raw-input --slurp 'split("\n")[:-1]' > touched-files.json
-
# Use the base branch to get accurate maintainer info
-
nix-build base/ci -A eval.compare \
-
--arg beforeResultDir ./baseResult \
+
# Use the target branch to get accurate maintainer info
+
nix-build target/ci -A eval.compare \
+
--arg beforeResultDir ./targetResult \
--arg afterResultDir ./prResult \
--arg touchedFilesJson ./touched-files.json \
-o comparison
···
cat comparison/step-summary.md >> "$GITHUB_STEP_SUMMARY"
- name: Upload the combined results
-
if: steps.baseRunId.outputs.baseRunId
+
if: steps.targetRunId.outputs.targetRunId
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
with:
name: comparison
···
name: Tag
runs-on: ubuntu-24.04
needs: [ attrs, process ]
-
if: needs.process.outputs.baseRunId
+
if: needs.process.outputs.targetRunId
permissions:
pull-requests: write
statuses: write
···
- name: Check out Nixpkgs at the base commit
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
-
ref: ${{ needs.attrs.outputs.baseSha }}
+
ref: ${{ needs.attrs.outputs.targetSha }}
path: base
sparse-checkout: ci
+5 -5
.github/workflows/nixpkgs-vet.yml
···
# Fetches the merge commit and its parents
fetch-depth: 2
-
- name: Checking out base branch
+
- name: Checking out target branch
run: |
-
base=$(mktemp -d)
-
git worktree add "$base" "$(git rev-parse HEAD^1)"
-
echo "base=$base" >> "$GITHUB_ENV"
+
target=$(mktemp -d)
+
git worktree add "$target" "$(git rev-parse HEAD^1)"
+
echo "target=$target" >> "$GITHUB_ENV"
- uses: cachix/install-nix-action@08dcb3a5e62fa31e2da3d490afc4176ef55ecd72 # v30
···
# Force terminal colors to be enabled. The library that `nixpkgs-vet` uses respects https://bixense.com/clicolors/
CLICOLOR_FORCE: 1
run: |
-
if result/bin/nixpkgs-vet --base "$base" .; then
+
if result/bin/nixpkgs-vet --base "$target" .; then
exit 0
else
exitCode=$?