This repository has been archived on 2026-04-03. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
core/.gitea/workflows/backend.yml
xcaliber 7157877f0b feat: Setup CI/CD infrastructure with Go, Frontend, and Docker workflows (#22)
## Summary

This PR sets up the complete CI/CD infrastructure for the Chat Switchboard project, implementing automated testing, linting, building, and Docker containerization.

## Changes

### CI/CD Workflows

1. **`.gitea/workflows/backend.yml`** - Backend CI pipeline
   - Automated Go module initialization
   - Test execution with coverage reporting
   - Code linting with golangci-lint
   - Binary compilation with version tags
   - Artifact upload for debugging

2. **`.gitea/workflows/frontend.yml`** - Frontend CI pipeline
   - JavaScript linting with ESLint
   - CSS validation with Prettier
   - Standalone HTML build via build.sh
   - HTML structure validation
   - Build artifact management

3. **`.gitea/workflows/docker.yml`** - Docker CI pipeline
   - Backend container building and testing
   - Frontend container building
   - Automatic image tagging on tags/branches
   - Registry push on main branch
   - Multi-arch manifest creation

### Docker Configuration

- `server/Dockerfile` - Multi-stage Go backend container with health checks
- `Dockerfile.frontend` - Nginx frontend container with gzip compression
- `nginx.conf` - Optimized nginx config with security headers

### Dependencies

- `server/go.mod` - Initialized Go module with Gin and godotenv

### Documentation

- `docs/CICD_SETUP.md` - Comprehensive CI/CD documentation

## Features

-  Auto-trigger on push/PR to main/develop
-  Test coverage reporting
-  Code quality checks (golangci-lint, ESLint)
-  Build artifact management (7-day retention)
-  Semantic versioning support (v* tags)
-  Multi-stage Docker builds
-  Container health checks
-  Security headers in nginx
-  Gzip compression
-  Non-root container execution

## Testing

The workflows will automatically run on this PR. Once merged, all future PRs and pushes to main/develop will trigger the appropriate CI checks.

## Acceptance Criteria

-  All PRs run CI checks
-  Docker images auto-build on tags
-  Standalone build generates on each commit

## Next Steps (Manual)

1. Merge this PR to `main`
2. Create `develop` branch: `git checkout main && git checkout -b develop && git push origin develop`
3. Configure branch protection in Gitea (Settings → Branches → Add protection rule for main/develop)
4. Test with a sample PR to verify CI runs

## Breaking Changes

None. This is purely infrastructure setup with no impact on existing functionality.

Reviewed-on: xcaliber/chat-switchboard#22
2026-02-04 18:17:07 +00:00

107 lines
2.5 KiB
YAML

name: Backend CI
on:
push:
branches: [main]
paths:
- 'server/**'
- '.gitea/workflows/backend.yml'
pull_request:
branches: [main]
paths:
- 'server/**'
- '.gitea/workflows/backend.yml'
env:
GO_VERSION: '1.21'
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: https://github.com/actions/checkout@v4
- name: Setup Go
uses: https://github.com/actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: false
- name: Tidy modules
working-directory: ./server
run: go mod tidy
- name: Install golangci-lint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.59.0
- name: Download dependencies
working-directory: ./server
run: go mod download
- name: Run linter
working-directory: ./server
run: |
$(go env GOPATH)/bin/golangci-lint run ./... --timeout=5m
build:
name: Build
needs: lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: https://github.com/actions/checkout@v4
- name: Setup Go
uses: https://github.com/actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: false
- name: Tidy modules
working-directory: ./server
run: go mod tidy
- name: Download dependencies
working-directory: ./server
run: go mod download
- name: Build binary
working-directory: ./server
run: |
CGO_ENABLED=0 go build -o chat-switchboard-api -ldflags "-s -w"
test:
name: Test
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: https://github.com/actions/checkout@v4
- name: Setup Go
uses: https://github.com/actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: false
- name: Tidy modules
working-directory: ./server
run: go mod tidy
- name: Download dependencies
working-directory: ./server
run: go mod download
- name: Run tests
working-directory: ./server
run: |
go test -v -cover -coverprofile=coverage.out ./...
EXIT_CODE=$?
echo "EXIT_CODE=$EXIT_CODE" >> $GITHUB_ENV
- name: Fail if tests failed
if: env.EXIT_CODE != '0'
run: exit 1