Skip to content

Commit 203e610

Browse files
committed
add ci workflow
Signed-off-by: Ray Lee <hburaylee@gmail.com>
1 parent eb6b944 commit 203e610

File tree

2 files changed

+82
-2
lines changed

2 files changed

+82
-2
lines changed

.github/workflows/ci.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master, main, dev ]
6+
pull_request:
7+
branches: [ master, main ]
8+
9+
jobs:
10+
build-and-test:
11+
runs-on: ubuntu-24.04
12+
timeout-minutes: 5
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
with:
18+
submodules: recursive
19+
20+
- name: Install dependencies
21+
run: |
22+
sudo apt-get update
23+
sudo apt-get install -y build-essential python3 qemu-system-x86
24+
25+
- name: Check QEMU availability
26+
run: |
27+
which qemu-system-x86_64 || echo "QEMU not found in PATH"
28+
ls -la /usr/bin/qemu* || echo "No QEMU binaries found"
29+
30+
- name: Build project
31+
run: |
32+
set -x
33+
make clean || true
34+
make Q= # Build without suppressing output
35+
36+
- name: Verify build
37+
run: |
38+
ls -la kvm-dmesg
39+
file kvm-dmesg
40+
41+
- name: Run full tests
42+
env:
43+
CI: "true"
44+
run: |
45+
set -x # Enable verbose output
46+
cd tests
47+
48+
echo "Starting full test execution..."
49+
50+
# Try to clone test repository
51+
if [ ! -d "kvm-dmesg-ci" ]; then
52+
echo "Cloning test repository..."
53+
git clone https://github.com/rayylee/kvm-dmesg-ci.git -b master || {
54+
echo "WARNING: Could not clone test repository, skipping full tests"
55+
exit 0
56+
}
57+
fi
58+
59+
# Check if test kernels are available
60+
if [ ! -d "kvm-dmesg-ci/kernels" ]; then
61+
echo "WARNING: No test kernels found, skipping full tests"
62+
exit 0
63+
fi
64+
65+
# Skip - Tcg `Triple fault` bug for el10
66+
rm -rf kvm-dmesg-ci/kernels/el10 || true
67+
68+
# Run the test script and capture exit code
69+
timeout 180s bash -x base.sh
70+
TEST_EXIT_CODE=$?
71+
72+
echo "Full test script exited with code: $TEST_EXIT_CODE"
73+
if [ $TEST_EXIT_CODE -ne 0 ]; then
74+
echo "FULL TESTS FAILED!"
75+
exit $TEST_EXIT_CODE
76+
else
77+
echo "FULL TESTS PASSED!"
78+
fi

tests/base.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def qemu_run(vmlinux_path):
126126
'-monitor', 'unix:/tmp/mon.sock,server,nowait'
127127
]
128128

129-
if os.path.exists('/dev/kvm'):
129+
if os.path.exists('/dev/kvm') and os.environ.get('CI') != 'true':
130130
command.extend(['-accel', 'kvm', '-cpu', 'host'])
131131

132132
try:
@@ -145,7 +145,7 @@ def qemu_run(vmlinux_path):
145145
print("\nKernel booted successfully!")
146146
return True
147147

148-
print("\nKernel did not boot successfully.")
148+
print("\n" + Colors.RED + "Kernel did not boot successfully." + Colors.ENDC)
149149
process.terminate()
150150
return False
151151

@@ -188,6 +188,7 @@ def test_all(kernels_dic):
188188
formatted_time = time.strftime('%Y-%m-%d %H:%M:%S', current_time)
189189
if nr_passed == nr_tests:
190190
print("\n" + Colors.GREEN + formatted_time + f" Tests {nr_passed}/{nr_tests} passed!" + Colors.ENDC)
191+
sys.exit(0)
191192
elif nr_passed < nr_tests:
192193
nr_failed = nr_tests - nr_passed
193194
print("\n" + Colors.RED + formatted_time + f" Tests {nr_failed}/{nr_tests} failed." + Colors.ENDC)
@@ -196,3 +197,4 @@ def test_all(kernels_dic):
196197
if __name__ == "__main__":
197198
kernels = traverse_kernels("%s/kvm-dmesg-ci/kernels" % os.getcwd())
198199
test_all(kernels)
200+
sys.exit(1)

0 commit comments

Comments
 (0)