name: Continuous Integration
on: pull_request_target

jobs:
  test-react-spa-components:
    name: test react-spa-components
    runs-on: ubuntu-latest
    steps:
      - name: Checkout source code
        uses: actions/checkout@v2
      - name: Setup Node.js
        uses: actions/setup-node@v1
        with:
          node-version: '12'
      - name: Install dependencies
        run: npm ci
      - name: Build the project
        run: npm run build:production
      - name: Run tests and do code coverage check
        run: npm run test:coverage
      - name: Run code linter
        uses: hallee/eslint-action@1.0.3
        if: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository }}
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}
      - name: Upload code coverage report to workflow as an artifact
        uses: actions/upload-artifact@v2
        with:
          name: spa-coverage.zip
          path: coverage
      - name: Upload code coverage report to codecov.io and comment in pull request
        uses: codecov/codecov-action@v1
