name: Portal CI

on:
  push:
    branches: [main, develop]
    paths:
      - 'portal/**'
      - '.github/workflows/portal-ci.yml'
  pull_request:
    branches: [main, develop]
    paths:
      - 'portal/**'

jobs:
  lint:
    name: Portal Lint
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: ./portal
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '20'
          cache: 'npm'
          cache-dependency-path: portal/package-lock.json
      - run: npm ci
      - run: npm run lint

  type-check:
    name: Portal Type Check
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: ./portal
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '20'
          cache: 'npm'
          cache-dependency-path: portal/package-lock.json
      - run: npm ci
      - run: npm run type-check

  test:
    name: Portal Test
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: ./portal
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '20'
          cache: 'npm'
          cache-dependency-path: portal/package-lock.json
      - run: npm ci
      - run: npm test -- --coverage
      - uses: codecov/codecov-action@v3
        with:
          files: ./portal/coverage/coverage-final.json
          flags: portal
          name: codecov-portal

  build:
    name: Portal Build
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: ./portal
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '20'
          cache: 'npm'
          cache-dependency-path: portal/package-lock.json
      - run: npm ci
      - run: npm run build

