name: 'Frontend tests'
description: 'Run frontend tests and check types'
runs:
  using: 'composite'
  steps:
    - name: Prepare frontend tests
      if: always()
      run: npm run defs && npm run features
      shell: bash

    - name: Tests
      if: always()
      run: npm run test:frontend -- --reporter json --reporter-option 'output=reports/frontend-tests.json'
      shell: bash

    - name: Type Checks
      if: always()
      run: |
        set -o pipefail
        npm run check-types:frontend 2>&1 | tee reports/frontend-types.txt
      shell: bash

    - name: Write Markdown Summary
      if: always()
      run: |
        node scripts/mocha2md.js 'Frontend Tests' reports/frontend-tests.json >> $GITHUB_STEP_SUMMARY
        echo '# Frontend Types' >> $GITHUB_STEP_SUMMARY
        echo '```' >> $GITHUB_STEP_SUMMARY
        cat reports/frontend-types.txt >> $GITHUB_STEP_SUMMARY
        echo '```' >> $GITHUB_STEP_SUMMARY
      shell: bash
