on:
    push:
        branches:
            - main
    pull_request:

name: CI

jobs:
    test:
        name: Unit tests (Node ${{ matrix.node-version }})
        runs-on: ubuntu-latest
        strategy:
            matrix:
                node-version: [18, 19, 20]
            fail-fast: false
        steps:
            - uses: actions/checkout@v3
            - uses: pnpm/action-setup@v2
            - uses: actions/setup-node@v3
              with:
                  node-version: ${{ matrix.node-version }}
                  cache: 'pnpm'
            - run: pnpm install
            - run: pnpm compile:ohm
            - run: pnpm test

    lint:
        name: Code quality
        runs-on: ubuntu-latest
        steps:
            - uses: actions/checkout@v3
            - uses: pnpm/action-setup@v2
            - uses: actions/setup-node@v3
              with:
                  node-version: ${{ matrix.node-version }}
                  cache: 'pnpm'
            - run: pnpm install
            - run: pnpm format:check
            - run: pnpm lint:check
