mirror of
https://github.com/CHN-beta/nixpkgs.git
synced 2026-01-12 02:40:31 +08:00
workflows/get-merge-commit: return targetSha
We can fetch the targetSha directly with the mergedSha from the API. This avoids a checkout with fetch-depth: 2 for a small performance improvement.
This commit is contained in:
20
.github/workflows/eval.yml
vendored
20
.github/workflows/eval.yml
vendored
@@ -24,23 +24,13 @@ jobs:
|
||||
runs-on: ubuntu-24.04-arm
|
||||
needs: get-merge-commit
|
||||
if: needs.get-merge-commit.outputs.mergedSha
|
||||
outputs:
|
||||
targetSha: ${{ steps.targetSha.outputs.targetSha }}
|
||||
steps:
|
||||
- name: Check out the PR at the test merge commit
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
ref: ${{ needs.get-merge-commit.outputs.mergedSha }}
|
||||
fetch-depth: 2
|
||||
path: nixpkgs
|
||||
|
||||
- name: Determine target commit
|
||||
if: github.event_name == 'pull_request_target'
|
||||
id: targetSha
|
||||
run: |
|
||||
targetSha=$(git -C nixpkgs rev-parse HEAD^1)
|
||||
echo "targetSha=$targetSha" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Install Nix
|
||||
uses: cachix/install-nix-action@526118121621777ccd86f79b04685a9319637641 # v31
|
||||
with:
|
||||
@@ -143,7 +133,7 @@ jobs:
|
||||
path: prResult/*
|
||||
|
||||
- name: Get target run id
|
||||
if: needs.attrs.outputs.targetSha
|
||||
if: needs.get-merge-commit.outputs.targetSha
|
||||
id: targetRunId
|
||||
run: |
|
||||
# Get the latest eval.yml workflow run for the PR's target commit
|
||||
@@ -172,7 +162,7 @@ jobs:
|
||||
echo "targetRunId=$runId" >> "$GITHUB_OUTPUT"
|
||||
env:
|
||||
REPOSITORY: ${{ github.repository }}
|
||||
TARGET_SHA: ${{ needs.attrs.outputs.targetSha }}
|
||||
TARGET_SHA: ${{ needs.get-merge-commit.outputs.targetSha }}
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
|
||||
- uses: actions/download-artifact@v4
|
||||
@@ -186,8 +176,8 @@ jobs:
|
||||
- name: Compare against the target branch
|
||||
if: steps.targetRunId.outputs.targetRunId
|
||||
run: |
|
||||
git -C nixpkgs worktree add ../target ${{ needs.attrs.outputs.targetSha }}
|
||||
git -C nixpkgs diff --name-only ${{ needs.attrs.outputs.targetSha }} \
|
||||
git -C nixpkgs worktree add ../target ${{ needs.get-merge-commit.outputs.targetSha }}
|
||||
git -C nixpkgs diff --name-only ${{ needs.get-merge-commit.outputs.targetSha }} \
|
||||
| jq --raw-input --slurp 'split("\n")[:-1]' > touched-files.json
|
||||
|
||||
# Use the target branch to get accurate maintainer info
|
||||
@@ -241,7 +231,7 @@ jobs:
|
||||
- name: Check out Nixpkgs at the base commit
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
ref: ${{ needs.attrs.outputs.targetSha }}
|
||||
ref: ${{ needs.get-merge-commit.outputs.targetSha }}
|
||||
path: base
|
||||
sparse-checkout: ci
|
||||
|
||||
|
||||
10
.github/workflows/get-merge-commit.yml
vendored
10
.github/workflows/get-merge-commit.yml
vendored
@@ -6,6 +6,9 @@ on:
|
||||
mergedSha:
|
||||
description: "The merge commit SHA"
|
||||
value: ${{ jobs.resolve-merge-commit.outputs.mergedSha }}
|
||||
targetSha:
|
||||
description: "The target commit SHA"
|
||||
value: ${{ jobs.resolve-merge-commit.outputs.targetSha }}
|
||||
systems:
|
||||
description: "The supported systems"
|
||||
value: ${{ jobs.resolve-merge-commit.outputs.systems }}
|
||||
@@ -17,6 +20,7 @@ jobs:
|
||||
runs-on: ubuntu-24.04-arm
|
||||
outputs:
|
||||
mergedSha: ${{ steps.merged.outputs.mergedSha }}
|
||||
targetSha: ${{ steps.merged.outputs.targetSha }}
|
||||
systems: ${{ steps.systems.outputs.systems }}
|
||||
steps:
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
@@ -35,9 +39,9 @@ jobs:
|
||||
echo "mergedSha=${{ github.sha }}" >> "$GITHUB_OUTPUT"
|
||||
;;
|
||||
pull_request_target)
|
||||
if mergedSha=$(base/ci/get-merge-commit.sh ${{ github.repository }} ${{ github.event.number }}); then
|
||||
echo "Checking the merge commit $mergedSha"
|
||||
echo "mergedSha=$mergedSha" >> "$GITHUB_OUTPUT"
|
||||
if commits=$(base/ci/get-merge-commit.sh ${{ github.repository }} ${{ github.event.number }}); then
|
||||
echo "Checking the commits:\n$commits"
|
||||
echo "$commits" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
# Skipping so that no notifications are sent
|
||||
echo "Skipping the rest..."
|
||||
|
||||
Reference in New Issue
Block a user