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
82 changes: 82 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Tests

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

jobs:
test:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
go-version: ['1.25.x']

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

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

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

- name: Download dependencies
run: go mod download

- name: Run tests
run: go test ./... -v -timeout 10m

- name: Run tests with race detector
run: go test ./... -race -timeout 15m

- name: Generate coverage report
run: |
go test ./... -coverprofile=coverage.out -covermode=atomic
go tool cover -func=coverage.out

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

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

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

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.25.x'

- name: Verify environment
run: |
go version
pwd
ls -la .golangci.yml || echo ".golangci.yml not found"

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.64.8
install-mode: goinstall
args: --timeout=5m -v
59 changes: 59 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
run:
timeout: 5m

linters:
enable:
- govet
- gofmt
- goimports
- ineffassign
- gosimple
- errcheck
- staticcheck
- unused

issues:
exclude-rules:
# Temporarily suppress deprecated ioutil warnings until a follow-up PR
- linters:
- staticcheck
text: "SA1019:.*io/ioutil"
# Suppress gosimple nil checks in config (existing code)
- path: pkg/config/config\.go
linters:
- gosimple
text: "S1009"
# Suppress ineffassign and SA4006 in existing cache tests
- path: pkg/cache/cache_test\.go
linters:
- ineffassign
- staticcheck
# Suppress errcheck in existing production code (pre-existing issues)
- path: pkg/config/config\.go
linters:
- errcheck
text: "godotenv.Load"
- path: pkg/llm/.*_test\.go
linters:
- errcheck
text: "json.Unmarshal"
- path: pkg/monitoring/monitoring\.go
linters:
- errcheck
text: "Encode"
- path: pkg/streaming/websocket\.go
linters:
- errcheck
text: "WriteJSON"
- path: pkg/jobs/handlers\.go
linters:
- errcheck
text: "Encode"
- path: pkg/jobs/worker\.go
linters:
- errcheck
text: "UpdateJobError"
- path: pkg/api/handlers\.go
linters:
- errcheck
text: "w.Write"
39 changes: 39 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
.PHONY: test test-unit test-integration test-race test-coverage clean build lint help

help:
@echo "Available targets:"
@echo " test - Run all tests"
@echo " test-unit - Run unit tests only"
@echo " test-integration - Run integration tests"
@echo " test-race - Run tests with race detector"
@echo " test-coverage - Run tests with coverage report"
@echo " lint - Run linters"
@echo " build - Build the application"
@echo " clean - Clean build artifacts"

test:
go test ./... -v -timeout 10m

test-unit:
go test ./... -v -short -timeout 5m

test-integration:
go test ./... -v -run Integration -timeout 10m

test-race:
go test ./... -race -timeout 15m

test-coverage:
go test ./... -coverprofile=coverage.out -covermode=atomic
go tool cover -html=coverage.out -o coverage.html
@echo "Coverage report generated: coverage.html"

lint:
@which golangci-lint > /dev/null || (echo "golangci-lint not found, installing..." && go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest)
golangci-lint run ./...

build:
go build -o bin/llmproxy ./cmd/server

clean:
rm -rf bin/ coverage.out coverage.html
Loading