Skip to content

Run generic kdevops CI tests #351

Run generic kdevops CI tests

Run generic kdevops CI tests #351

Workflow file for this run

# SPDX-License-Identifier: GPL-2.0
#
# Most simple Linux kernel subsystems can be tested with this target
# test setup. For more elaborates tests look for a topic branch under the
# kdevops-ci tree. For example to test a filesystem look at the fstests
# branch.
name: Run generic kdevops CI tests
on:
schedule:
- cron: '0 14 * * *'
# - cron: '*/20 * * * *'
push:
branches: ['**']
pull_request:
branches: ['**']
workflow_dispatch: # Allow manual triggering
inputs:
kernel_tree:
description: "Linux kernel tree to use"
required: true
default: 'linux'
type: choice
options:
- linux
- linux-next
- linux-stable
kernel_ref:
description: "Linux tree git reference (branch/tag/commit-id)"
required: true
default: "master"
type: string
jobs:
generate_ref:
name: Determine kernel_ref value
outputs:
kernel_ref: ${{ steps.set_kernel_ref.outputs.kernel_ref }}
kernel_tree: ${{ steps.set_kernel_ref.outputs.kernel_tree }}
runs-on: [self-hosted]
steps:
- name: Set kernel_ref based on trigger type
id: set_kernel_ref
run: |
current_date=$(date +'%Y%m%d')
# current_date=$(date -d "yesterday" +'%Y%m%d')
kernel_ref="next-${current_date}"
kernel_tree="linux-next"
if ! git ls-remote --tags "/mirror/${kernel_tree}.git" "$kernel_ref" | grep --quiet "$kernel_ref"; then
echo "Linux kernel ref ${kernel_ref} does not exist. Skipping."
kernel_ref="unset"
echo "kernel_ref=${kernel_ref}" >> "$GITHUB_OUTPUT"
fi
echo "kernel_ref=${kernel_ref}" >> "$GITHUB_OUTPUT"
echo "kernel_tree=${kernel_tree}" >> "$GITHUB_OUTPUT"
echo "DEBUG: kernel_ref=${kernel_ref}, kernel_tree=${kernel_tree}"
setup:
needs: generate_ref
if: ${{ startsWith(needs.generate_ref.outputs.kernel_ref, 'next-') }}
uses: ./.github/workflows/kdevops-init.yml
with:
kernel_ref: ${{ needs.generate_ref.outputs.kernel_ref || 'master' }}
kernel_tree: ${{ needs.generate_ref.outputs.kernel_tree || 'linux' }}
secrets: inherit
run-tests:
needs: setup
name: Run CI tests
runs-on: [self-hosted, Linux, X64]
steps:
- name: Run CI tests
run: |
cd kdevops
# Run the CI test suite in a clean, isolated background process group.
#
# - `nohup`: Ensures the test runner continues even if the controlling
# terminal (e.g. the CI shell) ends or gets a SIGHUP.
# - `stdbuf -oL`: Forces line-buffered stdout to ensure log output
# appears in real-time (especially important for
# CI logs).
# - `setsid`: Starts the process in a new session and process group
# so we can later kill the entire test group cleanly
# (including all children like ansible-playbook, ssh,
# etc.) using a single `kill -TERM -- -$PID`.
nohup stdbuf -oL bash -c 'setsid CI_WORKFLOW="${{ github.repository }}" make ci-test' > ci.log 2>&1 &
echo $! > ci.pid
CI_PID=$(cat ci.pid)
CI_WATCHDOG="./scripts/workflows/generic/crash_watchdog.py"
while kill -0 $CI_PID 2> /dev/null; do
$CI_WATCHDOG || touch .crashed
sleep 60
done
if [[ -f .crashed ]]; then
if kill -0 $CI_PID 2>/dev/null; then
echo "Killing ci-test due to possible crash."
echo "Try to end things gracefully sending TERM first..."
kill -TERM -- "$CI_PID" 2>/dev/null || true
# We want to wait for all processes to end, if we killed
# a stalled system or crashed system, the make ci-archive
# will run, and this can take some time. 5 minutes should do.
sleep $((5*60))
# Experience shows by this time, the process would be dead
echo "Now we wack all processes sending KILL ..."
kill -KILL -- "$CI_PID" 2>/dev/null || true
# we are tempted to try to collect logs but if the hosts
# are crashed that's futile. Just hope we collected the
# crash logs.
else
echo "ci-test process already exited"
fi
fi
# If you crashed you may not have any results collected other
# than your kernel crashes.
if [[ -d workflows/selftests/results/last-run ]]; then
# Check for kernel test logs and add them if they exist
KERNEL_LOGS=$(find workflows/selftests/results/last-run -name "*.dmesg.log" 2>/dev/null)
if [ -n "$KERNEL_LOGS" ]; then
echo -e "Kernel tests results:\n" > ci.commit_extra
for log in $KERNEL_LOGS; do
if [ -s "$log" ]; then
tail -n 1 "$log" >> ci.commit_extra
fi
done
echo -e "\n\n" >> ci.commit_extra
fi
# Check for userspace test logs and add them if they exist
USERSPACE_LOGS=$(find workflows/selftests/results/last-run -name "*.userspace.log" 2>/dev/null)
if [ -n "$USERSPACE_LOGS" ]; then
echo -e "Userspace test results:\n" >> ci.commit_extra
for log in $USERSPACE_LOGS; do
if [ -s "$log" ]; then
echo "Results from $log:" >> ci.commit_extra
tail -n 1 "$log" >> ci.commit_extra
fi
done
fi
fi
if [[ -f .crashed ]]; then
echo "Generating crash report ..."
./scripts/workflows/generic/crash_report.py >> ci.commit_extra
fi
if grep -i -q "fail" ci.commit_extra || [ -f .crashed ]; then
echo "fail" > ci.result
else
echo "ok" > ci.result
fi
cleanup:
needs: run-tests
uses: ./.github/workflows/kdevops-cleanup.yml
secrets: inherit