Skip to content

Commit

Permalink
Allow tests under PHP 8.2 and 8.3, run PHPStan only unter PHP 8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Art4 committed Oct 12, 2023
1 parent 898d9ea commit 20f8c29
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 54 deletions.
32 changes: 7 additions & 25 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,48 +7,30 @@ on:
jobs:

tests:
name: Run with PHP ${{ matrix.php-versions }} on ${{ matrix.operating-system }}
name: Run PHPStan with PHP ${{ matrix.php }}
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
operating-system: ['ubuntu-latest']
php-versions: ['7.4', '8.0', '8.1']
php: ['8.2']

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 2

- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."

- name: Setup PHP, with composer and extensions
- name: Setup PHP with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: ${{ matrix.php-versions }}
tools: phpunit
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite
php-version: ${{ matrix.php }}
coverage: xdebug

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

- name: Cache composer dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
tools: none

- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader
uses: "ramsey/composer-install@v2"

- name: Run PHPStan
run: vendor/bin/phpstan.phar analyze src --level 8

- run: echo "🍏 This job's status is ${{ job.status }}."
39 changes: 14 additions & 25 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,48 +7,37 @@ on:
jobs:

tests:
name: Tests (PHP ${{ matrix.php-versions }} on ${{ matrix.operating-system }})
name: Tests (PHP ${{ matrix.php }})
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
operating-system: ['ubuntu-latest']
php-versions: ['7.4', '8.0', '8.1']
php: ['7.4', '8.0', '8.1', '8.2', '8.3']

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 2

- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."

- name: Setup PHP, with composer and extensions
- name: Setup PHP with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: ${{ matrix.php-versions }}
tools: phpunit
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite
php-version: ${{ matrix.php }}
coverage: xdebug
tools: none

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: "Install Composer dependencies"
if: ${{ matrix.php < '8.3' }}
uses: "ramsey/composer-install@v2"

- name: Cache composer dependencies
uses: actions/cache@v2
- name: "Install Composer dependencies (PHP 8.3)"
if: ${{ matrix.php >= '8.3' }}
uses: "ramsey/composer-install@v2"
with:
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader
composer-options: --ignore-platform-reqs

- name: Run tests
run: vendor/bin/phpunit --coverage-text

- run: echo "🍏 This job's status is ${{ job.status }}."
run: composer run phpunit -- --coverage-text
9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
}
],
"require": {
"php": "^7.4 || ^8.0"
"php": "^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.2",
Expand All @@ -30,10 +30,11 @@
"Art4\\JsonApiClient\\Tests\\": "tests"
}
},
"scripts": {
"phpstan": "phpstan analyze --memory-limit 512M analyze src --level 8",
"phpunit": "phpunit"
},
"config": {
"//platform": {
"php": "7.4"
},
"sort-packages": true
}
}
1 change: 1 addition & 0 deletions tests/Fixtures/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

namespace Art4\JsonApiClient\Tests\Fixtures;

#[\AllowDynamicProperties]
class TestCase extends \PHPUnit\Framework\TestCase
{
/**
Expand Down

0 comments on commit 20f8c29

Please sign in to comment.