|
| 1 | +name: CI (Latest Kernel) |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ "master" ] |
| 6 | + paths-ignore: |
| 7 | + - "docs/**" |
| 8 | + - "**.md" |
| 9 | + pull_request: |
| 10 | + branches: [ "master" ] |
| 11 | + paths-ignore: |
| 12 | + - "docs/**" |
| 13 | + - "**.md" |
| 14 | + |
| 15 | +env: |
| 16 | + KERNEL_ARCHIVE_URL: "https://cdn.kernel.org/pub/linux/kernel/v7.x/linux-7.2.tar.xz" |
| 17 | + |
| 18 | +jobs: |
| 19 | + build-and-test: |
| 20 | + runs-on: ubuntu-26.04 |
| 21 | + timeout-minutes: 30 |
| 22 | + |
| 23 | + strategy: |
| 24 | + fail-fast: false |
| 25 | + matrix: |
| 26 | + mode: [ privileged, unprivileged ] |
| 27 | + |
| 28 | + steps: |
| 29 | + - name: Checkout Repository |
| 30 | + uses: actions/checkout@v4 |
| 31 | + with: |
| 32 | + submodules: recursive # condy's vm-run.sh / light-initrd.sh are used |
| 33 | + |
| 34 | + - name: Update Apt Packages |
| 35 | + run: sudo apt-get update |
| 36 | + |
| 37 | + - name: Setup QEMU |
| 38 | + run: | |
| 39 | + sudo apt-get install -y qemu-system-x86 |
| 40 | + qemu-system-x86_64 --version # Verify installation |
| 41 | +
|
| 42 | + - name: Hash Kernel Archive URL |
| 43 | + id: kernel-url-hash |
| 44 | + run: | |
| 45 | + echo "value=$(printf '%s' \"$KERNEL_ARCHIVE_URL\" | sha256sum | cut -d ' ' -f1)" >> "$GITHUB_OUTPUT" |
| 46 | +
|
| 47 | + - name: Cache Kernel bzImage |
| 48 | + id: cache-kernel |
| 49 | + uses: actions/cache@v4 |
| 50 | + with: |
| 51 | + path: .cache/bzImage |
| 52 | + key: bzImage-${{ steps.kernel-url-hash.outputs.value }}-${{ hashFiles('scripts/light-kernel.sh') }}-${{ runner.os }} |
| 53 | + |
| 54 | + - name: Build Linux Kernel |
| 55 | + timeout-minutes: 20 |
| 56 | + if: steps.cache-kernel.outputs.cache-hit != 'true' |
| 57 | + run: | |
| 58 | + sudo apt-get install -y \ |
| 59 | + build-essential \ |
| 60 | + libncurses-dev \ |
| 61 | + bison \ |
| 62 | + flex \ |
| 63 | + libssl-dev \ |
| 64 | + libelf-dev \ |
| 65 | + bc \ |
| 66 | + kmod \ |
| 67 | + cpio \ |
| 68 | + rsync \ |
| 69 | + wget |
| 70 | +
|
| 71 | + mkdir -p .cache |
| 72 | + bash ./scripts/light-kernel.sh -o .cache/bzImage "$KERNEL_ARCHIVE_URL" |
| 73 | +
|
| 74 | + - name: Configure CMake |
| 75 | + run: | |
| 76 | + cmake -B ${{github.workspace}}/build \ |
| 77 | + -DUBLKCPP_BUILD_TESTS=ON \ |
| 78 | + -DUBLKCPP_BUILD_UBLKCTL=ON \ |
| 79 | + -DUBLKCPP_TESTS_STATIC_LINK=ON \ |
| 80 | + -DCMAKE_C_COMPILER=clang \ |
| 81 | + -DCMAKE_CXX_COMPILER=clang++ \ |
| 82 | + -DCMAKE_BUILD_TYPE=Release |
| 83 | +
|
| 84 | + - name: Build |
| 85 | + run: cmake --build ${{github.workspace}}/build -j$(nproc) |
| 86 | + |
| 87 | + - name: Run Tests on QEMU |
| 88 | + timeout-minutes: 15 |
| 89 | + run: | |
| 90 | + bash ./scripts/vm-run.sh \ |
| 91 | + -m ${{ matrix.mode }} \ |
| 92 | + -c './tests' \ |
| 93 | + ./.cache/bzImage ./build/tests/tests \ |
| 94 | + 2>&1 | tee vm-run.log |
| 95 | +
|
| 96 | + if grep -q "SUCCESS!" vm-run.log; then |
| 97 | + echo "::notice:: All tests passed" |
| 98 | + else |
| 99 | + echo "::error:: Tests failed" |
| 100 | + exit 1 |
| 101 | + fi |
0 commit comments