Skip to content

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

Merged
merged 5 commits into from
May 6, 2025
Merged

Improve PHP CI workflow #753

merged 5 commits into from
May 6, 2025

Conversation

ayodejidev
Copy link
Contributor

@ayodejidev ayodejidev commented Mar 24, 2025

Changes

  • Improved the workflow to three main jobs:

    1. php-test: Runs unit tests across multiple php versions
    2. php-lint: Runs after unit tests
    3. integration-tests: Runs integration tests only for release PRs from the main repository
  • Removed 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

  • Better separation of concerns between unit and integration tests
  • Improved security by not exposing sensitive credentials to forked PRs
  • Clearer workflow structure with focused jobs

Testing

  • The updated workflow ran successfully in my forked branch

@ayodejidev ayodejidev requested a review from a team as a code owner March 24, 2025 03:25
@gcatanese gcatanese force-pushed the improve-github-workflows branch from 20852f0 to c361cc1 Compare May 6, 2025 14:19
Comment on lines +16 to +54
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

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
Comment on lines +55 to +76
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

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
Copy link

sonarqubecloud bot commented May 6, 2025

@gcatanese gcatanese merged commit b4cd55e into main May 6, 2025
9 checks passed
@gcatanese gcatanese deleted the improve-github-workflows branch May 6, 2025 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants