Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 121 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
name: CI Pipeline

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
test:
name: Run Tests
runs-on: ubuntu-latest

strategy:
matrix:
go-version: ['1.21', '1.22', '1.23']

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y clang libbpf-dev linux-headers-$(uname -r)

- name: Cache Go modules
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ matrix.go-version }}-

- name: Download Go modules
run: go mod download

- name: Verify Go modules
run: go mod verify

- name: Run go vet
run: go vet ./...

- name: Run tests
run: go test -v -race -coverprofile=coverage.out ./...

- name: Run tests with race detection
run: go test -race -v ./...

- name: Check test coverage
run: go tool cover -func=coverage.out

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage.out
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false

lint:
name: Lint Code
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23'

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y clang libbpf-dev linux-headers-$(uname -r)

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
args: --timeout=5m

build:
name: Build Binary
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23'

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y clang libbpf-dev linux-headers-$(uname -r)

- name: Build eBPF programs
run: make generate

- name: Build binary
run: make build

- name: Build development binary
run: make build-dev

- name: Test binary can start
run: timeout 5s sudo ./bin/ebpf-server -addr :0 || [[ $? == 124 ]]

14 changes: 10 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,16 @@ fmt:
clean:
@echo "Cleaning build artifacts..."
rm -rf bin/
rm -f $(BPF_OBJECTS)
rm -f bpf/*.skel.go
rm -f bpf/include/vmlinux.h.generated
go clean
rm -rf bpf/*.o

# Generate API documentation using Swagger
.PHONY: docs
docs:
@command -v $(shell go env GOPATH)/bin/swag >/dev/null 2>&1 || { echo "Installing swag..."; go install github.com/swaggo/swag/cmd/swag@latest; }
$(shell go env GOPATH)/bin/swag init -g internal/api/handlers.go -o docs/swagger --parseDependency --parseInternal
@echo "API documentation generated at docs/swagger/"
@echo "Interactive docs: http://localhost:8080/docs/ (when server is running)"
@echo "External docs: https://petstore.swagger.io/?url=https://raw.githubusercontent.com/srodi/ebpf-server/main/docs/swagger.json"

# Install the binary system-wide
.PHONY: install
Expand Down
Loading
Loading