name: "PR Checks"
on: [pull_request, push]

jobs:
  check_pr:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1

    - name: "yarn install"
      run: yarn install

    - name: "yarn build"
      run: yarn build

    - name: "yarn test"
      run: yarn test

    - name: "check for uncommitted changes"
      # Ensure no changes, but ignore node_modules dir since dev/fresh ci deps installed.
      run: |
        git diff --exit-code --stat -- . ':!node_modules' \
        || (echo "##[error] found changed files after build. please 'yarn build && npm run format'" \
                 "and check in all changes" \
            && exit 1)
