b17e7d3d5f
- Add Caddy client package (client.go) with Load/GetConfig/Ping methods - Implement config generator (config.go) transforming ProxyHost → Caddy JSON - Add pre-flight validator (validator.go) catching config errors before reload - Create manager (manager.go) with rollback capability using config snapshots - Add CaddyConfig model for audit trail of configuration changes - Update Config to include Caddy admin API and config dir settings - Create comprehensive unit tests with 100% coverage for caddy package Docker Infrastructure: - Add docker-compose.yml with Caddy sidecar container - Add docker-compose.dev.yml for development overrides - Create .github/workflows/docker-publish.yml for GHCR publishing - Update CI to build Docker images and run integration tests - Add DOCKER.md with comprehensive deployment guide - Update Makefile with docker-compose commands - Update README with Docker-first deployment instructions Configuration: - Add CPM_CADDY_ADMIN_API and CPM_CADDY_CONFIG_DIR env vars - Update .env.example with new Caddy settings - Update AutoMigrate to include CaddyConfig model All acceptance criteria met: ✅ Can programmatically generate valid Caddy JSON configs ✅ Can reload Caddy configuration via admin API ✅ Invalid configs caught by validator before reload ✅ Automatic rollback on failure via snapshot system
148 lines
4.1 KiB
YAML
148 lines
4.1 KiB
YAML
name: CI - Lint, Test & Coverage
|
|
|
|
on:
|
|
push:
|
|
branches: [ main, development, 'feature/**' ]
|
|
pull_request:
|
|
branches: [ main, development ]
|
|
|
|
jobs:
|
|
backend-lint:
|
|
name: Backend - Go Lint
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: '1.22'
|
|
- name: golangci-lint
|
|
uses: golangci/golangci-lint-action@v6
|
|
with:
|
|
version: latest
|
|
working-directory: backend
|
|
|
|
backend-test:
|
|
name: Backend - Go Tests
|
|
runs-on: ubuntu-latest
|
|
needs: [backend-lint]
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: '1.22'
|
|
- name: Cache Go modules
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/go/pkg/mod
|
|
# Use the backend module's go.sum for cache key so the cache
|
|
# restores correctly when modules change.
|
|
key: ${{ runner.os }}-go-${{ hashFiles('backend/go.sum') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-go-
|
|
- name: Run tests
|
|
working-directory: backend
|
|
run: go test -v -race -coverprofile=coverage.out ./...
|
|
- name: Upload coverage to Codecov
|
|
uses: codecov/codecov-action@v4
|
|
with:
|
|
file: backend/coverage.out
|
|
flags: backend
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
frontend-lint:
|
|
name: Frontend - ESLint
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Set up Node
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
- name: Cache node modules
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: frontend/node_modules
|
|
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-node-
|
|
- name: Install dependencies
|
|
working-directory: frontend
|
|
run: npm ci
|
|
- name: Run ESLint
|
|
working-directory: frontend
|
|
run: npm run lint
|
|
|
|
frontend-build:
|
|
name: Frontend - Build
|
|
runs-on: ubuntu-latest
|
|
needs: [frontend-lint]
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Set up Node
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
- name: Cache node modules
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: frontend/node_modules
|
|
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-node-
|
|
- name: Install dependencies
|
|
working-directory: frontend
|
|
run: npm ci
|
|
- name: Build frontend
|
|
working-directory: frontend
|
|
run: npm run build
|
|
|
|
docker-build-test:
|
|
name: Docker - Build & Integration Test
|
|
runs-on: ubuntu-latest
|
|
needs: [backend-test, frontend-build]
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Build Docker image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
load: true
|
|
tags: caddyproxymanager-plus:test
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
- name: Start services with docker-compose
|
|
run: |
|
|
docker-compose up -d
|
|
sleep 10 # Wait for services to be ready
|
|
|
|
- name: Check app health
|
|
run: |
|
|
curl --retry 5 --retry-delay 3 --retry-connrefused http://localhost:8080/api/v1/health
|
|
|
|
- name: Check Caddy admin API
|
|
run: |
|
|
curl --retry 5 --retry-delay 3 --retry-connrefused http://localhost:2019/config/
|
|
|
|
- name: Run integration tests
|
|
run: |
|
|
# Future: run integration tests against running containers
|
|
echo "Integration tests placeholder - will be implemented with Issue #4"
|
|
|
|
- name: Show logs on failure
|
|
if: failure()
|
|
run: |
|
|
docker-compose logs app
|
|
docker-compose logs caddy
|
|
|
|
- name: Cleanup
|
|
if: always()
|
|
run: docker-compose down -v
|