Skip to content

Commit 560eb51

Browse files
roxanan1996shreeya-patel98
authored andcommitted
github actions: Fix download baseline kselftest logs step
After the split, the actual kernelCI workflow will always run from the mainline branch. Hence searching for jobs that match the HEAD_BRANCH of this job is obsolete. There is no way of knowing the HEAD_BRANCH of the kernelCI workflow without publishing the HEAD_BRANCH in the artifacts. When we search for jobs that run in the past to compare kselftests against, we now check the pr_ref from the artifacts and try to match the HEAD_BRANCH. Increased the timeout to 5 minutes, since we have to download an extra artifact in this step (head_reaf). Signed-off-by: Roxana Nicolescu <rnicolescu@ciq.com>
1 parent 40ac8f6 commit 560eb51

1 file changed

Lines changed: 40 additions & 4 deletions

File tree

.github/workflows/kernel-build-and-test-multiarch.yml

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,14 @@ jobs:
198198
echo "skip_kselftests=$SKIP_KSELFTESTS" >> $GITHUB_OUTPUT
199199
echo "is_pr=$IS_PR" >> $GITHUB_OUTPUT
200200
201+
- name: Upload head_ref for baseline search
202+
if: steps.pr_metadata.outputs.skip_ci != 'true'
203+
uses: actions/upload-artifact@v4
204+
with:
205+
name: head-ref
206+
path: pr_metadata/head_ref.txt
207+
retention-days: 7
208+
201209
setup:
202210
name: Setup matrix
203211
runs-on: ubuntu-latest
@@ -606,11 +614,12 @@ jobs:
606614
607615
# Get last 50 successful workflow runs (cast a wider net to find PRs targeting this base)
608616
# We need to check each run to see if it targets the same base branch AND was merged
617+
# The workflow always runs on mainline after the split
609618
SUCCESSFUL_RUNS=$(gh run list \
610619
--workflow kernel-build-and-test-multiarch.yml \
611620
--status success \
612621
--limit 50 \
613-
--json databaseId,headBranch,createdAt)
622+
--json databaseId,createdAt)
614623
615624
if [ -z "$SUCCESSFUL_RUNS" ] || [ "$SUCCESSFUL_RUNS" = "[]" ]; then
616625
echo "::warning::No successful workflow runs found"
@@ -620,14 +629,41 @@ jobs:
620629
# Parse runs and check each one's base branch by examining branch name pattern
621630
while read -r run; do
622631
RUN_ID=$(echo "$run" | jq -r '.databaseId')
623-
HEAD_BRANCH=$(echo "$run" | jq -r '.headBranch')
624-
CREATED_AT=$(echo "$run" | jq -r '.createdAt')
625632
626633
# Skip current run
627634
if [ "$RUN_ID" = "$CURRENT_RUN_ID" ]; then
628635
continue
629636
fi
630637
638+
# Download the head-ref artifact to read the original head_ref.
639+
# This artifact is uploaded by pre-setup and is directly attached to each
640+
# actual workflow run — no need to cross-reference the trigger workflow.
641+
HEAD_REF_ARTIFACT_ID=$(gh api \
642+
"repos/${{ github.repository }}/actions/runs/$RUN_ID/artifacts" \
643+
--jq ".artifacts[] | select(.name == \"head-ref\" and .expired == false) | .id" \
644+
| tail -1)
645+
646+
if [ -z "$HEAD_REF_ARTIFACT_ID" ]; then
647+
echo "Run $RUN_ID: no head-ref artifact, skipping"
648+
continue
649+
fi
650+
651+
rm -rf /tmp/run-head-ref && mkdir -p /tmp/run-head-ref
652+
if ! gh api "repos/${{ github.repository }}/actions/artifacts/$HEAD_REF_ARTIFACT_ID/zip" \
653+
> /tmp/run-head-ref.zip 2>/dev/null || \
654+
! unzip -q /tmp/run-head-ref.zip -d /tmp/run-head-ref 2>/dev/null; then
655+
echo "Run $RUN_ID: failed to download/extract head-ref artifact, skipping"
656+
rm -f /tmp/run-head-ref.zip
657+
continue
658+
fi
659+
rm -f /tmp/run-head-ref.zip
660+
661+
HEAD_BRANCH=$(cat /tmp/run-head-ref/head_ref.txt 2>/dev/null || echo "")
662+
if [ -z "$HEAD_BRANCH" ]; then
663+
echo "Run $RUN_ID: no head_ref.txt in artifact, skipping"
664+
continue
665+
fi
666+
631667
# Extract base from branch name — support both legacy and RLC patterns
632668
EXTRACTED_BASE=""
633669
if [[ "$HEAD_BRANCH" =~ ^\{[^}]+\}_(rlc-[0-9]+/.+)$ ]]; then
@@ -684,7 +720,7 @@ jobs:
684720
echo "::warning::No baseline test results found from merged PRs targeting $BASE_BRANCH"
685721
echo "::notice::This may be the first merged PR targeting this base branch, or artifacts have expired (7-day retention)"
686722
continue-on-error: true
687-
timeout-minutes: 3
723+
timeout-minutes: 5
688724

689725
- name: Compare test results
690726
id: comparison

0 commit comments

Comments
 (0)