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
122 changes: 57 additions & 65 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ on:
jobs:
test-backend:
runs-on: ubuntu-latest

services:
redis:
image: redis:7-alpine
Expand All @@ -20,52 +19,49 @@ jobs:
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- uses: actions/checkout@v4

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

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

- name: Download dependencies
working-directory: ./server
run: go mod download
- name: Format check

- name: Format, Vet, and Lint
working-directory: ./server
run: |
if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then
echo "Go code is not formatted. Please run 'go fmt ./...'"
gofmt -s -l .
exit 1
fi

- name: Vet
working-directory: ./server
run: go vet ./...

- name: Lint
uses: golangci/golangci-lint-action@v3
go vet ./...
- uses: golangci/golangci-lint-action@v3
with:
version: latest
working-directory: ./server
- name: Test with race detection

- name: Test with race detection and coverage
working-directory: ./server
run: go test -race -coverprofile=coverage.out ./...
env:
REDIS_URL: redis://localhost:6379

# Use the same env var name as the application for consistency
REDIS_ADDR: localhost:6379

- name: Check test coverage
working-directory: ./server
run: |
Expand All @@ -78,72 +74,68 @@ jobs:
exit 1
fi

- name: Build backend binary
working-directory: ./server
run: go build -o ../alignment-server ./cmd/server

- name: Upload backend artifact
uses: actions/upload-artifact@v4
with:
name: backend-binary
path: alignment-server

test-frontend:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
cache-dependency-path: './client/package-lock.json'

- name: Install dependencies
working-directory: ./client
run: npm ci

- name: Type check
working-directory: ./client
run: npx tsc --noEmit

- name: Lint
working-directory: ./client
run: npm run lint

- name: Test

- name: Type check, Lint, and Test
working-directory: ./client
run: npm test

- name: Build
run: |
npx tsc --noEmit
npm run lint
npm test

- name: Build frontend
working-directory: ./client
run: npm run build

build-integration:
- name: Upload frontend artifact
uses: actions/upload-artifact@v4
with:
name: frontend-dist
path: client/dist

# This job now verifies the artifacts from the previous jobs
verify-integration:
runs-on: ubuntu-latest
needs: [test-backend, test-frontend]

steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
- name: Download backend artifact
uses: actions/download-artifact@v4
with:
go-version: '1.21'
- name: Set up Node.js
uses: actions/setup-node@v4
name: backend-binary

- name: Download frontend artifact
uses: actions/download-artifact@v4
with:
node-version: '18'
cache: 'npm'
cache-dependency-path: './client/package-lock.json'

- name: Build frontend
working-directory: ./client
run: |
npm ci
npm run build

- name: Build backend
working-directory: ./server
run: |
go mod download
go build -o ../alignment-server ./cmd/server

- name: Test integration
name: frontend-dist
path: client/dist

- name: Verify artifacts
run: |
echo "Integration build successful"
echo "Verifying downloaded artifacts..."
ls -la alignment-server
ls -la client/dist/
ls -la client/dist/
echo "✅ Integration artifacts successfully verified."
Loading
Loading