Skip to content

Commit 315f7f9

Browse files
withzombiesclaude
andauthored
feat: add CI with osquery integration tests and coverage
# Summary Complete CI infrastructure refactor with osquery integration testing and coverage measurement. ## Changes ### CI Workflow (`.github/workflows/ci.yml`) - Renamed workflow from "Rust CI" to "CI" - Split into build (fmt, clippy, build) and test jobs - Added osquery installation for integration tests - Integrated `cargo-llvm-cov` for coverage measurement - Added dynamic coverage badge via Gist ### Test Script (`scripts/ci-test.sh`) - New orchestration script for local and CI testing - Detects osqueryd (PATH and common install locations) - Falls back to Docker when osqueryd not available - Builds and autoloads logger-file and config-static extensions - Waits for socket AND extension registration before tests - Generates lcov coverage reports with `--coverage` flag - Cross-platform cleanup using `pkill -f` pattern matching ### Docker Support - Added `docker/Dockerfile.test` for containerized testing - Pre-builds extensions in image for faster test runs - Mirrors native test environment for consistency ### README Badge Fixes - Fixed CI badge URL (workflows/CI not workflows/Rust%20CI) - Fixed coverage link (ci.yml not coverage.yml) ## Testing - 161 tests passing - ~87% code coverage - CI completes in ~1.5 minutes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent e128398 commit 315f7f9

File tree

34 files changed

+5724
-88
lines changed

34 files changed

+5724
-88
lines changed

.dockerignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Ignore local build artifacts
2+
target/
3+
4+
# Ignore git directory
5+
.git/
6+
7+
# Ignore IDE files
8+
.idea/
9+
.vscode/
10+
11+
# Ignore test artifacts
12+
*.log
13+
coverage/
14+
15+
# Ignore Docker build context waste
16+
.dockerignore

.github/workflows/ci.yml

Lines changed: 61 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,77 @@
1-
name: Rust CI
1+
name: CI
22

33
on:
44
push:
5-
branches:
6-
- main
5+
branches: [main]
76
pull_request:
8-
types:
9-
- opened
10-
- synchronize
11-
- reopened
7+
branches: [main]
128

13-
jobs:
14-
build-and-test:
15-
name: Build and Test on ${{ matrix.os }}
16-
runs-on: ${{ matrix.os }}
17-
strategy:
18-
matrix:
19-
os: [ubuntu-latest, macos-latest]
9+
env:
10+
CARGO_TERM_COLOR: always
11+
CARGO_INCREMENTAL: 0
2012

13+
jobs:
14+
build:
15+
name: Build
16+
runs-on: ubuntu-latest
2117
steps:
22-
- name: Checkout Code
23-
uses: actions/checkout@v4
18+
- uses: actions/checkout@v4
2419
with:
2520
submodules: recursive
2621
fetch-depth: 1
2722

28-
- name: Set up Rust Toolchain
29-
uses: actions-rust-lang/setup-rust-toolchain@v1
23+
- uses: actions-rust-lang/setup-rust-toolchain@v1
3024
with:
3125
toolchain: stable
32-
override: true
3326
components: rustfmt, clippy
3427

35-
- name: Build Project
36-
run: cargo build --release --verbose
28+
- name: Check formatting
29+
run: cargo fmt --all -- --check
30+
31+
- name: Run clippy
32+
run: cargo clippy --all-features -- -D warnings
33+
34+
- name: Build
35+
run: cargo build --all-features
36+
37+
test:
38+
name: Test & Coverage
39+
runs-on: ubuntu-latest
40+
needs: build
41+
steps:
42+
- uses: actions/checkout@v4
43+
with:
44+
submodules: recursive
45+
46+
- uses: actions-rust-lang/setup-rust-toolchain@v1
47+
with:
48+
toolchain: stable
49+
components: llvm-tools-preview
50+
51+
- uses: taiki-e/install-action@cargo-llvm-cov
3752

38-
- name: Run Tests
39-
run: cargo test --all-features --verbose
53+
- name: Install osquery
54+
run: |
55+
wget -q https://github.com/osquery/osquery/releases/download/5.20.0/osquery_5.20.0-1.linux_amd64.deb
56+
sudo dpkg -i osquery_5.20.0-1.linux_amd64.deb
57+
osqueryi --version
58+
59+
- name: Build workspace
60+
run: cargo build --workspace
61+
62+
- name: Run coverage with osquery
63+
id: coverage
64+
run: ./scripts/ci-test.sh --coverage
65+
66+
- name: Update coverage badge
67+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
68+
uses: schneegans/[email protected]
69+
with:
70+
auth: ${{ secrets.GIST_TOKEN }}
71+
gistID: 36626ec8e61a6ccda380befc41f2cae1
72+
filename: coverage.json
73+
label: coverage
74+
message: ${{ steps.coverage.outputs.coverage }}%
75+
valColorRange: ${{ steps.coverage.outputs.coverage }}
76+
maxColorRange: 100
77+
minColorRange: 0

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ osquery-rust.iml
33

44
/examples/*/target
55

6-
/Cargo.lock
76
/target
87

98
/thrift/Cargo.lock

0 commit comments

Comments
 (0)