sanger/sequencescape

View on GitHub
.github/workflows/lint.yml

Summary

Maintainability
Test Coverage
name: Linting
on:
  - push
  - pull_request

jobs:
  rubocop:
    runs-on: ubuntu-latest
    env:
      # Directory to cache Rubocop processing. Support added in 0.9.0 but
      # preparing this in advance of upgrade as it is side effect free.
      RUBOCOP_CACHE_ROOT: ".rubocop-cache"
      BUNDLE_WITHOUT: "cucumber deployment profile development default test"
    steps:
      - uses: actions/checkout@v2
      - name: Set up Ruby
        uses: ruby/setup-ruby@v1
        with:
          bundler-cache: true # runs 'bundle install' and caches installed gems automatically
      # Establish a cache of rubocop cache to improve performance
      # ${{ env.RUBOCOP_CACHE_ROOT }}
      - name: Setup node
        uses: actions/setup-node@v3
        with:
          node-version-file: ".nvmrc"
          cache: "yarn"
      - name: Set up yarn
        run: yarn
      - name: Cache cops
        uses: actions/cache@v2
        with:
          path: |
            ${{ env.RUBOCOP_CACHE_ROOT }}
          key: ${{ runner.os }}-rubocop-${{ hashFiles('**/.rubocop_todo.yml') }}
          # If we don't find the specific cache we want, fallback to the last rubocop
          # cache, then finally any cache for this repo.
          # Github looks for the newest cache beginning with the first entry, before
          # falling back the the second if none is present.
          restore-keys: |
            ${{ runner.os }}-rubocop-
            ${{ runner.os }}-
      # Run prettier prior to the cops
      - name: Run prettier
        run: yarn prettier --check .
      # Actually run our cops with flags to improve the details of lint errors
      # and parallel to try and improve speed
      - name: Run rubocop
        run: bundle exec rubocop --extra-details --display-style-guide --parallel --format github --format progress
  eslint:
    name: EsLint
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Setup node
        uses: actions/setup-node@v3
        with:
          node-version-file: ".nvmrc"
          cache: "yarn"
      - name: Install
        run: yarn install
      - name: Run yarn test
        run: yarn lint