name: ci
on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - '**'
jobs:
  test:
    strategy:
      matrix:
        include:
          - name: Node.js 20
            NODE_VERSION: 20
          - name: Node.js 22
            NODE_VERSION: 22
          - name: Node.js 24
            NODE_VERSION: 24
      fail-fast: false
    name: ${{ matrix.name }}
    runs-on: ubuntu-latest
    timeout-minutes: 5
    steps:
      - uses: actions/checkout@v4
      - name: Use Node.js ${{ matrix.NODE_VERSION }}
        uses: actions/setup-node@v4
        with:
          node-version: ${{ matrix.NODE_VERSION }}
      - name: Cache Node.js modules
        uses: actions/cache@v4
        with:
          path: ~/.npm
          key: ${{ runner.os }}-node-${{ matrix.NODE_VERSION }}-${{ hashFiles('**/package-lock.json') }}
          restore-keys: |
              ${{ runner.os }}-node-${{ matrix.NODE_VERSION }}-
      - run: npm ci
      - run: npm run lint
      - run: npm run coverage
      - name: Upload code coverage
        uses: codecov/codecov-action@v4
        with:
          # Set to `true` once codecov token bug is fixed; https://github.com/parse-community/parse-server/issues/9129
          fail_ci_if_error: false
          token: ${{ secrets.CODECOV_TOKEN }}
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
