Skip to content

Commit 47f1211

Browse files
github-actions: Add CBR support in kernelCI
build_kernel.sh calls image_from_container.sh by name (PATH lookup), which resolves to /usr/local/bin/ in the builder container. Mount the version from kernel-container-build directly there so CI always uses the latest script. Allow callers to skip the kselftests stage entirely. Useful for CBR (RHEL 7) where kselftest coverage is minimal due to the old kernel. Now compare-results always runs when build+boot succeed, but gates the three kselftest-specific steps (download current logs, download baseline, compare results) on !inputs.skip_kselftests. Base branch detection always runs, ensuring create-pr has the base branch in all scenarios including force pushes with existing PRs. Signed-off-by: Shreeya Patel <spatel@ciq.com>
1 parent 1b32edf commit 47f1211

1 file changed

Lines changed: 35 additions & 15 deletions

File tree

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

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ on:
1313
required: false
1414
type: boolean
1515
default: false
16+
skip_kselftests:
17+
description: 'Skip the kselftests stage (e.g. for CBR where kselftest coverage is minimal)'
18+
required: false
19+
type: boolean
20+
default: false
1621
secrets:
1722
APP_ID:
1823
required: true
@@ -120,6 +125,7 @@ jobs:
120125
-v "$PWD/kernel-src-tree":/src \
121126
-v "$PWD/output":/output \
122127
-v "$PWD/kernel-container-build/build-container":/usr/local/build-scripts:ro \
128+
-v "$PWD/kernel-container-build/build-container/image_from_container.sh":/usr/local/bin/image_from_container.sh:ro \
123129
-v "$PWD/kernel-container-build/container/kernel_build.sh":/usr/libexec/kernel_build.sh:ro \
124130
-v "$PWD/kernel-container-build/container/check_kabi.sh":/usr/libexec/check_kabi.sh:ro \
125131
--security-opt label=disable \
@@ -217,6 +223,7 @@ jobs:
217223
name: Run kselftests (${{ matrix.arch }})
218224
runs-on: ${{ matrix.runner }}
219225
needs: [setup, boot]
226+
if: ${{ !inputs.skip_kselftests }}
220227
strategy:
221228
fail-fast: false
222229
matrix: ${{ fromJSON(needs.setup.outputs.matrix) }}
@@ -284,8 +291,8 @@ jobs:
284291
compare-results:
285292
name: Compare with previous run (${{ matrix.arch }})
286293
runs-on: ${{ matrix.runner }}
287-
needs: [setup, test-kselftest]
288-
if: success() || failure()
294+
needs: [setup, build, boot, test-kselftest]
295+
if: ${{ always() && needs.build.result == 'success' && needs.boot.result == 'success' }}
289296
strategy:
290297
fail-fast: false
291298
matrix: ${{ fromJSON(needs.setup.outputs.matrix) }}
@@ -301,6 +308,7 @@ jobs:
301308
fetch-depth: 1 # Shallow clone - only current commit needed for comparison logic
302309

303310
- name: Download current kselftest logs
311+
if: ${{ !inputs.skip_kselftests }}
304312
uses: actions/download-artifact@v4
305313
with:
306314
name: kselftest-logs-${{ matrix.arch }}
@@ -335,7 +343,7 @@ jobs:
335343
336344
# Define whitelist of valid base branches
337345
# TODO: Use a centralized place to get the base branches
338-
VALID_BASES="ciqlts9_2 ciqlts9_4 ciqlts8_6 ciqlts9_6 ciq-6.12.y ciq-6.18.y"
346+
VALID_BASES="ciqlts9_2 ciqlts9_4 ciqlts8_6 ciqlts9_6 ciq-6.12.y ciq-6.18.y ciqcbr7_9"
339347
340348
echo "Current branch: $BRANCH_NAME"
341349
@@ -399,7 +407,7 @@ jobs:
399407
echo "Base branch for comparison: $BASE_BRANCH"
400408
401409
- name: Download baseline kselftest logs from last merged PR targeting same base
402-
if: steps.base_branch.outputs.base_branch != ''
410+
if: ${{ !inputs.skip_kselftests && steps.base_branch.outputs.base_branch != '' }}
403411
env:
404412
GH_TOKEN: ${{ steps.generate_token_compare.outputs.token }}
405413
run: |
@@ -494,6 +502,7 @@ jobs:
494502

495503
- name: Compare test results
496504
id: comparison
505+
if: ${{ !inputs.skip_kselftests }}
497506
run: |
498507
# Check if we have a base branch to compare against
499508
if [ -z "${{ steps.base_branch.outputs.base_branch }}" ]; then
@@ -563,7 +572,10 @@ jobs:
563572
name: Create Pull Request
564573
runs-on: kernel-build
565574
needs: [setup, build, boot, test-kselftest, compare-results]
566-
if: success() || failure()
575+
if: |
576+
always() &&
577+
needs.build.result == 'success' &&
578+
needs.boot.result == 'success'
567579
568580
steps:
569581
- name: Check if branch name matches a supported pattern
@@ -579,10 +591,12 @@ jobs:
579591
580592
- name: Check if tests passed and no regressions
581593
run: |
582-
# Skip PR if any test stage failed
594+
# Skip PR if any required stage failed
595+
# test-kselftest is optional when skip_kselftests is true (result will be 'skipped')
596+
KSELFTEST_RESULT="${{ needs.test-kselftest.result }}"
583597
if [ "${{ needs.build.result }}" != "success" ] || \
584598
[ "${{ needs.boot.result }}" != "success" ] || \
585-
[ "${{ needs.test-kselftest.result }}" != "success" ]; then
599+
( [ "$KSELFTEST_RESULT" != "success" ] && [ "$KSELFTEST_RESULT" != "skipped" ] ); then
586600
echo "One or more test stages failed, skipping PR creation"
587601
exit 1
588602
fi
@@ -678,14 +692,14 @@ jobs:
678692
path: artifacts/boot/aarch64
679693

680694
- name: Download kselftest logs (x86_64)
681-
if: steps.detect_arch.outputs.has_x86_64 == 'true'
695+
if: steps.detect_arch.outputs.has_x86_64 == 'true' && !inputs.skip_kselftests
682696
uses: actions/download-artifact@v4
683697
with:
684698
name: kselftest-logs-x86_64
685699
path: artifacts/test/x86_64
686700

687701
- name: Download kselftest logs (aarch64)
688-
if: steps.detect_arch.outputs.has_aarch64 == 'true'
702+
if: steps.detect_arch.outputs.has_aarch64 == 'true' && !inputs.skip_kselftests
689703
uses: actions/download-artifact@v4
690704
with:
691705
name: kselftest-logs-aarch64
@@ -698,23 +712,23 @@ jobs:
698712
HAS_ARM="${{ steps.detect_arch.outputs.has_aarch64 }}"
699713
700714
# x86_64 stats
701-
if [ "$HAS_X86" = "true" ]; then
715+
if [ "$HAS_X86" = "true" ] && ls artifacts/test/x86_64/kselftests-*.log 1>/dev/null 2>&1; then
702716
PASSED_X86=$(grep -a '^ok' artifacts/test/x86_64/kselftests-*.log | wc -l || echo "0")
703717
FAILED_X86=$(grep -a '^not ok' artifacts/test/x86_64/kselftests-*.log | wc -l || echo "0")
704718
else
705-
PASSED_X86="0"
706-
FAILED_X86="0"
719+
PASSED_X86="N/A"
720+
FAILED_X86="N/A"
707721
fi
708722
echo "passed_x86_64=$PASSED_X86" >> $GITHUB_OUTPUT
709723
echo "failed_x86_64=$FAILED_X86" >> $GITHUB_OUTPUT
710724
711725
# aarch64 stats
712-
if [ "$HAS_ARM" = "true" ]; then
726+
if [ "$HAS_ARM" = "true" ] && ls artifacts/test/aarch64/kselftests-*.log 1>/dev/null 2>&1; then
713727
PASSED_ARM=$(grep -a '^ok' artifacts/test/aarch64/kselftests-*.log | wc -l || echo "0")
714728
FAILED_ARM=$(grep -a '^not ok' artifacts/test/aarch64/kselftests-*.log | wc -l || echo "0")
715729
else
716-
PASSED_ARM="0"
717-
FAILED_ARM="0"
730+
PASSED_ARM="N/A"
731+
FAILED_ARM="N/A"
718732
fi
719733
echo "passed_aarch64=$PASSED_ARM" >> $GITHUB_OUTPUT
720734
echo "failed_aarch64=$FAILED_ARM" >> $GITHUB_OUTPUT
@@ -812,6 +826,12 @@ jobs:
812826
COMPARISON_STATUS_X86="${{ needs.compare-results.outputs.comparison_status_x86_64 }}"
813827
COMPARISON_STATUS_ARM="${{ needs.compare-results.outputs.comparison_status_aarch64 }}"
814828
829+
# When kselftests are skipped, comparison step doesn't run so status is empty — treat as skipped
830+
if [ "${{ inputs.skip_kselftests }}" = "true" ]; then
831+
[ -z "$COMPARISON_STATUS_X86" ] && COMPARISON_STATUS_X86="skipped"
832+
[ -z "$COMPARISON_STATUS_ARM" ] && COMPARISON_STATUS_ARM="skipped"
833+
fi
834+
815835
# Create comparison section - use printf to avoid code block formatting
816836
COMPARISON_SECTION="### Test Comparison"
817837

0 commit comments

Comments
 (0)