-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,115 @@ | ||
name: Main Workflow | ||
name: PHP CI | ||
|
||
on: ["pull_request"] | ||
on: | ||
push: | ||
branches: | ||
- main | ||
- develop | ||
pull_request: | ||
branches: | ||
- main | ||
- develop | ||
workflow_dispatch: {} | ||
|
||
jobs: | ||
run: | ||
name: Run | ||
php-test: | ||
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: | ||
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: | ||
Comment on lines
+55
to
+76
Check warningCode 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}
|
||
name: Integration Tests | ||
needs: [php-test, php-lint] | ||
runs-on: ubuntu-latest | ||
|
||
# Only run integration tests on pull requests with release label and from the main repository | ||
if: | | ||
github.event_name == 'pull_request' && | ||
contains(github.event.pull_request.labels.*.name, 'release') && | ||
github.event.pull_request.head.repo.full_name == github.repository | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- 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 integration tests | ||
run: vendor/bin/phpunit --testsuite=integration --no-coverage | ||
env: | ||
INTEGRATION_USERNAME: ${{ secrets.INTEGRATION_USERNAME }} | ||
INTEGRATION_PASSWORD: ${{ secrets.INTEGRATION_PASSWORD }} | ||
INTEGRATION_X_API_KEY: ${{ secrets.INTEGRATION_X_API_KEY }} | ||
INTEGRATION_MERCHANT_ACCOUNT: ${{ secrets.INTEGRATION_MERCHANT_ACCOUNT }} | ||
INTEGRATION_DONATION_ACCOUNT: ${{ secrets.INTEGRATION_DONATION_ACCOUNT }} | ||
INTEGRATION_SKIN_CODE: ${{ secrets.INTEGRATION_SKIN_CODE }} | ||
INTEGRATION_HMAC_SIGNATURE: ${{ secrets.INTEGRATION_HMAC_SIGNATURE }} | ||
INTEGRATION_STORE_PAYOUT_USERNAME: ${{ secrets.INTEGRATION_STORE_PAYOUT_USERNAME }} | ||
INTEGRATION_STORE_PAYOUT_PASSWORD: ${{ secrets.INTEGRATION_STORE_PAYOUT_PASSWORD }} | ||
INTEGRATION_REVIEW_PAYOUT_USERNAME: ${{ secrets.INTEGRATION_REVIEW_PAYOUT_USERNAME }} | ||
INTEGRATION_REVIEW_PAYOUT_PASSWORD: ${{ secrets.INTEGRATION_REVIEW_PAYOUT_PASSWORD }} | ||
Check warningCode 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}
|
||
|
||
- name: Run unit tests | ||
run: vendor/bin/phpunit --testsuite=unit --coverage-clover build/clover.xml --log-junit build/tests-log.xml | ||
|
||
# PHPUnit generates absolute file paths and SonarCloud expects relative file paths. This command removes the | ||
# current working directory from the report files. | ||
- name: Clean up reports | ||
run: sed -i "s;`pwd`/;;g" build/*.xml | ||
|
||
- name: Run PHP Code Sniffer | ||
run: vendor/bin/phpcs --exclude=Generic.Files.LineLength | ||
|
||
- name: Make sure project files are compilable | ||
run: find -L . -path ./vendor -prune -o -path ./tests -prune -o -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium