Skip to content

Commit 47036ac

Browse files
committed
Add workflows
1 parent 078d10f commit 47036ac

File tree

7 files changed

+146
-5
lines changed

7 files changed

+146
-5
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Continuous Integration
2+
3+
on:
4+
push:
5+
paths-ignore: ["**.md"]
6+
pull_request:
7+
paths-ignore: ["**.md"]
8+
9+
env:
10+
COMPOSER_FLAGS: --ansi --no-interaction --no-progress --prefer-dist
11+
12+
jobs:
13+
tests:
14+
name: CI
15+
16+
runs-on: ${{ matrix.os }}
17+
18+
strategy:
19+
matrix:
20+
php-version:
21+
- "7.4"
22+
- "8.0"
23+
- "8.1"
24+
- "8.2"
25+
os: [ubuntu-latest]
26+
include:
27+
- php-version: "7.4"
28+
os: windows-latest
29+
- php-version: "8.2"
30+
os: windows-latest
31+
32+
steps:
33+
- name: Checkout
34+
uses: actions/checkout@v3
35+
36+
- name: Install PHP
37+
uses: shivammathur/setup-php@v2
38+
with:
39+
coverage: none
40+
php-version: ${{ matrix.php-version }}
41+
42+
- name: Get composer cache directory
43+
id: composercache
44+
shell: bash
45+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
46+
47+
- name: Restore cached dependencies
48+
uses: actions/cache@v3
49+
with:
50+
path: ${{ steps.composercache.outputs.dir }}
51+
key: php-${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.json') }}
52+
restore-keys: php-${{ matrix.php-version }}-composer-
53+
54+
- name: Install latest dependencies
55+
run: composer update ${{ env.COMPOSER_FLAGS }}
56+
57+
- name: Run tests
58+
run: vendor/bin/phpunit

.github/workflows/lint.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: PHP Lint
2+
3+
on:
4+
push:
5+
paths-ignore: ["**.md"]
6+
pull_request:
7+
paths-ignore: ["**.md"]
8+
9+
jobs:
10+
tests:
11+
name: Lint
12+
13+
runs-on: ubuntu-latest
14+
15+
strategy:
16+
matrix:
17+
php-version:
18+
- "7.4"
19+
- "latest"
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v3
24+
25+
- name: Install PHP
26+
uses: shivammathur/setup-php@v2
27+
with:
28+
coverage: none
29+
php-version: ${{ matrix.php-version }}
30+
31+
- name: Lint PHP files
32+
run: "find src/ -type f -name '*.php' -print0 | xargs -0 -L1 -P4 -- php -l -f"

.github/workflows/phpstan.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: PHPStan
2+
3+
on:
4+
push:
5+
paths-ignore: ["**.md"]
6+
pull_request:
7+
paths-ignore: ["**.md"]
8+
9+
env:
10+
COMPOSER_FLAGS: --ansi --no-interaction --no-progress --prefer-dist
11+
12+
jobs:
13+
tests:
14+
name: PHPStan
15+
16+
runs-on: ubuntu-latest
17+
18+
strategy:
19+
matrix:
20+
php-version:
21+
- "8.2"
22+
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v3
26+
27+
- name: Install PHP
28+
uses: shivammathur/setup-php@v2
29+
with:
30+
coverage: none
31+
php-version: ${{ matrix.php-version }}
32+
33+
- name: Get composer cache directory
34+
id: composercache
35+
shell: bash
36+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
37+
38+
- name: Restore cached dependencies
39+
uses: actions/cache@v3
40+
with:
41+
path: ${{ steps.composercache.outputs.dir }}
42+
key: php-${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.json') }}
43+
restore-keys: php-${{ matrix.php-version }}-composer
44+
45+
- name: Install latest dependencies
46+
run: composer update ${{ env.COMPOSER_FLAGS }}
47+
48+
- name: Run PHPStan
49+
run: vendor/bin/phpstan analyse

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
}
2727
},
2828
"require-dev": {
29-
"phpunit/phpunit": "9.6.5 || ^10.0",
29+
"phpunit/phpunit": "^9.6.5",
3030
"phpstan/phpstan": "^1.0",
3131
"phpstan/phpstan-strict-rules": "^1.1"
3232
},

phpunit.xml.dist

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit backupGlobals="false"
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
backupGlobals="false"
34
backupStaticAttributes="false"
45
colors="true"
56
convertErrorsToExceptions="true"

tests/Helpers/ErrorTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ public function testKnownCodes(): void
1919
$msg = 'something';
2020

2121
foreach ($class->getConstants() as $code) {
22-
if (!is_string($code)) {
23-
throw new \UnexpectedValueException('Error constant must be string');
22+
if (!is_string($code) || $code === '') {
23+
throw new \UnexpectedValueException('Error constant must be a non-empty string');
2424
}
25+
2526
$result = $this->error->get($code, $msg);
2627
self::assertStringStartsWith($code, $result);
2728
$expected = $code !== Error::ERR_VALIDATE ? '[something]' : $msg;

tests/Helpers/Patch/PatcherTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public function testAssignToScalarFails($data, string $path): void
141141
/**
142142
* @return array<string, array<mixed>>
143143
*/
144-
public function scalarProvider(): array
144+
public static function scalarProvider(): array
145145
{
146146
$prop = '/prop1';
147147
$offset = '/0';

0 commit comments

Comments
 (0)