name: test

on:
  push:
    branches:
    - main
  pull_request:
    branches:
    - main

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      # Set everything up
      - uses: actions/checkout@v4
        with:
          submodules: 'recursive'
      - uses: actions/setup-node@v4
        with:
          node-version: 22

      # build and lint
      - run: npm install
      - run: npm run build
      - run: npm run lint

      # upload build artifacts
      - uses: actions/upload-artifact@v4
        with:
          name: engine262-lib
          path: |
            lib/engine262.js
            lib/engine262.js.map
            lib/engine262.mjs
            lib/engine262.mjs.map

      # run tests/coverage
      - run: npm run coverage:all
        env:
          CONTINUOUS_INTEGRATION: 1
          NUM_WORKERS: 1

      # Upload coverage data
      - name: Coveralls
        uses: coverallsapp/github-action@v2
        with:
          github-token: ${{github.token}}
