Skip to content

Commit 20f8c29

Browse files
committed
Allow tests under PHP 8.2 and 8.3, run PHPStan only unter PHP 8.2
1 parent 898d9ea commit 20f8c29

File tree

4 files changed

+27
-54
lines changed

4 files changed

+27
-54
lines changed

.github/workflows/phpstan.yml

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,48 +7,30 @@ on:
77
jobs:
88

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

1313
strategy:
1414
fail-fast: false
1515
matrix:
1616
operating-system: ['ubuntu-latest']
17-
php-versions: ['7.4', '8.0', '8.1']
17+
php: ['8.2']
1818

1919
steps:
2020
- name: Checkout
21-
uses: actions/checkout@v2
21+
uses: actions/checkout@v3
2222
with:
2323
fetch-depth: 2
2424

25-
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
26-
27-
- name: Setup PHP, with composer and extensions
25+
- name: Setup PHP with composer and extensions
2826
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
2927
with:
30-
php-version: ${{ matrix.php-versions }}
31-
tools: phpunit
32-
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite
28+
php-version: ${{ matrix.php }}
3329
coverage: xdebug
34-
35-
- name: Get composer cache directory
36-
id: composer-cache
37-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
38-
39-
- name: Cache composer dependencies
40-
uses: actions/cache@v2
41-
with:
42-
path: ${{ steps.composer-cache.outputs.dir }}
43-
# Use composer.json for key, if composer.lock is not committed.
44-
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
45-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
46-
restore-keys: ${{ runner.os }}-composer-
30+
tools: none
4731

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

5135
- name: Run PHPStan
5236
run: vendor/bin/phpstan.phar analyze src --level 8
53-
54-
- run: echo "🍏 This job's status is ${{ job.status }}."

.github/workflows/unit-tests.yml

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,48 +7,37 @@ on:
77
jobs:
88

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

1313
strategy:
1414
fail-fast: false
1515
matrix:
1616
operating-system: ['ubuntu-latest']
17-
php-versions: ['7.4', '8.0', '8.1']
17+
php: ['7.4', '8.0', '8.1', '8.2', '8.3']
1818

1919
steps:
2020
- name: Checkout
21-
uses: actions/checkout@v2
21+
uses: actions/checkout@v3
2222
with:
2323
fetch-depth: 2
2424

25-
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
26-
27-
- name: Setup PHP, with composer and extensions
25+
- name: Setup PHP with composer and extensions
2826
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
2927
with:
30-
php-version: ${{ matrix.php-versions }}
31-
tools: phpunit
32-
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite
28+
php-version: ${{ matrix.php }}
3329
coverage: xdebug
30+
tools: none
3431

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

39-
- name: Cache composer dependencies
40-
uses: actions/cache@v2
36+
- name: "Install Composer dependencies (PHP 8.3)"
37+
if: ${{ matrix.php >= '8.3' }}
38+
uses: "ramsey/composer-install@v2"
4139
with:
42-
path: ${{ steps.composer-cache.outputs.dir }}
43-
# Use composer.json for key, if composer.lock is not committed.
44-
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
45-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
46-
restore-keys: ${{ runner.os }}-composer-
47-
48-
- name: Install Composer dependencies
49-
run: composer install --no-progress --prefer-dist --optimize-autoloader
40+
composer-options: --ignore-platform-reqs
5041

5142
- name: Run tests
52-
run: vendor/bin/phpunit --coverage-text
53-
54-
- run: echo "🍏 This job's status is ${{ job.status }}."
43+
run: composer run phpunit -- --coverage-text

composer.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
}
1414
],
1515
"require": {
16-
"php": "^7.4 || ^8.0"
16+
"php": "^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0"
1717
},
1818
"require-dev": {
1919
"friendsofphp/php-cs-fixer": "^3.2",
@@ -30,10 +30,11 @@
3030
"Art4\\JsonApiClient\\Tests\\": "tests"
3131
}
3232
},
33+
"scripts": {
34+
"phpstan": "phpstan analyze --memory-limit 512M analyze src --level 8",
35+
"phpunit": "phpunit"
36+
},
3337
"config": {
34-
"//platform": {
35-
"php": "7.4"
36-
},
3738
"sort-packages": true
3839
}
3940
}

tests/Fixtures/TestCase.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
namespace Art4\JsonApiClient\Tests\Fixtures;
2121

22+
#[\AllowDynamicProperties]
2223
class TestCase extends \PHPUnit\Framework\TestCase
2324
{
2425
/**

0 commit comments

Comments
 (0)