name: CI Tests

on:
  push:
  pull_request:
    branches: [ main ]

jobs:
  # separate linting from testing so that a failure in one doesn't prevent the other
  lint:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Lint
      uses: actions/setup-node@v2
      with:
        node-version: 18.x
    - run: yarn install
    - run: yarn run lint
  build-test:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Build & Test
      uses: actions/setup-node@v2
      with:
        node-version: 18.x
    - run: yarn install
    - run: yarn run build-full-test
    - id: setup-chrome
      uses: browser-actions/setup-chrome@v2
      with:
        install-dependencies: true
    # set up a virtual display for chrome (since the tests don't currently run it in headless mode)
    # then run the tests
    - name: Run Tests
      env:
        CHROME_PATH: ${{ steps.setup-chrome.outputs.chrome-path }}
      run: |
        export DISPLAY=:99
        sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 &
        yarn test
