test: add test and ci #4
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| clippy: | |
| name: Clippy (Linting) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: clippy | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| llvm \ | |
| clang \ | |
| libelf-dev \ | |
| libbpf-dev \ | |
| linux-tools-common \ | |
| linux-tools-generic \ | |
| linux-headers-generic \ | |
| linux-libc-dev \ | |
| build-essential \ | |
| pkg-config | |
| - name: Run clippy | |
| run: cargo clippy --all-targets --all-features -- -D warnings | |
| format: | |
| name: Format Check | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: rustfmt | |
| - name: Check formatting | |
| run: cargo fmt --all -- --check | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| llvm \ | |
| clang \ | |
| libelf-dev \ | |
| libbpf-dev \ | |
| linux-tools-common \ | |
| linux-tools-generic \ | |
| linux-headers-generic \ | |
| linux-libc-dev \ | |
| build-essential \ | |
| pkg-config | |
| # Create symlink to make kernel headers accessible | |
| - name: Setup kernel headers | |
| run: | | |
| KERNEL_VERSION=$(ls /usr/src | grep -E '^linux-headers-[0-9]' | head -n1 | sed 's/linux-headers-//') | |
| echo "Found kernel headers version: $KERNEL_VERSION" | |
| sudo ln -sf /usr/src/linux-headers-${KERNEL_VERSION}/include/asm-generic /usr/include/asm-generic | |
| sudo ln -sf /usr/src/linux-headers-${KERNEL_VERSION}/arch/x86/include/asm /usr/include/asm | |
| - name: Build | |
| run: cargo build --verbose --release | |
| test: | |
| name: Test Suite | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| llvm \ | |
| clang \ | |
| libelf-dev \ | |
| libbpf-dev \ | |
| linux-tools-common \ | |
| linux-tools-generic \ | |
| linux-headers-generic \ | |
| linux-libc-dev \ | |
| build-essential \ | |
| pkg-config | |
| # Create symlink to make kernel headers accessible | |
| - name: Setup kernel headers | |
| run: | | |
| KERNEL_VERSION=$(ls /usr/src | grep -E '^linux-headers-[0-9]' | head -n1 | sed 's/linux-headers-//') | |
| echo "Found kernel headers version: $KERNEL_VERSION" | |
| sudo ln -sf /usr/src/linux-headers-${KERNEL_VERSION}/include/asm-generic /usr/include/asm-generic | |
| sudo ln -sf /usr/src/linux-headers-${KERNEL_VERSION}/arch/x86/include/asm /usr/include/asm | |
| - name: Cache cargo registry | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cargo/registry | |
| key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Cache cargo index | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cargo/git | |
| key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Cache cargo build | |
| uses: actions/cache@v4 | |
| with: | |
| path: target | |
| key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Run tests | |
| run: cargo test --verbose |