Skip to content

Commit

Permalink
Update CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed Aug 23, 2024
1 parent 986a689 commit 684ebfd
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 67 deletions.
55 changes: 24 additions & 31 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,15 @@ on:
- push
- pull_request

env:
COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --prefer-dist"
SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT: "1"

permissions:
contents: read

jobs:
tests:
name: "CI"

runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}

strategy:
matrix:
Expand All @@ -25,41 +22,37 @@ jobs:
- "7.4"
- "8.0"
- "8.1"
dependencies: [locked]
- "8.2"
- "8.3"
- "8.4"
dependencies: [highest]
experimental: [false]
os: [ubuntu-latest]
include:
- php-version: "7.2"
dependencies: lowest
- php-version: "8.1"
os: ubuntu-latest
experimental: false
- php-version: "8.3"
dependencies: lowest
os: ubuntu-latest
experimental: false
- php-version: "8.3"
dependencies: highest
os: windows-latest
experimental: false

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 }}"
tools: composer:snapshot

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

- name: Cache dependencies
uses: actions/cache@v2
- uses: ramsey/composer-install@v3
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: "Handle lowest dependencies update"
if: "contains(matrix.dependencies, 'lowest')"
run: "echo \"COMPOSER_FLAGS=$COMPOSER_FLAGS --prefer-lowest\" >> $GITHUB_ENV"

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

- name: "Run tests"
run: "vendor/bin/simple-phpunit --verbose"
- name: Run tests
run: composer test
24 changes: 17 additions & 7 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,27 @@ jobs:
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:
coverage: "none"
php-version: "${{ matrix.php-version }}"
coverage: none

- name: "Lint PHP files"
run: "find src/ -type f -name '*.php' -print0 | xargs -0 -L1 -P4 -- php -l -f"
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
33 changes: 8 additions & 25 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ on:
- push
- pull_request

env:
COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --prefer-dist"
SYMFONY_PHPUNIT_VERSION: ""

permissions:
contents: read

Expand All @@ -20,33 +16,20 @@ jobs:
strategy:
matrix:
php-version:
- "8.0"
- "7.2"
- "8.3"

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 }}"
coverage: none

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

- name: Cache dependencies
uses: actions/cache@v2
- uses: ramsey/composer-install@v3
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

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

- name: Run PHPStan
run: |
composer require --dev phpunit/phpunit:^8.5.18 --with-all-dependencies ${{ env.COMPOSER_FLAGS }}
vendor/bin/phpstan analyse
run: composer phpstan
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,13 @@
"require-dev": {
"composer/composer": "^1.10.27 || ^2.7",
"composer/semver": "^1.7.2 || ^3.4.0",
"symfony/phpunit-bridge": "^7.1.1",
"phpunit/phpunit": "^8 || ^9",
"phpstan/phpstan": "^1.11",
"symfony/process": "^5 || ^6 || ^7",
"phpstan/phpstan-phpunit": "^1"
},
"scripts": {
"test": "@php vendor/bin/simple-phpunit",
"phpstan": "@php vendor/bin/phpstan analyse"
"test": "@php phpunit",
"phpstan": "@php phpstan analyse"
}
}
2 changes: 1 addition & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ parameters:
paths:
- src
- tests
excludes_analyse:
excludePaths:
- tests/Composer/Installers/Test/PolyfillTestCase.php
ignoreErrors:
- '~Test::[a-zA-Z0-9]+Provider\(\) return type~'
Expand Down

0 comments on commit 684ebfd

Please sign in to comment.