victorperin/qr-scanner-cli

View on GitHub
.github/workflows/pr-check.yml

Summary

Maintainability
Test Coverage
name: pr-check

on:
  pull_request:
    branches:
      - 'main'
  push:
    branches:
      - 'main'

jobs:
  Check:
    runs-on: ${{ matrix.os }}

    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
        node-version: [21.x, 20.x, 18.x, 16.x]

    steps:
      - name: Begin Check...
        uses: actions/checkout@v2

      - name: Use NodeJS ${{ matrix.node-version }}
        uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node-version }}

      - uses: pnpm/action-setup@v2
        name: Install pnpm
        with:
          version: 8
          run_install: false

      - name: Get pnpm store directory
        shell: bash
        run: |
          echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

      - uses: actions/cache@v3
        name: Setup pnpm cache
        with:
          path: ${{ env.STORE_PATH }}
          key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
          restore-keys: |
            ${{ runner.os }}-pnpm-store-

      - name: Install dependencies
        run: pnpm install

      - name: 🐛 Linter 🕵️
        if: matrix.os == 'ubuntu-latest' && matrix.node-version == '15.x'
        run: npm run linter

      - name: 🐛 Test on Ubuntu
        if: matrix.os == 'ubuntu-latest'
        run: xvfb-run npm run test:coverage

      - name: 🐛 Test on other os
        if: matrix.os != 'ubuntu-latest'
        run: npm test

      - name: publish code coverage on CodeClimate
        if: matrix.os == 'ubuntu-latest'
        uses: paambaati/codeclimate-action@v2.7.4
        env:
          CC_TEST_REPORTER_ID: 7224dfa80ac316eaffa0c0d753c472d455d995ac1a10dd2ff66462ad48b70577

      - name: publish code coverage on Coveralls
        if: matrix.os == 'ubuntu-latest'
        uses: coverallsapp/github-action@master
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}