Skip to content

Commit b4cd55e

Browse files
authored
Merge pull request #753 from Adyen/improve-github-workflows
Improve PHP CI workflow
2 parents 2840874 + c361cc1 commit b4cd55e

File tree

2 files changed

+78
-72
lines changed

2 files changed

+78
-72
lines changed

.github/workflows/codeql-analysis.yml

-49
This file was deleted.

.github/workflows/main.yml

+78-23
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,100 @@
1-
name: Main Workflow
1+
name: PHP CI
22

3-
on: ["pull_request"]
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- develop
8+
pull_request:
9+
branches:
10+
- main
11+
- develop
12+
workflow_dispatch: {}
413

514
jobs:
6-
run:
7-
name: Run
15+
php-test:
16+
name: PHP Test
817
runs-on: ubuntu-latest
9-
1018
strategy:
1119
matrix:
12-
php-version: [ 7.3, 8.2 ]
20+
php-version: [ '7.3', '8.2', '8.4' ]
21+
include:
22+
- php-version: '8.2'
23+
validate: true
1324

1425
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
with:
29+
fetch-depth: 0
30+
1531
- name: Setup PHP
1632
uses: shivammathur/setup-php@v2
1733
with:
1834
php-version: ${{ matrix.php-version }}
1935
tools: composer:v2
2036

37+
- name: Validate composer.json and composer.lock
38+
if: matrix.validate
39+
run: composer validate --strict
40+
41+
- name: Check PHP syntax
42+
if: matrix.validate
43+
run: find -L . -path ./vendor -prune -o -path ./tests -prune -o -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l
44+
45+
- name: Install dependencies
46+
run: composer install --prefer-dist --no-progress
47+
48+
- name: Run unit tests
49+
run: vendor/bin/phpunit --testsuite=unit --coverage-clover build/clover.xml --log-junit build/tests-log.xml
50+
51+
- name: Clean up reports
52+
run: sed -i "s;`pwd`/;;g" build/*.xml
53+
54+
php-lint:
55+
name: PHP Lint
56+
needs: php-test
57+
runs-on: ubuntu-latest
58+
steps:
2159
- name: Checkout
2260
uses: actions/checkout@v4
2361
with:
24-
# Disabling shallow clone to improve relevancy of SonarCloud reporting
2562
fetch-depth: 0
2663

27-
- name: Validate composer.json and composer.lock
28-
run: composer validate --strict
64+
- name: Setup PHP
65+
uses: shivammathur/setup-php@v2
66+
with:
67+
php-version: '8.2'
68+
tools: composer:v2
69+
70+
- name: Install dependencies
71+
run: composer install --prefer-dist --no-progress
72+
73+
- name: Run PHP Code Sniffer
74+
run: vendor/bin/phpcs --exclude=Generic.Files.LineLength
75+
76+
integration-tests:
77+
name: Integration Tests
78+
needs: [php-test, php-lint]
79+
runs-on: ubuntu-latest
80+
81+
# Only run integration tests on pull requests with release label and from the main repository
82+
if: |
83+
github.event_name == 'pull_request' &&
84+
contains(github.event.pull_request.labels.*.name, 'release') &&
85+
github.event.pull_request.head.repo.full_name == github.repository
86+
87+
steps:
88+
- name: Checkout
89+
uses: actions/checkout@v4
90+
with:
91+
fetch-depth: 0
92+
93+
- name: Setup PHP
94+
uses: shivammathur/setup-php@v2
95+
with:
96+
php-version: '8.2'
97+
tools: composer:v2
2998

3099
- name: Install dependencies
31100
run: composer install --prefer-dist --no-progress
@@ -44,17 +113,3 @@ jobs:
44113
INTEGRATION_STORE_PAYOUT_PASSWORD: ${{ secrets.INTEGRATION_STORE_PAYOUT_PASSWORD }}
45114
INTEGRATION_REVIEW_PAYOUT_USERNAME: ${{ secrets.INTEGRATION_REVIEW_PAYOUT_USERNAME }}
46115
INTEGRATION_REVIEW_PAYOUT_PASSWORD: ${{ secrets.INTEGRATION_REVIEW_PAYOUT_PASSWORD }}
47-
48-
- name: Run unit tests
49-
run: vendor/bin/phpunit --testsuite=unit --coverage-clover build/clover.xml --log-junit build/tests-log.xml
50-
51-
# PHPUnit generates absolute file paths and SonarCloud expects relative file paths. This command removes the
52-
# current working directory from the report files.
53-
- name: Clean up reports
54-
run: sed -i "s;`pwd`/;;g" build/*.xml
55-
56-
- name: Run PHP Code Sniffer
57-
run: vendor/bin/phpcs --exclude=Generic.Files.LineLength
58-
59-
- name: Make sure project files are compilable
60-
run: find -L . -path ./vendor -prune -o -path ./tests -prune -o -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l

0 commit comments

Comments
 (0)