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".
This commit is contained in:
18
.github/workflows/check-nix-format.yml
vendored
18
.github/workflows/check-nix-format.yml
vendored
@@ -31,13 +31,13 @@ jobs:
|
||||
# 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: |
|
||||
@@ -85,12 +85,12 @@ jobs:
|
||||
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"
|
||||
|
||||
18
.github/workflows/check-nixf-tidy.yml
vendored
18
.github/workflows/check-nixf-tidy.yml
vendored
@@ -20,13 +20,13 @@ jobs:
|
||||
# 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: |
|
||||
@@ -91,8 +91,8 @@ jobs:
|
||||
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")"
|
||||
@@ -119,7 +119,7 @@ jobs:
|
||||
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."
|
||||
|
||||
50
.github/workflows/eval.yml
vendored
50
.github/workflows/eval.yml
vendored
@@ -26,7 +26,7 @@ jobs:
|
||||
# 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
|
||||
@@ -36,12 +36,12 @@ jobs:
|
||||
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
|
||||
@@ -128,7 +128,7 @@ jobs:
|
||||
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
|
||||
@@ -158,11 +158,11 @@ jobs:
|
||||
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]') \
|
||||
@@ -185,30 +185,30 @@ jobs:
|
||||
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
|
||||
@@ -216,7 +216,7 @@ jobs:
|
||||
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
|
||||
@@ -227,7 +227,7 @@ jobs:
|
||||
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
|
||||
@@ -254,7 +254,7 @@ jobs:
|
||||
- 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
|
||||
|
||||
|
||||
10
.github/workflows/nixpkgs-vet.yml
vendored
10
.github/workflows/nixpkgs-vet.yml
vendored
@@ -39,11 +39,11 @@ jobs:
|
||||
# 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
|
||||
|
||||
@@ -65,7 +65,7 @@ jobs:
|
||||
# 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=$?
|
||||
|
||||
Reference in New Issue
Block a user