Skip to content

Commit 28a50b7

Browse files
committed
Add matrix to run tests on multiple versions
1 parent 600c5e6 commit 28a50b7

23 files changed

+139
-109
lines changed

.github/workflows/phpunit.yml

Lines changed: 39 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,53 @@
1-
name: PHPUnit
1+
name: run-tests
22

33
on:
44
push:
5-
branches: [ "main" ]
6-
pull_request:
7-
branches: [ "main" ]
8-
9-
permissions:
10-
contents: read
5+
paths:
6+
- '**.php'
7+
- '.github/workflows/run-tests.yml'
8+
- 'phpunit.xml.dist'
9+
- 'composer.json'
10+
- 'composer.lock'
1111

1212
jobs:
13-
build:
14-
15-
runs-on: ubuntu-latest
13+
phpunit:
14+
name: "P{{ matrix.php }} - L{{ matrix.laravel }} - {{ matrix.dependency-versions }} - {{ matrix.os }}"
15+
runs-on: "{{ matrix.os }}"
16+
timeout-minutes: 5
17+
18+
strategy:
19+
matrix:
20+
os: [ 'ubuntu-latest', 'macos-latest' ]
21+
php: [ '8.3', '8.2', '8.1', '8.0', ]
22+
laravel: [ '11.*', '10.*', '10.*' ]
23+
dependency-versions: [ 'prefer-lowest', 'prefer-stable' ]
24+
include:
25+
- laravel: '9.*'
26+
testbench: '7.*'
27+
- laravel: '10.*'
28+
testbench: '8.*'
29+
exclude:
30+
- laravel: '11.*'
31+
php: '8.0'
1632

1733
steps:
18-
- uses: actions/checkout@v3
34+
- name: Checkout code
35+
uses: actions/checkout@v4
1936

20-
- name: Validate composer.json and composer.lock
21-
run: composer validate --strict
22-
23-
- name: Cache Composer packages
24-
id: composer-cache
25-
uses: actions/cache@v3
37+
- name: Setup PHP
38+
uses: shivammathur/setup-php@v2
2639
with:
27-
path: vendor
28-
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
29-
restore-keys: |
30-
${{ runner.os }}-php-
40+
php-version: ${{ matrix.php }}
41+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
42+
coverage: none
3143

3244
- name: Install dependencies
33-
run: composer install --prefer-dist --no-progress
45+
run: |
46+
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "nesbot/carbon:${{ matrix.carbon }}" --no-interaction --no-update
47+
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
48+
49+
- name: List Installed Dependencies
50+
run: composer show -D
3451

3552
- name: Run test suite
3653
run: vendor/bin/phpunit

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/.coverage
22
/.phpunit.cache
3+
/.phpunit.result.cache
34
/vendor
45
/composer.lock

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@
2626
"php": "^8.0",
2727
"composer/semver": "^3.3",
2828
"guzzlehttp/guzzle": "^7.5",
29-
"illuminate/contracts": "^9.0 | ^10.0",
29+
"illuminate/contracts": "^9.0 | ^10.0 | ^11.0",
3030
"twig/twig": "^3.0"
3131
},
3232
"require-dev": {
33-
"brianium/paratest": "^6.10",
34-
"laravel/pint": "^1.4",
35-
"nunomaduro/collision": "^6.2",
36-
"orchestra/testbench": "^7.19"
33+
"laravel/pint": "^1.13.7",
34+
"nunomaduro/collision": "^6.4",
35+
"orchestra/testbench": "^8.19",
36+
"phpunit/phpunit": "^10.5.5"
3737
},
3838
"autoload": {
3939
"psr-4": {
@@ -61,6 +61,6 @@
6161
}
6262
},
6363
"scripts": {
64-
"coverage": "XDEBUG_MODE=coverage php -d pcov.enabled=1 -d pcov.directory=src -d pcov.exclude='~vendor~' vendor/bin/testbench package:test --parallel --coverage"
64+
"coverage": "XDEBUG_MODE=coverage php -d pcov.enabled=1 -d pcov.directory=src -d pcov.exclude='~vendor~' vendor/bin/testbench package:test --coverage"
6565
}
6666
}

phpunit.xml

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,28 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
4-
bootstrap="vendor/autoload.php"
5-
cacheResultFile=".phpunit.cache/test-results"
6-
executionOrder="depends,defects"
7-
forceCoversAnnotation="true"
8-
beStrictAboutCoversAnnotation="true"
3+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
4+
beStrictAboutCoverageMetadata="true"
95
beStrictAboutOutputDuringTests="true"
106
beStrictAboutTodoAnnotatedTests="true"
11-
convertDeprecationsToExceptions="true"
7+
bootstrap="vendor/autoload.php"
8+
cacheResultFile=".phpunit.cache/test-results.json"
9+
colors="true"
10+
executionOrder="depends,defects"
1211
failOnRisky="true"
1312
failOnWarning="true"
14-
verbose="true">
13+
requireCoverageMetadata="true"
14+
>
1515
<testsuites>
1616
<testsuite name="Feature">
1717
<directory>tests/Feature</directory>
1818
</testsuite>
19+
1920
<testsuite name="Unit">
2021
<directory>tests/Unit</directory>
2122
</testsuite>
2223
</testsuites>
2324

24-
<coverage cacheDirectory=".phpunit.cache/code-coverage"
25-
processUncoveredFiles="true">
26-
<include>
27-
<directory suffix=".php">src</directory>
28-
</include>
29-
30-
<exclude>
31-
<file>src/helpers.php</file>
32-
</exclude>
33-
25+
<coverage cacheDirectory=".phpunit.cache/code-coverage">
3426
<report>
3527
<html outputDirectory=".coverage"/>
3628
<text outputFile="php://stdout" showOnlySummary="true"/>

src/Commands/BaseCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ abstract class BaseCommand extends Command
1313
*
1414
* @param string[] $choices
1515
*/
16-
public function optionalChoice(string $question, array $choices, string $default = null): string|false
16+
public function optionalChoice(string $question, array $choices, ?string $default = null): string|false
1717
{
1818
$choice = $this->choice(
1919
question: $question,

src/Commands/DockerCiCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ public function handle(): int
3939

4040
protected function copy(string $platform): int
4141
{
42-
if (CiPlatform::GITHUB_ACTIONS === $platform) {
42+
if ($platform === CiPlatform::GITHUB_ACTIONS) {
4343
$template = package_path('resources/templates/ci-platforms/github-workflow.yml');
4444
$output = base_path('.github/workflows/ci.yml');
45-
} elseif (CiPlatform::GITLAB_CI === $platform) {
45+
} elseif ($platform === CiPlatform::GITLAB_CI) {
4646
$template = package_path('resources/templates/ci-platforms/.gitlab-ci.yml');
4747
$output = base_path('.gitlab-ci.yml');
4848
} else {

src/Commands/GenerateQuestions/Choices/PhpExtensions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class PhpExtensions
88
{
9-
public static function values(string $phpVersion = null): array
9+
public static function values(?string $phpVersion = null): array
1010
{
1111
return app(SupportedPhpExtensions::class)->get($phpVersion);
1212
}

src/Detectors/PhpExtensionsDetector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class PhpExtensionsDetector implements DetectorContract
99
{
1010
private array $supported;
1111

12-
public function supported(array $supported = null): self|array
12+
public function supported(?array $supported = null): self|array
1313
{
1414
if (is_null($supported)) {
1515
return $this->supported;

src/Integrations/SupportedPhpExtensions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class SupportedPhpExtensions
1010

1111
private ?array $cache = null;
1212

13-
public function get(string $phpVersion = null): array
13+
public function get(?string $phpVersion = null): array
1414
{
1515
if (! is_null($this->cache)) {
1616
return $this->cache;

src/helpers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
if (! function_exists('package_path')) {
4-
function package_path(string $path = null): string
4+
function package_path(?string $path = null): string
55
{
66
$dir = dirname(__FILE__, 2);
77

0 commit comments

Comments
 (0)