Skip to content

Commit

Permalink
Update CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed Aug 27, 2024
1 parent f1949bc commit 627fcbb
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 73 deletions.
29 changes: 8 additions & 21 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ on:
pull_request:
paths-ignore: ["**.md"]

env:
COMPOSER_FLAGS: --ansi --no-interaction --no-progress --prefer-dist
permissions:
contents: read

jobs:
tests:
Expand Down Expand Up @@ -40,29 +40,16 @@ jobs:
experimental: true

steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Install PHP
uses: shivammathur/setup-php@v2
- uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: ${{ matrix.php-version }}
php-version: "${{ matrix.php-version }}"
coverage: xdebug

- name: Get composer cache directory
id: composercache
shell: bash
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Restore cached dependencies
uses: actions/cache@v4
- uses: ramsey/composer-install@v3
with:
path: ${{ steps.composercache.outputs.dir }}
key: php-${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: php-${{ matrix.php-version }}-composer-

- name: Install latest dependencies
run: composer update ${{ env.COMPOSER_FLAGS }}
dependency-versions: highest

- name: Run tests
if: ${{ !matrix.experimental }}
Expand Down
29 changes: 8 additions & 21 deletions .github/workflows/functional.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ on:
pull_request:
paths-ignore: ["**.md"]

env:
COMPOSER_FLAGS: --ansi --no-interaction --no-progress --prefer-dist
permissions:
contents: read

jobs:
tests:
Expand Down Expand Up @@ -35,29 +35,16 @@ jobs:
experimental: true

steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Install PHP
uses: shivammathur/setup-php@v2
- uses: shivammathur/setup-php@v2
with:
coverage: xdebug
php-version: ${{ matrix.php-version }}
php-version: "${{ matrix.php-version }}"
coverage: none

- name: Get composer cache directory
id: composercache
shell: bash
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Restore cached dependencies
uses: actions/cache@v4
- uses: ramsey/composer-install@v3
with:
path: ${{ steps.composercache.outputs.dir }}
key: php-${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: php-${{ matrix.php-version }}-composer-

- name: Install latest dependencies
run: composer update ${{ env.COMPOSER_FLAGS }}
dependency-versions: highest

- name: Run tests
if: ${{ !matrix.experimental }}
Expand Down
31 changes: 22 additions & 9 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,40 @@ on:
pull_request:
paths-ignore: ["**.md"]

permissions:
contents: read

jobs:
tests:
name: Lint
name: "Lint"

runs-on: ubuntu-latest

strategy:
matrix:
php-version:
- "7.2"
- "latest"
- "nightly"

steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Install PHP
uses: shivammathur/setup-php@v2
- uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php-version }}"
coverage: none
php-version: ${{ matrix.php-version }}

- name: Lint PHP files
run: "find src/ -type f -name '*.php' -print0 | xargs -0 -L1 -P4 -- php -l -f"
- name: "Lint PHP files"
run: |
hasErrors=0
for f in $(find src/ tests/ -type f -name '*.php' ! -path '*/vendor/*' ! -path '*/Fixtures/*')
do
{ error="$(php -derror_reporting=-1 -ddisplay_errors=1 -l -f $f 2>&1 1>&3 3>&-)"; } 3>&1;
if [ "$error" != "" ]; then
while IFS= read -r line; do echo "::error file=$f::$line"; done <<< "$error"
hasErrors=1
fi
done
if [ $hasErrors -eq 1 ]; then
exit 1
fi
27 changes: 7 additions & 20 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ on:
pull_request:
paths-ignore: ["**.md"]

env:
COMPOSER_FLAGS: --ansi --no-interaction --no-progress --prefer-dist
permissions:
contents: read

jobs:
tests:
Expand All @@ -21,29 +21,16 @@ jobs:
- "8.1"

steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Install PHP
uses: shivammathur/setup-php@v2
- uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php-version }}"
coverage: none
php-version: ${{ matrix.php-version }}

- name: Get composer cache directory
id: composercache
shell: bash
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Restore cached dependencies
uses: actions/cache@v4
- uses: ramsey/composer-install@v3
with:
path: ${{ steps.composercache.outputs.dir }}
key: php-${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: php-${{ matrix.php-version }}-composer

- name: Install latest dependencies
run: composer update ${{ env.COMPOSER_FLAGS }}
dependency-versions: highest

- name: Run PHPStan
run: vendor/bin/phpstan analyse
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"composer/pcre": "^1 || ^2 || ^3"
},
"require-dev": {
"phpstan/phpstan": "^1.0",
"phpstan/phpstan": "^1.11",
"phpstan/phpstan-strict-rules": "^1.1",
"phpunit/phpunit": "^8.5 || ^9.6 || ^10.5"
},
Expand Down
1 change: 1 addition & 0 deletions tests/App/Framework/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public function __construct(Output $output)
/**
* @inheritdoc
* @phpstan-param mixed[] $context
* @param string|\Stringable $message
*/
public function log($level, $message, array $context = array()): void
{
Expand Down
3 changes: 2 additions & 1 deletion tests/App/Framework/Logs.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public function __construct(array $outputLines)
foreach ($outputLines as $line) {
$line = trim($line);

if (!(bool) preg_match('/^(.+)\\[(\\d+)\\](.+)$/', $line, $matches)) {
// @phpstan-ignore booleanNot.exprNotBoolean
if (!preg_match('/^(.+)\\[(\\d+)\\](.+)$/', $line, $matches)) {
continue;
}

Expand Down
1 change: 1 addition & 0 deletions tests/Helpers/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class Logger extends AbstractLogger
/**
* @inheritdoc
* @phpstan-param mixed[] $context
* @param string|\Stringable $message
*/
public function log($level, $message, array $context = []): void
{
Expand Down

0 comments on commit 627fcbb

Please sign in to comment.