Skip to content

Merge pull request #216 from coder13/dependabot/npm_and_yarn/eslint-c… #196

Merge pull request #216 from coder13/dependabot/npm_and_yarn/eslint-c…

Merge pull request #216 from coder13/dependabot/npm_and_yarn/eslint-c… #196

Workflow file for this run

name: CI
on:
pull_request:
push:
branches:
- dev
- master
jobs:
configuration:
name: Production configuration checks
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Validate production metrics configuration
run: scripts/test-compose-metrics-config.sh
- name: Validate CI branch coverage
run: scripts/test-ci-branches.sh
- name: Validate CodeQL branch coverage
run: scripts/test-codeql-branches.sh
- name: Rehearse MongoDB backup and restore scripts
run: scripts/test-mongo-backup-restore.sh
- name: Rehearse a live MongoDB backup and restore
run: scripts/test-mongo-backup-restore-live.sh
server:
name: Server lint and unit tests
runs-on: ubuntu-latest
env:
PGHOST: 127.0.0.1
PGPORT: 5432
PGDATABASE: letscube
PGUSER: letscube
PGPASSWORD: letscube
services:
postgres:
image: postgres:17-alpine
env:
POSTGRES_DB: letscube
POSTGRES_USER: letscube
POSTGRES_PASSWORD: letscube
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U letscube -d letscube"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 22.17.0
cache: yarn
cache-dependency-path: yarn.lock
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Validate Prisma schema
run: yarn workspace letscube-server postgres:schema:validate
- name: Apply PostgreSQL migrations
run: yarn workspace letscube-server postgres:migrate
- name: Check PostgreSQL schema drift
run: yarn workspace letscube-server postgres:schema:check
- name: Run server lint
run: yarn turbo run lint --filter=letscube-server
- name: Run server unit tests
run: yarn turbo run test:ci --filter=letscube-server
client:
name: Client lint and unit tests
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 22.17.0
cache: yarn
cache-dependency-path: yarn.lock
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Run client lint
run: yarn turbo run lint --filter=letscube-client
- name: Run client unit tests
run: yarn turbo run test:ci --filter=letscube-client
cypress:
name: Cypress full-stack smoke
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Node for client
uses: actions/setup-node@v4
with:
node-version: 22.17.0
cache: yarn
cache-dependency-path: yarn.lock
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Start client
run: BROWSER=none yarn workspace letscube-client start > client.log 2>&1 &
- name: Set up Node for server and Cypress
uses: actions/setup-node@v4
with:
node-version: 22.17.0
- name: Start backing services
run: docker compose -f compose.yml -f compose.dev.yml up -d mongo redis
- name: Start server
run: CORS_ORIGINS=http://localhost:3000,http://localhost:8080 LETSCUBE_TEST_AUTH=true SOCIAL_FEATURES_ENABLED=true POSTGRES_ENABLED=false yarn workspace letscube-server node index.js > server.log 2>&1 &
- name: Start socket server
run: SOCIAL_FEATURES_ENABLED=true POSTGRES_ENABLED=false yarn workspace letscube-server node socket/ > socket.log 2>&1 &
- name: Wait for local stack
run: |
for url in \
http://localhost:3000/ \
http://localhost:8080/api/announcements \
"http://localhost:9000/socket.io/?EIO=4&transport=polling"
do
for i in {1..60}; do
if curl --fail --silent --output /dev/null "$url"; then
break
fi
if [ "$i" -eq 60 ]; then
echo "Timed out waiting for $url"
echo "--- client.log"
cat client.log || true
echo "--- server.log"
cat server.log || true
echo "--- socket.log"
cat socket.log || true
docker compose -f compose.yml -f compose.dev.yml ps
exit 1
fi
sleep 2
done
done
- name: Run Cypress
run: yarn cypress:run
- name: Print app logs on failure
if: failure()
run: |
echo "--- client.log"
cat client.log || true
echo "--- server.log"
cat server.log || true
echo "--- socket.log"
cat socket.log || true
docker compose -f compose.yml -f compose.dev.yml ps || true