name: Tests

on:
  push:
    branches: [ master ]
  pull_request:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Use Node.js 18
        uses: actions/setup-node@v3
        with:
          node-version: 18

      - name: Install Dependencies
        run: yarn

      - name: Build All
        run: yarn build

      - name: Run Tests
        run: yarn test

      - name: Check Code Formatting
        run: yarn fmt && (git diff-index --quiet HEAD; git diff)
