Skip to content

run only 18

run only 18 #2

Workflow file for this run

name: CI Workflow
on:
push:
branches:
- week5
- main
pull_request:
branches:
- main
workflow_dispatch:
jobs:
backend-tests:
name: Backend Tests (Node.js ${{ matrix.node-version }})
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: week5/backend/package-lock.json
- name: Install backend dependencies
run: |
cd week5/backend
npm ci
- name: Run backend tests
run: |
cd week5/backend
npm test
- name: Start backend server and health check
run: |
cd week5/backend
npm start &
sleep 5
curl -f http://localhost:3000/health
curl -f http://localhost:3000/api/users
pkill -f "node server.js"
frontend-tests:
name: Frontend Tests (Node.js ${{ matrix.node-version }})
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 18]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: week5/frontend/package-lock.json
- name: Install frontend dependencies
run: |
cd week5/frontend
npm ci
- name: Run frontend tests
run: |
cd week5/frontend
npm test
integration-tests:
name: Integration Tests
runs-on: ubuntu-latest
needs: [backend-tests, frontend-tests]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
- name: Install all dependencies
run: |
cd week5/backend && npm ci
cd ../frontend && npm ci
- name: Start backend server
run: |
cd week5/backend
npm start &
sleep 5
- name: Verify API endpoints
run: |
# Test all API endpoints
curl -f http://localhost:3000/
curl -f http://localhost:3000/health
curl -f http://localhost:3000/api/users
# Test creating a user
curl -f -X POST http://localhost:3000/api/users \
-H "Content-Type: application/json" \
-d '{"name":"Test User","email":"test@example.com"}'
# Test getting the created user
curl -f http://localhost:3000/api/users/4