From f978434208d1cbb983835f2ab41f06105ffa050e Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 23 Aug 2024 15:19:30 +0200 Subject: [PATCH 1/2] Upgrade build system --- .github/workflows/continuous-integration.yml | 37 +++++++------------- .github/workflows/lint.yml | 27 ++++++++++---- .github/workflows/phpstan.yml | 31 +++++----------- phpunit.xml.dist | 24 +++++++------ 4 files changed, 56 insertions(+), 63 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index fe5dc39..53ab0ab 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -4,14 +4,14 @@ on: - push - pull_request -env: - 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: @@ -24,37 +24,26 @@ jobs: - "8.1" - "8.2" - "8.3" + - "8.4" experimental: [false] + os: [ubuntu-latest] include: - - php-version: "8.4" - experimental: true + - php-version: "8.3" + os: windows-latest steps: - - name: "Checkout" - uses: "actions/checkout@v2" + - 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 tests" + - name: Run tests run: | vendor/bin/phpunit vendor/bin/phpunit --testsuite phpstan diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 55e69c9..f23abf1 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -4,6 +4,9 @@ on: - push - pull_request +permissions: + contents: read + jobs: tests: name: "Lint" @@ -14,17 +17,27 @@ jobs: matrix: php-version: - "7.2" - - "8.3" + - "nightly" steps: - - name: "Checkout" - uses: "actions/checkout@v2" + - 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 diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index ae5094d..ce7db11 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -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: @@ -21,28 +20,16 @@ jobs: - "8.3" steps: - - name: "Checkout" - uses: "actions/checkout@v2" + - 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 phpstan" + - name: Run PHPStan + run: composer phpstan diff --git a/phpunit.xml.dist b/phpunit.xml.dist index ea52b72..b78312f 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,12 +1,17 @@ - +> tests/PregTests @@ -16,10 +21,9 @@ tests/PHPStanTests - - - - src - - + + + ./src/ + + From 9424d5f3c84a27442b94666fb0dccf005c9d84cb Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 23 Aug 2024 15:23:57 +0200 Subject: [PATCH 2/2] Fix --- .github/workflows/continuous-integration.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 53ab0ab..d6b43fc 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -30,6 +30,7 @@ jobs: include: - php-version: "8.3" os: windows-latest + experimental: false steps: - uses: actions/checkout@v4