name: Test All Packages

on: push

jobs:
  test:
    name: Node.js and Browser (Chrome) Tests
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Set up Node (10)
      uses: actions/setup-node@v2
      with:
        node-version: 10.x
    - name: install Chrome stable
      run: |
        sudo apt-get update
        sudo apt-get install google-chrome-stable
    - name: Bump Node memory limit
      run: echo "NODE_OPTIONS=--max_old_space_size=4096" >> $GITHUB_ENV
    - name: Test setup and yarn install
      run: |
        cp config/ci.config.json config/project.json
        yarn
    - name: yarn build
      run: yarn build
    - name: Set start timestamp env var
      run: echo "FIREBASE_CI_TEST_START_TIME=$(date +%s)" >> $GITHUB_ENV
    - name: Run unit tests
      run: |
        xvfb-run yarn test:ci
        node scripts/print_test_logs.js
    - name: Generate coverage file
      run: yarn ci:coverage
    - name: Run coverage
      uses: coverallsapp/github-action@master
      with:
        github-token: ${{ secrets.GITHUB_TOKEN }}
        path-to-lcov: ./lcov-all.info
      continue-on-error: true
