stalniy/casl

View on GitHub
.github/workflows/main.yml

Summary

Maintainability
Test Coverage
name: CI

on:
  push:
    branches: [master]
    paths:
      - .github/workflows/main.yml
      - packages/**/*.{js,ts,json}
      - '*.{json,js}'
      - .eslintrc
      - tools/**/*
  pull_request:

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node:
          - 18 # 2025-04-30
          - 20 # 2026-05-26
          - latest
    steps:
    - uses: actions/checkout@v3
      with:
        ref: ${{ github.sha }}
        fetch-depth: 2
    - uses: pnpm/action-setup@v2
      with:
        version: 8.4.0
        run_install: false
    - name: Get pnpm store directory
      id: pnpm-cache
      shell: bash
      run: |
        echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
    - name: Cache dependencies
      uses: actions/cache@v3
      env:
        cache-name: casl-deps
      with:
        path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
        key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('./pnpm-lock.yaml') }}
        restore-keys: |
          ${{ runner.os }}-build-${{ env.cache-name }}-
          ${{ runner.os }}-build-
          ${{ runner.os }}-
    - name: Install dependencies
      run: pnpm install
    - name: Get base sha
      id: base-commit
      run: |
        echo "sha=${{ github.event.pull_request.base.sha || github.event.before }}" >> $GITHUB_OUTPUT
    - name: Build
      run: pnpm run -r --filter '[${{ steps.base-commit.outputs.sha }}]...' build
    - name: lint
      run: pnpm run -r --filter '[${{ steps.base-commit.outputs.sha }}]' lint
    - name: test
      run: pnpm run -r --filter '...[${{ steps.base-commit.outputs.sha }}]' test --coverage
    - name: submit coverage
      env:
        CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
      run: pnpm run coverage.submit