mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-09 19:13:26 +03:00
workflows/eval: fetch target results in outpaths job
This is an intermediate step towards more efficiency. At this stage, the outpaths job pulls the result from the matching outpaths job on the target branch and uploads both results together. The process job then downloads both results at once and does the comparison as usual. This is slightly more inefficient, because the intermediate results are essentially stored as artifacts twice. But that inefficiency will go away in the next step, this refactor is split to make it slightly more reviewable and testable. On the other side, this allows us to save the process job on push events entirely, which is a win, because most of it is setup and nix download anyway.
This commit is contained in:
parent
13f5aa304e
commit
a6b659b08a
1 changed files with 76 additions and 55 deletions
131
.github/workflows/eval.yml
vendored
131
.github/workflows/eval.yml
vendored
|
@ -84,20 +84,84 @@ jobs:
|
|||
name: merged-${{ matrix.system }}
|
||||
path: merged/*
|
||||
|
||||
- name: Get target run id
|
||||
if: needs.prepare.outputs.targetSha
|
||||
id: targetRunId
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
MATRIX_SYSTEM: ${{ matrix.system }}
|
||||
REPOSITORY: ${{ github.repository }}
|
||||
TARGET_SHA: ${{ needs.prepare.outputs.targetSha }}
|
||||
run: |
|
||||
# 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="$TARGET_SHA" -f event=push \
|
||||
--jq '.workflow_runs | sort_by(.run_started_at) | .[-1]') \
|
||||
|| [[ -z "$run" ]]; then
|
||||
echo "Could not find an eval.yml workflow run for $TARGET_SHA, cannot make comparison"
|
||||
exit 1
|
||||
fi
|
||||
echo "Comparing against $(jq .html_url <<< "$run")"
|
||||
runId=$(jq .id <<< "$run")
|
||||
|
||||
if ! job=$(gh api --method GET /repos/"$REPOSITORY"/actions/runs/"$runId"/jobs \
|
||||
--jq ".jobs[] | select (.name == \"Outpaths ($MATRIX_SYSTEM)\")") \
|
||||
|| [[ -z "$job" ]]; then
|
||||
echo "Could not find the Outpaths ($MATRIX_SYSTEM) job for workflow run $runId, cannot make comparison"
|
||||
exit 1
|
||||
fi
|
||||
jobId=$(jq .id <<< "$job")
|
||||
conclusion=$(jq -r .conclusion <<< "$job")
|
||||
|
||||
while [[ "$conclusion" == null || "$conclusion" == "" ]]; do
|
||||
echo "Job not done, waiting 10 seconds before checking again"
|
||||
sleep 10
|
||||
conclusion=$(gh api /repos/"$REPOSITORY"/actions/jobs/"$jobId" --jq '.conclusion')
|
||||
done
|
||||
|
||||
if [[ "$conclusion" != "success" ]]; then
|
||||
echo "Job was not successful (conclusion: $conclusion), cannot make comparison"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "targetRunId=$runId" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- uses: actions/download-artifact@v4
|
||||
if: steps.targetRunId.outputs.targetRunId
|
||||
with:
|
||||
run-id: ${{ steps.targetRunId.outputs.targetRunId }}
|
||||
name: merged-${{ matrix.system }}
|
||||
path: target
|
||||
github-token: ${{ github.token }}
|
||||
merge-multiple: true
|
||||
|
||||
- name: Upload the output paths and eval stats
|
||||
if: steps.targetRunId.outputs.targetRunId
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: target-${{ matrix.system }}
|
||||
path: target/*
|
||||
|
||||
process:
|
||||
name: Process
|
||||
runs-on: ubuntu-24.04-arm
|
||||
needs: [ prepare, outpaths ]
|
||||
outputs:
|
||||
targetRunId: ${{ steps.targetRunId.outputs.targetRunId }}
|
||||
if: needs.prepare.outputs.targetSha
|
||||
steps:
|
||||
- name: Download output paths and eval stats for all systems
|
||||
- name: Download output paths and eval stats for all systems (PR)
|
||||
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
|
||||
with:
|
||||
pattern: merged-*
|
||||
path: merged
|
||||
merge-multiple: true
|
||||
|
||||
- name: Download output paths and eval stats for all systems (target)
|
||||
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
|
||||
with:
|
||||
pattern: target-*
|
||||
path: target
|
||||
merge-multiple: true
|
||||
|
||||
- name: Check out the PR at the target commit
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
|
@ -109,62 +173,20 @@ jobs:
|
|||
with:
|
||||
extra_nix_config: sandbox = true
|
||||
|
||||
- name: Combine all output paths and eval stats
|
||||
- name: Combine all output paths and eval stats (PR)
|
||||
run: |
|
||||
nix-build trusted/ci -A eval.combine \
|
||||
--arg evalDir ./merged \
|
||||
--out-link combined
|
||||
--out-link combinedMerged
|
||||
|
||||
- name: Upload the combined results
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: combined
|
||||
path: combined/*
|
||||
|
||||
- name: Get target run id
|
||||
- name: Combine all output paths and eval stats (target)
|
||||
if: needs.prepare.outputs.targetSha
|
||||
id: targetRunId
|
||||
env:
|
||||
REPOSITORY: ${{ github.repository }}
|
||||
TARGET_SHA: ${{ needs.prepare.outputs.targetSha }}
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
# 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="$TARGET_SHA" -f event=push \
|
||||
--jq '.workflow_runs | sort_by(.run_started_at) | .[-1]') \
|
||||
|| [[ -z "$run" ]]; then
|
||||
echo "Could not find an eval.yml workflow run for $TARGET_SHA, cannot make comparison"
|
||||
exit 1
|
||||
fi
|
||||
echo "Comparing against $(jq .html_url <<< "$run")"
|
||||
runId=$(jq .id <<< "$run")
|
||||
conclusion=$(jq -r .conclusion <<< "$run")
|
||||
|
||||
while [[ "$conclusion" == null || "$conclusion" == "" ]]; do
|
||||
echo "Workflow not done, waiting 10 seconds before checking again"
|
||||
sleep 10
|
||||
conclusion=$(gh api /repos/"$REPOSITORY"/actions/runs/"$runId" --jq '.conclusion')
|
||||
done
|
||||
|
||||
if [[ "$conclusion" != "success" ]]; then
|
||||
echo "Workflow was not successful (conclusion: $conclusion), cannot make comparison"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "targetRunId=$runId" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- uses: actions/download-artifact@v4
|
||||
if: steps.targetRunId.outputs.targetRunId
|
||||
with:
|
||||
name: combined
|
||||
path: target
|
||||
merge-multiple: true
|
||||
github-token: ${{ github.token }}
|
||||
run-id: ${{ steps.targetRunId.outputs.targetRunId }}
|
||||
nix-build trusted/ci -A eval.combine \
|
||||
--arg evalDir ./target \
|
||||
-o combinedTarget
|
||||
|
||||
- name: Compare against the target branch
|
||||
if: steps.targetRunId.outputs.targetRunId
|
||||
env:
|
||||
AUTHOR_ID: ${{ github.event.pull_request.user.id }}
|
||||
run: |
|
||||
|
@ -174,8 +196,8 @@ jobs:
|
|||
|
||||
# Use the target branch to get accurate maintainer info
|
||||
nix-build trusted/ci -A eval.compare \
|
||||
--arg beforeDir ./target \
|
||||
--arg afterDir "$(realpath combined)" \
|
||||
--arg beforeDir "$(realpath combinedTarget)" \
|
||||
--arg afterDir "$(realpath combinedMerged)" \
|
||||
--arg touchedFilesJson ./touched-files.json \
|
||||
--argstr githubAuthorId "$AUTHOR_ID" \
|
||||
--out-link comparison
|
||||
|
@ -183,7 +205,6 @@ jobs:
|
|||
cat comparison/step-summary.md >> "$GITHUB_STEP_SUMMARY"
|
||||
|
||||
- name: Upload the comparison results
|
||||
if: steps.targetRunId.outputs.targetRunId
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: comparison
|
||||
|
@ -194,7 +215,7 @@ jobs:
|
|||
name: Tag
|
||||
runs-on: ubuntu-24.04-arm
|
||||
needs: [ prepare, process ]
|
||||
if: needs.process.outputs.targetRunId
|
||||
if: needs.prepare.outputs.targetSha
|
||||
permissions:
|
||||
pull-requests: write
|
||||
statuses: write
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue