Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CI #47

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 16 additions & 23 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ on:
- 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"
Expand All @@ -28,33 +30,24 @@ jobs:
- "7.4"
- "8.0"
- "8.1"
- "8.2"
- "8.3"
- "8.4"

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: "Remove PHPStan as it requires a newer PHP"
run: composer remove phpstan/phpstan --dev --no-update

- name: Cache dependencies
uses: actions/cache@v4
- 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: |
# Remove PHPStan as it requires a newer PHP
composer remove phpstan/phpstan --dev --no-update
composer update ${{ env.COMPOSER_FLAGS }}

- name: "Run tests"
run: "vendor/bin/simple-phpunit --verbose"
dependency-versions: highest

- name: Run tests
run: vendor/bin/simple-phpunit --verbose
28 changes: 21 additions & 7 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
- push
- pull_request

permissions:
contents: read

jobs:
tests:
name: "Lint"
Expand All @@ -14,17 +17,28 @@ jobs:
matrix:
php-version:
- "5.3"
- "8.0"
- "7.4"
- "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
27 changes: 7 additions & 20 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ on:
- push
- pull_request

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

jobs:
tests:
Expand All @@ -21,28 +20,16 @@ jobs:
- "7.4"

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@v4
- 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
# Locked to phpunit 7.5 here as newer ones have void return types which break inheritance
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"php": "^5.3.2 || ^7.0 || ^8.0"
},
"require-dev": {
"symfony/phpunit-bridge": "^4.2 || ^5",
"phpstan/phpstan": "^0.12.55"
"symfony/phpunit-bridge": "^3 || ^7",
"phpstan/phpstan": "^1.11"
},
"autoload": {
"psr-4": {
Expand Down
9 changes: 5 additions & 4 deletions tests/SpdxLicensesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public function testIsDeprecatedByIdentifier()
}

/**
* @return array[]
* @return array<array{SpdxLicenses::*}>
*/
public function provideResourceFiles()
{
Expand Down Expand Up @@ -287,7 +287,7 @@ public function provideValidLicenses()
}

/**
* @return array[]
* @return array<array{string|string[]}>
*/
public function provideInvalidLicenses()
{
Expand Down Expand Up @@ -316,7 +316,7 @@ public function provideInvalidLicenses()
}

/**
* @return array[]
* @return array<array<mixed>>
*/
public function provideInvalidArgument()
{
Expand All @@ -330,14 +330,15 @@ public function provideInvalidArgument()
}

/**
* @param string $exception
* @param class-string<\Throwable> $exception
* @param string|null $message
* @param int|null $code
* @return void
*/
public function setExpectedException($exception, $message = null, $code = null)
{
if (!class_exists('PHPUnit\Framework\Error\Notice')) {
/** @var class-string<\Throwable> */
$exception = str_replace('PHPUnit\\Framework\\Error\\', 'PHPUnit_Framework_Error_', $exception);
}
if (method_exists($this, 'expectException')) {
Expand Down