arifszn/blog.js

View on GitHub
.github/workflows/test.yml

Summary

Maintainability
Test Coverage
name: Test

on:
  pull_request:
    branches: [main]

  push:
    branches: [main]

  workflow_dispatch:

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v3

      - name: Set up Node
        uses: actions/setup-node@v3
        with:
          node-version: 16.x
          cache: 'npm'

      - name: Restore cache
        uses: actions/cache@v3
        with:
          path: |
            **/node_modules
          key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}

      - name: Install dependencies
        run: npm ci

      - name: Run lint
        run: npm run lint

      - name: Run prettier
        run: npm run prettier

      - name: Run tests
        run: npm run test

      - name: Publish in Code Climate
        if: github.event_name != 'pull_request'
        uses: paambaati/codeclimate-action@v3.0.0
        env:
          CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
        with:
          coverageCommand: npm run test:coverage
          debug: false