Skip to content

Commit a0e211d

Browse files
ci: add GitHub Actions workflow for automated testing
Add comprehensive CI pipeline that runs on all PRs and pushes to main: Jobs: - test: Run full test suite (106 tests) - clippy: Lint code and fail on warnings - format: Verify code formatting with rustfmt - build: Ensure release build succeeds Dependencies installed: - LLVM/Clang for BPF compilation - libelf-dev and libbpf-dev for BPF support - Linux headers for kernel integration Caching strategy: - Cargo registry and git index - Build artifacts to speed up subsequent runs This ensures all PRs meet quality standards before merging. Signed-off-by: Sai Aung Hlyan Htet <saiaunghlyanhtet2003@gmail.com>
1 parent e8ec918 commit a0e211d

1 file changed

Lines changed: 136 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
clippy:
14+
name: Clippy (Linting)
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
with:
20+
submodules: recursive
21+
22+
- name: Install Rust toolchain
23+
uses: dtolnay/rust-toolchain@stable
24+
with:
25+
components: clippy
26+
27+
- name: Install dependencies
28+
run: |
29+
sudo apt-get update
30+
sudo apt-get install -y \
31+
llvm \
32+
clang \
33+
libelf-dev \
34+
libbpf-dev \
35+
linux-tools-common \
36+
linux-tools-generic \
37+
linux-headers-generic \
38+
linux-libc-dev \
39+
build-essential \
40+
pkg-config
41+
42+
- name: Run clippy
43+
run: cargo clippy --all-targets --all-features -- -D warnings
44+
45+
format:
46+
name: Format Check
47+
runs-on: ubuntu-latest
48+
steps:
49+
- name: Checkout repository
50+
uses: actions/checkout@v4
51+
52+
- name: Install Rust toolchain
53+
uses: dtolnay/rust-toolchain@stable
54+
with:
55+
components: rustfmt
56+
57+
- name: Check formatting
58+
run: cargo fmt --all -- --check
59+
60+
build:
61+
name: Build
62+
runs-on: ubuntu-latest
63+
steps:
64+
- name: Checkout repository
65+
uses: actions/checkout@v4
66+
with:
67+
submodules: recursive
68+
69+
- name: Install Rust toolchain
70+
uses: dtolnay/rust-toolchain@stable
71+
72+
- name: Install dependencies
73+
run: |
74+
sudo apt-get update
75+
sudo apt-get install -y \
76+
llvm \
77+
clang \
78+
libelf-dev \
79+
libbpf-dev \
80+
linux-tools-common \
81+
linux-tools-generic \
82+
linux-headers-generic \
83+
linux-libc-dev \
84+
build-essential \
85+
pkg-config
86+
87+
- name: Build
88+
run: cargo build --verbose --release
89+
90+
test:
91+
name: Test Suite
92+
runs-on: ubuntu-latest
93+
steps:
94+
- name: Checkout repository
95+
uses: actions/checkout@v4
96+
with:
97+
submodules: recursive
98+
99+
- name: Install Rust toolchain
100+
uses: dtolnay/rust-toolchain@stable
101+
102+
- name: Install dependencies
103+
run: |
104+
sudo apt-get update
105+
sudo apt-get install -y \
106+
llvm \
107+
clang \
108+
libelf-dev \
109+
libbpf-dev \
110+
linux-tools-common \
111+
linux-tools-generic \
112+
linux-headers-generic \
113+
linux-libc-dev \
114+
build-essential \
115+
pkg-config
116+
117+
- name: Cache cargo registry
118+
uses: actions/cache@v4
119+
with:
120+
path: ~/.cargo/registry
121+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
122+
123+
- name: Cache cargo index
124+
uses: actions/cache@v4
125+
with:
126+
path: ~/.cargo/git
127+
key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }}
128+
129+
- name: Cache cargo build
130+
uses: actions/cache@v4
131+
with:
132+
path: target
133+
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
134+
135+
- name: Run tests
136+
run: cargo test --verbose

0 commit comments

Comments
 (0)