name: tests with tape and check code coverage

on: [pull_request, workflow_dispatch]

permissions:
  contents: read

jobs:
  test:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, windows-latest]
        node: [22, 24]

    steps:
      - uses: actions/checkout@v7

      - name: setup node
        uses: actions/setup-node@v7
        with:
          node-version: ${{ matrix.node }}
          package-manager-cache: false

      - run: npm install --global yarn@1.22.22

      - run: yarn install --frozen-lockfile

      - run: yarn lint

      - run: yarn coverage

      - run: yarn test:dist

      - run: yarn test:types

      - name: upload coverage to codecov
        if: matrix.os == 'ubuntu-latest' && matrix.node == 24
        uses: codecov/codecov-action@v5
        with:
          files: ./coverage/lcov.info
          token: ${{ secrets.CODECOV_TOKEN }}
          fail_ci_if_error: true
          verbose: true
