From 99ce01c3b7c364a38da0e4473dc6c3f17237f07f Mon Sep 17 00:00:00 2001 From: n4ss1m Date: Sat, 26 Oct 2024 02:30:36 +0100 Subject: [PATCH] enhancement: improve `php.yml` GitHub test workflow - Add testing for multiple PHP versions: 8.1, 8.2, 8.3 - Add OS matrix: ubuntu-latest, windows-latest - Validate `composer.json` - Execute tests across configurations --- .github/workflows/php.yml | 48 ++++++++++++++++++----------------- .github/workflows/symfony.yml | 47 ---------------------------------- 2 files changed, 25 insertions(+), 70 deletions(-) delete mode 100644 .github/workflows/symfony.yml diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 1ef7894..428744e 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -1,4 +1,4 @@ -name: PHP Composer +name: Tests on: push: @@ -6,34 +6,36 @@ on: pull_request: branches: [ "main" ] -permissions: - contents: read - jobs: - build: + test: + runs-on: ${{ matrix.os }} + timeout-minutes: 5 + strategy: + fail-fast: true + matrix: + os: [ubuntu-latest, windows-latest] + php: [8.1, 8.2, 8.3] - runs-on: ubuntu-latest + name: P${{ matrix.php }} - ${{ matrix.stability }} - ${{ matrix.os }} steps: - - uses: actions/checkout@v3 + - name: Checkout code + uses: actions/checkout@v4 - - name: Validate composer.json and composer.lock - run: composer validate --strict + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none - - 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: Validate composer.json + run: composer validate - - name: Install dependencies - run: composer install --prefer-dist --no-progress + - name: Install dependencies + run: composer install --prefer-dist --no-interaction - # Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit" - # Docs: https://getcomposer.org/doc/articles/scripts.md + - name: List Installed Dependencies + run: composer show -D - # - name: Run test suite - # run: composer run-script test + - name: Execute tests + run: composer test \ No newline at end of file diff --git a/.github/workflows/symfony.yml b/.github/workflows/symfony.yml deleted file mode 100644 index d0092f1..0000000 --- a/.github/workflows/symfony.yml +++ /dev/null @@ -1,47 +0,0 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -name: Symfony - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - -permissions: - contents: read - -jobs: - symfony-tests: - runs-on: ubuntu-latest - steps: - # To automatically get bug fixes and new Php versions for shivammathur/setup-php, - # change this to (see https://github.com/shivammathur/setup-php#bookmark-versioning): - # uses: shivammathur/setup-php@v2 - - uses: shivammathur/setup-php@2cb9b829437ee246e9b3cac53555a39208ca6d28 - with: - php-version: '8.0' - - uses: actions/checkout@v3 - - name: Copy .env.test.local - run: php -r "file_exists('.env.test.local') || copy('.env.test', '.env.test.local');" - - 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 Dependencies - run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist - - name: Create Database - run: | - mkdir -p data - touch data/database.sqlite - - name: Execute tests (Unit and Feature tests) via PHPUnit - env: - DATABASE_URL: sqlite:///%kernel.project_dir%/data/database.sqlite - run: vendor/bin/phpunit