name: CI

on:
  workflow_dispatch:
  pull_request:

jobs:
  build:
    name: Build
    runs-on: [ubuntu-latest]
    steps:
      - uses: open-turo/actions-node/build@v7
  lint:
    name: Lint
    runs-on: ubuntu-latest
    steps:
      - name: Download actionlint
        run: |
          mkdir -p "$HOME/bin"
          bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash) latest "$HOME/bin"
          echo "${HOME}/bin" >> "$GITHUB_PATH"
      - uses: open-turo/actions-node/lint@v7
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          npm-token: ${{ secrets.OPEN_TURO_NPM_TOKEN }}
  test:
    name: Test
    runs-on: ubuntu-latest
    needs: [build]
    steps:
      - uses: open-turo/actions-node/test@v7
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          test-flags: --coverage
      - name: Upload coverage
        uses: coverallsapp/github-action@v2
