Skip to content

Add package-lock.json for CI caching #2

Add package-lock.json for CI caching

Add package-lock.json for CI caching #2

Workflow file for this run

name: Playwright E2E Tests
on:
push:
branches: [master, main]
pull_request:
branches: [master, main]
workflow_dispatch: # Allow manual trigger
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout playwright tests
uses: actions/checkout@v4
- name: Checkout confac
uses: actions/checkout@v4
with:
repository: itenium-be/confac
path: confac
# Use the same branch if it exists, otherwise master
ref: ${{ github.head_ref || github.ref_name || 'master' }}
continue-on-error: true
- name: Fallback to confac master
if: failure()
uses: actions/checkout@v4
with:
repository: itenium-be/confac
path: confac
ref: master
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- name: Install Playwright dependencies
run: |
npm ci
npx playwright install --with-deps chromium
- name: Install confac backend dependencies
working-directory: ./confac/backend
run: npm ci
- name: Install confac frontend dependencies
working-directory: ./confac/frontend
run: npm ci
- name: Start infrastructure (MongoDB + mocks)
run: |
docker compose -f docker-compose.test.yml up -d --build
# Wait for MongoDB to be ready
sleep 10
docker compose -f docker-compose.test.yml ps
- name: Setup backend environment
working-directory: ./confac/backend
run: |
cp ../../.env.test .env
cp -r templates-example templates || true
- name: Start backend
working-directory: ./confac/backend
run: npm start &
env:
NODE_ENV: test
- name: Start frontend
working-directory: ./confac/frontend
run: npm start &
env:
CI: true
BROWSER: none
- name: Wait for services
run: |
echo "Waiting for backend..."
timeout 60 bash -c 'until curl -s http://localhost:9000/health > /dev/null 2>&1 || curl -s http://localhost:9000 > /dev/null 2>&1; do sleep 2; done' || true
echo "Waiting for frontend..."
timeout 120 bash -c 'until curl -s http://localhost:3000 > /dev/null 2>&1; do sleep 2; done'
echo "Services ready!"
- name: Seed database
run: npm run seed
- name: Run Playwright tests
run: npx playwright test --project=chromium --reporter=html
env:
CI: true
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: playwright-report
path: playwright-report/
retention-days: 30
- name: Upload test artifacts
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-results
path: test-results/
retention-days: 30
- name: Show docker logs on failure
if: failure()
run: docker compose -f docker-compose.test.yml logs
- name: Cleanup
if: always()
run: docker compose -f docker-compose.test.yml down -v