Skip to content

Merge pull request #183 from akargi/feat/Radis #4

Merge pull request #183 from akargi/feat/Radis

Merge pull request #183 from akargi/feat/Radis #4

Workflow file for this run

name: CI
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
env:
NODE_VERSION: '20'
NODE_OPTIONS: '--max-old-space-size=4096'
jobs:
install:
name: Install Dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- run: npm ci --prefer-offline
- uses: actions/cache@v4
with:
path: node_modules
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
lint:
name: ESLint
runs-on: ubuntu-latest
needs: install
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: '${{ env.NODE_VERSION }}', cache: 'npm' }
- uses: actions/cache@v4
with:
path: node_modules
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
- run: npx eslint "{src,apps,libs,test}/**/*.ts" --max-warnings 0
format:
name: Prettier Format Check
runs-on: ubuntu-latest
needs: install
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: '${{ env.NODE_VERSION }}', cache: 'npm' }
- uses: actions/cache@v4
with:
path: node_modules
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
- run: npx prettier --check "src/**/*.ts" "test/**/*.ts"
typecheck:
name: TypeScript Type Check
runs-on: ubuntu-latest
needs: install
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: '${{ env.NODE_VERSION }}', cache: 'npm' }
- uses: actions/cache@v4
with:
path: node_modules
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
- run: npx tsc --project tsconfig.build.json --noEmit
build:
name: Build
runs-on: ubuntu-latest
needs: [lint, format, typecheck]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: '${{ env.NODE_VERSION }}', cache: 'npm' }
- uses: actions/cache@v4
with:
path: node_modules
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
- run: npm run build
- uses: actions/upload-artifact@v4
with: { name: dist, path: dist/, retention-days: 1 }
unit-tests:
name: Unit Tests & Coverage
runs-on: ubuntu-latest
needs: install
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: '${{ env.NODE_VERSION }}', cache: 'npm' }
- uses: actions/cache@v4
with:
path: node_modules
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
- run: npx jest --config jest.config.js --coverage --forceExit --runInBand
env:
NODE_ENV: test
JWT_SECRET: ci-test-secret
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/teachlink_test
- uses: actions/upload-artifact@v4
if: always()
with: { name: coverage-report, path: coverage/, retention-days: 7 }
e2e-tests:
name: E2E Tests
runs-on: ubuntu-latest
needs: build
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: teachlink_test
ports: ['5432:5432']
options: >-
--health-cmd pg_isready
--health-interval 10s --health-timeout 5s --health-retries 5
redis:
image: redis:7-alpine
ports: ['6379:6379']
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: '${{ env.NODE_VERSION }}', cache: 'npm' }
- uses: actions/cache@v4
with:
path: node_modules
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
- uses: actions/download-artifact@v4
with: { name: dist, path: dist/ }
- run: npx jest --config test/jest-e2e.json --forceExit --runInBand
env:
NODE_ENV: test
DB_HOST: localhost
DB_PORT: 5432
DB_USERNAME: postgres
DB_PASSWORD: postgres
DB_NAME: teachlink_test
REDIS_HOST: localhost
REDIS_PORT: 6379
JWT_SECRET: ci-e2e-test-secret
ci-success:
name: CI Passed
runs-on: ubuntu-latest
needs: [lint, format, typecheck, build, unit-tests, e2e-tests]
if: always()
steps:
- name: Check all jobs passed
run: |
results="${{ join(needs.*.result, ' ') }}"
for result in $results; do
if [ "$result" != "success" ]; then echo "❌ CI failed." && exit 1; fi
done
echo "✅ All CI jobs passed."