name: CI

on:
  push:
    branches: [ main, develop ]
  pull_request:
    branches: [ main, develop ]

jobs:
  test-backend:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
      with:
        submodules: recursive
    - uses: actions/setup-go@v4
      with:
        go-version: '1.22'
    - name: Run tests
      run: |
        cd backend
        go test ./...
    - name: Build
      run: |
        cd backend
        go build ./...

  test-frontend:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
      with:
        submodules: recursive
    - uses: actions/setup-node@v3
      with:
        node-version: '20'
    - name: Install dependencies
      run: |
        cd frontend
        npm ci
    - name: Run tests
      run: |
        cd frontend
        npm test
    - name: Build
      run: |
        cd frontend
        npm run build

  lint:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
      with:
        submodules: recursive
    - uses: actions/setup-go@v4
      with:
        go-version: '1.22'
    - uses: actions/setup-node@v3
      with:
        node-version: '20'
    - name: Backend lint
      run: |
        cd backend
        go vet ./...
    - name: Frontend lint
      run: |
        cd frontend
        npm ci
        npm run lint
        npm run type-check

