tunnckoCore/koa-better-body

View on GitHub
.github/workflows/nodejs.yml

Summary

Maintainability
Test Coverage
name: nodejs

on:
  pull_request:
    branches:
      - master
  push:
    branches:
      - master

# Add to every job
# - uses: actions/cache@v1
#   id: nodejs-cache
#   name: Cache node modules
#   with:
#     path: node_modules
#     key: ${{ matrix.os }}-nodejs-${{ matrix.node }}-${{ hashFiles('yarn.lock') }}
#     restore-keys: |
#       ${{ matrix.os }}-nodejs-${{ matrix.node }}-
#       ${{ matrix.os }}-nodejs-
#       ${{ matrix.os }}-

jobs:
  lint:
    if: "!contains(toJson(github.event.commits), '[skip ci]')"
    env:
      CI: true
    strategy:
      matrix:
        os: [ubuntu-latest]
        node: [12.x]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        if: steps.nodejs-cache.outputs.cache-hit != 'true'
      - uses: actions/cache@v1
        id: nodejs-cache
        name: Cache node modules
        with:
          path: node_modules
          key: ${{ matrix.os }}-nodejs-${{ matrix.node }}-${{ hashFiles('yarn.lock') }}
          restore-keys: |
            ${{ matrix.os }}-nodejs-${{ matrix.node }}-
            ${{ matrix.os }}-nodejs-
            ${{ matrix.os }}-
      - name: Installing dependencies
        if: steps.nodejs-cache.outputs.cache-hit != 'true'
        run: yarn run setup:ci
      - name: Linting & Format with Hela ESLint
        run: yarn run lint
      - name: Format full codebase with Prettier
        run: yarn run format
  test:
    if: "!contains(toJson(github.event.commits), '[skip ci]')"
    env:
      CI: true
      CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}}
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
        node: [10.x, 12.x]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v2
        if: steps.nodejs-cache.outputs.cache-hit != 'true'
      - uses: actions/cache@v1
        id: nodejs-cache
        name: Cache node modules
        with:
          path: node_modules
          key: ${{ matrix.os }}-nodejs-${{ matrix.node }}-${{ hashFiles('yarn.lock') }}
          restore-keys: |
            ${{ matrix.os }}-nodejs-${{ matrix.node }}-
            ${{ matrix.os }}-nodejs-
            ${{ matrix.os }}-
      - name: Installing dependencies
        if: steps.nodejs-cache.outputs.cache-hit != 'true'
        run: yarn run setup:ci
      - name: Testing
        run: yarn run test:ci
      - name: Sending coverage to CodeCov
        if: matrix.os == 'ubuntu-latest' && matrix.node == '12.x'
        run: echo ${{ matrix.node }} && bash <(curl -s https://codecov.io/bash)