name: TypeScript tests

on:
  workflow_call:
    inputs:
      all-platforms:
        required: false
        default: true
        type: boolean

jobs:
  regular-tests:
    strategy:
      matrix:
        platform: ${{ (inputs.all-platforms && fromJSON('["ubuntu-24.04", "macos-latest", "windows-latest"]')) || fromJSON('["ubuntu-24.04"]') }}
    runs-on: ${{ matrix.platform }}
    timeout-minutes: 120
    steps:
      - name: Check out lingua-franca repository
        uses: actions/checkout@v3
        with:
          fetch-depth: 0
          submodules: true
      - name: Prepare build environment
        uses: ./.github/actions/prepare-build-env
      - name: Setup Node.js environment
        uses: actions/setup-node@v4
        with:
          node-version: 22
      - name: Install pnpm
        run: npm i -g pnpm
      - name: Install coreutils (macOS)
        run: |
          brew install coreutils
        if: ${{ runner.os == 'macOS' }}
      - name: Install RTI
        uses: ./.github/actions/install-rti
        if: ${{ runner.os == 'macOS' || runner.os == 'Linux' }}
      - name: Perform TypeScript tests
        run: |
          ./gradlew targetTest -Ptarget=TypeScript -Druntime="git://github.com/lf-lang/reactor-ts.git#master"
      - name: Report to CodeCov
        uses: ./.github/actions/report-code-coverage
        with:
          files: core/build/reports/jacoco/integrationTestCodeCoverageReport/integrationTestCodeCoverageReport.xml
        if: ${{ github.repository == 'lf-lang/lingua-franca' }}
