-
Notifications
You must be signed in to change notification settings - Fork 109
Improve PHP CI workflow #753
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
Conversation
|
20852f0
to
c361cc1
Compare
name: PHP Test | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
php-version: [ 7.3, 8.2 ] | ||
php-version: [ '7.3', '8.2', '8.4' ] | ||
include: | ||
- php-version: '8.2' | ||
validate: true | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php-version }} | ||
tools: composer:v2 | ||
|
||
- name: Validate composer.json and composer.lock | ||
if: matrix.validate | ||
run: composer validate --strict | ||
|
||
- name: Check PHP syntax | ||
if: matrix.validate | ||
run: find -L . -path ./vendor -prune -o -path ./tests -prune -o -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l | ||
|
||
- name: Install dependencies | ||
run: composer install --prefer-dist --no-progress | ||
|
||
- name: Run unit tests | ||
run: vendor/bin/phpunit --testsuite=unit --coverage-clover build/clover.xml --log-junit build/tests-log.xml | ||
|
||
- name: Clean up reports | ||
run: sed -i "s;`pwd`/;;g" build/*.xml | ||
|
||
php-lint: |
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
name: PHP Lint | ||
needs: php-test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
# Disabling shallow clone to improve relevancy of SonarCloud reporting | ||
fetch-depth: 0 | ||
|
||
- name: Validate composer.json and composer.lock | ||
run: composer validate --strict | ||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: '8.2' | ||
tools: composer:v2 | ||
|
||
- name: Install dependencies | ||
run: composer install --prefer-dist --no-progress | ||
|
||
- name: Run PHP Code Sniffer | ||
run: vendor/bin/phpcs --exclude=Generic.Files.LineLength | ||
|
||
integration-tests: |
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
|
Changes
Improved the workflow to three main jobs:
php-test
: Runs unit tests across multiple php versionsphp-lint
: Runs after unit testsintegration-tests
: Runs integration tests only for release PRs from the main repositoryRemoved environment variables from unit tests since they should be self-contained
Kept environment variables only in the integration test job where they are needed
Removed CodeQL workflow as PHP language is not yet supported.
Benefits
Testing