belgattitude/nextvalid

View on GitHub
.github/workflows/ci-packages.yml

Summary

Maintainability
Test Coverage
name: CI-packages

on:
  push:
    branches: [dev, main]
    paths-ignore:
      - 'docs/**'
  pull_request:
    types: [opened, synchronize, reopened, ready_for_review]
    branches:
      - '**'
    paths-ignore:
      - 'docs/**'

permissions:
  contents: read

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [18.x, 20.x]
    steps:
      - uses: actions/checkout@v4
        #with:
          # Fetch all git history so that yarn workspaces --since can compare with the correct commits
          # @link https://github.com/actions/checkout#fetch-all-history-for-all-tags-and-branches
        #  fetch-depth: 0

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

      - name: 📥 Monorepo install
        uses: ./.github/actions/yarn-nm-install

      - name: Restore packages cache
        uses: actions/cache@v3
        with:
          path: |
            ${{ github.workspace }}/.cache
            ${{ github.workspace }}/**/tsconfig.tsbuildinfo

          key: ${{ runner.os }}-packages-cache-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('packages/**.[jt]sx?', 'packages/**.json') }}
          restore-keys: |
            ${{ runner.os }}-packages-cache-${{ hashFiles('**/yarn.lock') }}-

      - name: Typecheck
        run: yarn workspaces foreach -W -tv --from="./packages/**" run typecheck

      - name: ESLint checks
        run: yarn workspaces foreach -W -tv --from="./packages/**" run lint

      - name: Unit tests
        run: yarn workspaces foreach -W -tv --from="./packages/**" run test-unit --coverage

      - name: Build packages
        run: yarn workspaces foreach -W -tv --from="./packages/**" run build

      - name: Check build for size-limits
        run: yarn workspaces foreach -W -tv --from="./packages/**" run check-size

      - name: Check build for ecmascript compliance
        run: yarn workspaces foreach -W -tv --from="./packages/**" run check-dist

      - name: Codecov upload
        if: matrix.node-version == '18.x'
        uses: codecov/codecov-action@v3
        with:
          directory: ./packages/zod-request/coverage
          #files: ./packages/http-exception/coverage/clover.xml
          flags: zod-request-unit
          fail_ci_if_error: false
          verbose: false
          working-directory: ${{ github.workspace }}

      - name: Check doc can be built
        run: yarn workspaces foreach -W -tv --from="./packages/**" run build-doc