GeoSot/Laravel-EnvEditor

View on GitHub
.github/workflows/phpunit.yml

Summary

Maintainability
Test Coverage
name: phpunit

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  test:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: true
      matrix:
        os: [ubuntu-latest]
        php: [8.1, 8.2, 8.3]
        laravel: [10.*, 11.*]
        include:
          -   laravel: 10.*
              testbench: 8.*
          -   laravel: 11.*
              testbench: 9.*
        exclude:
          -   laravel: 11.*
              php: 8.1


    name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} - ${{ matrix.os }}

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php }}
          extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
          coverage: pcov

      - name: Setup problem matchers
        run: |
          echo "::add-matcher::${{ runner.tool_cache }}/php.json"
          echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

      - name: Get composer cache directory
        id: composer-cache
        run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

      - name: Cache dependencies
        uses: actions/cache@v4
        with:
          path: ${{ steps.composer-cache.outputs.dir }}
          key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
          restore-keys: ${{ runner.os }}-composer-



      - name: Install composer dependencies
        run: |
          composer --version
          composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update
          composer require "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update --dev
          composer update --prefer-dist --no-interaction --no-suggest --dev
          composer dump


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

      - name: Upload coverage results to Coveralls
        env:
          COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          composer global require php-coveralls/php-coveralls
          php-coveralls --coverage_clover=build/logs/clover.xml -v