name: ci

on: [push, pull_request]

jobs:
    test:
        runs-on: ubuntu-latest

        strategy:
            matrix:
              node-version: [14, 16, 18]
              target: [test-inline, test-browser, coverage]

        steps:
            - name: Checkout
              uses: actions/checkout@v2

            - name: Use Node.js
              uses: actions/setup-node@v2
              with:
                node-version: ${{ matrix.node-version }}

            - name: Reconfigure git to use HTTPS
              run: git config --global url.https://github.com/.insteadOf ssh://git@github.com/

            - name: Install
              run: npm ci

            - name: Lint
              run: npx grunt lint

            - name: Run tests
              uses: GabrielBB/xvfb-action@v1
              with:
                run: npx grunt ${{ matrix.target }}

            - name: Coveralls
              if: matrix.target == 'coverage'
              uses: coverallsapp/github-action@master
              with:
                github-token: ${{ secrets.GITHUB_TOKEN }}
