name: CI

on:
  push:
    branches: main

jobs:
  build-js:
    name: Building css & javascript
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Yarn Build
        run: |
          yarn install
          yarn production
          cat public/mix-manifest.json # See asset versions in log
  test-php:
    name: Test PHP
    runs-on: ubuntu-latest
    needs: build-js
    steps:
      - uses: actions/checkout@v3
      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: '8.1'
          extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick
          coverage: none

      - name: Run composer install
        run: composer install -n --prefer-dist

      - name: Prepare Laravel Application
        run: |
          cp .env.example .env
          php artisan key:generate

      - name: Run Feature & Unit Test
        run: php artisan test
