name: Test

on:
  push:

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - name: Set up Node.js
        uses: actions/setup-node@v5
        with:
          node-version: '22.19.0'
      - name: Install dependencies
        run: npm ci
      - name: Format and check for changes
        run: npm run fmt && git --no-pager diff && exit $(git diff | wc -l)
      - name: Build
        run: npm run build
      - name: Run tests
        run: npm run test
      - name: Store test results
        uses: actions/upload-artifact@v4
        with:
          name: jest-junit-reports
          path: reports/jest-junit
      - name: Store artifacts
        uses: actions/upload-artifact@v4
        with:
          name: reports
          path: reports
