Skip to content

feat: add GitHub Actions CI workflow #14

feat: add GitHub Actions CI workflow

feat: add GitHub Actions CI workflow #14

Workflow file for this run

name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
# Frontend Linting Job
frontend-lint:
name: Frontend Lint
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./client
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: client/package-lock.json
- name: Install dependencies
run: npm ci
- name: Run ESLint
run: npx eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 1
- name: Check TypeScript
run: npm run checkTs
- name: Check Prettier formatting
run: npm run format -- --check
# Frontend Unit/Integration Tests
frontend-test:
name: Frontend Tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./client
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: client/package-lock.json
- name: Install dependencies
run: npm ci
- name: Run unit tests
run: npm test -- --run
- name: Run tests with coverage
run: npm run coverage
# Backend Linting and Format Check
backend-lint:
name: Backend Lint
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./server
steps:
- uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Check formatting
run: cargo fmt -- --check
- name: Run Clippy
run: cargo clippy -- -D warnings
# Backend Build
backend-build:
name: Backend Build
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./server
steps:
- uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Build release binary
run: cargo build --release --verbose
- name: Upload backend binary
uses: actions/upload-artifact@v4
with:
name: backend-binary
path: server/target/release/poker-planning
retention-days: 1
# Backend Test
backend-test:
name: Backend Test
runs-on: ubuntu-latest
needs: backend-build
defaults:
run:
working-directory: ./server
steps:
- uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Run tests
run: cargo test --verbose
# E2E Tests
e2e-tests:
name: E2E Tests
timeout-minutes: 60
runs-on: ubuntu-latest
needs: [frontend-lint, backend-lint, backend-build]
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: client/package-lock.json
- name: Download backend binary
uses: actions/download-artifact@v4
with:
name: backend-binary
path: server/target/release/
- name: Make backend binary executable
run: chmod +x server/target/release/poker-planning
- name: Install frontend dependencies
working-directory: ./client
run: npm ci
- name: Setup environment variables
working-directory: ./client
run: |
echo "VITE_GRAPHQL_ENDPOINT=http://localhost:8000/" > .env.local
echo "VITE_GRAPHQL_WS_ENDPOINT=ws://localhost:8000/" >> .env.local
- name: Install Playwright browsers
working-directory: ./client
run: npx playwright install --with-deps chromium
- name: Start backend server
working-directory: ./server
run: |
./target/release/poker-planning &
echo $! > ../backend.pid
# Wait for backend to be ready (up to 30 seconds)
for i in {1..30}; do
if curl -f http://localhost:8000/health_check 2>/dev/null; then
echo "Backend is ready!"
break
fi
echo "Waiting for backend to start... (attempt $i/30)"
sleep 1
done
# Final check to ensure backend is running
curl -f http://localhost:8000/health_check || exit 1
- name: Run E2E tests
working-directory: ./client
run: |
npm run dev &
echo $! > ../frontend.pid
npx wait-on http://localhost:5173 --timeout 30000
# Verify backend is responding
echo "Checking backend health..."
curl -f http://localhost:8000/health_check || exit 1
# Test GraphQL endpoint directly
echo "Testing GraphQL endpoint..."
curl -X POST http://localhost:8000/ \
-H "Content-Type: application/json" \
-d '{"query":"{ __typename }"}' \
-v || exit 1
# Give frontend a moment to fully initialize
sleep 5
# Show environment variables for debugging
echo "Environment variables:"
cat .env.local
npx playwright test --reporter=list,html
env:
CI: true
- name: Cleanup servers
if: always()
run: |
if [ -f backend.pid ]; then kill $(cat backend.pid) || true; fi
if [ -f frontend.pid ]; then kill $(cat frontend.pid) || true; fi
- name: Upload Playwright report
uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: client/playwright-report/
retention-days: 30
# All tests passed
ci-success:
name: CI Success
runs-on: ubuntu-latest
needs: [frontend-lint, frontend-test, backend-lint, backend-build, backend-test, e2e-tests]
if: success()
steps:
- name: CI passed
run: echo "All CI checks passed successfully!"