name: Tests

on:
  push:
    branches: [ master ]

permissions:
  contents: read

env:
  DB_PASSWORD: 'root'

jobs:
  tests:
    runs-on: ubuntu-22.04

    strategy:
      fail-fast: true
      matrix:
        php: [8.1]

    name: PHP ${{ matrix.php }}

    steps:
      - name: Checkout code
        uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php }}
          extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite
          coverage: none

      - name: Validate composer.json and composer.lock
        run: composer validate --strict

      - name: Cache Composer packages
        id: composer-cache
        uses: actions/cache@v3
        with:
          path: vendor
          key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
          restore-keys: |
            ${{ runner.os }}-php-

      - name: Install Composer dependencies
        run: composer install --prefer-dist --no-interaction --no-progress

      - name: Copy environment file
        run: cp .env.example .env

      - name: Generate app key
        run: php artisan key:generate
        
      - name: Clear Config
        run: php artisan config:clear
        
      - name: Setup mysql
        run: |
          sudo systemctl start mysql.service
          mysql -e 'CREATE DATABASE hammer_crm_test;' -uroot -proot

      - name: Execute tests
        run: vendor/bin/phpunit

Add workflow Tests for Github Actions
Add workflow Tests for Github Actions
