Skip to content

Commit 976647b

Browse files
ci: optimize CI workflow performance (#465)
1 parent 118bfa3 commit 976647b

File tree

5 files changed

+35
-14
lines changed

5 files changed

+35
-14
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ on:
1010
branches:
1111
- main
1212

13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
16+
1317
permissions:
1418
contents: read
1519

.github/workflows/integration-tests.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ on:
1010
branches:
1111
- main
1212

13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
16+
1317
permissions:
1418
contents: read
1519

@@ -81,7 +85,7 @@ jobs:
8185
uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f # v2
8286
with:
8387
php-version: ${{ matrix.php }}
84-
coverage: xdebug
88+
coverage: ${{ matrix.calculate-code-coverage == true && 'xdebug' || 'none' }}
8589
extensions: ctype, json, mbstring, pdo_pgsql
8690
tools: composer
8791

@@ -93,9 +97,10 @@ jobs:
9397
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
9498
with:
9599
path: vendor
96-
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
100+
key: ${{ runner.os }}-php-${{ matrix.php }}-pg-${{ matrix.postgres }}-${{ hashFiles('**/composer.lock') }}
97101
restore-keys: |
98-
${{ runner.os }}-php-
102+
${{ runner.os }}-php-${{ matrix.php }}-pg-${{ matrix.postgres }}-
103+
${{ runner.os }}-php-${{ matrix.php }}-
99104
100105
- name: Install dependencies
101106
run: composer install --prefer-dist --no-interaction --no-progress
@@ -125,7 +130,12 @@ jobs:
125130
PGPASSWORD=postgres psql -h localhost -U postgres -d postgres_doctrine_test -c "SELECT PostGIS_Version();"
126131
127132
- name: Run integration test suite
128-
run: composer run-integration-tests
133+
run: |
134+
if [ "${{ matrix.calculate-code-coverage }}" = "true" ]; then
135+
XDEBUG_MODE=coverage composer run-integration-tests
136+
else
137+
composer run-integration-tests -- --no-coverage
138+
fi
129139
env:
130140
POSTGRES_HOST: localhost
131141
POSTGRES_PORT: 5432

.github/workflows/unit-tests.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ on:
1010
branches:
1111
- main
1212

13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
16+
1317
permissions:
1418
contents: read
1519

@@ -63,7 +67,7 @@ jobs:
6367
uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f # v2
6468
with:
6569
php-version: ${{ matrix.php }}
66-
coverage: xdebug
70+
coverage: ${{ matrix.calculate-code-coverage == true && 'xdebug' || 'none' }}
6771
extensions: ctype, json, mbstring
6872
tools: composer
6973

@@ -72,9 +76,10 @@ jobs:
7276
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
7377
with:
7478
path: vendor
75-
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
79+
key: ${{ runner.os }}-php-${{ matrix.php }}-orm-${{ matrix.doctrine-orm }}-lexer-${{ matrix.doctrine-lexer }}-${{ hashFiles('**/composer.lock') }}
7680
restore-keys: |
77-
${{ runner.os }}-php-
81+
${{ runner.os }}-php-${{ matrix.php }}-orm-${{ matrix.doctrine-orm }}-lexer-${{ matrix.doctrine-lexer }}-
82+
${{ runner.os }}-php-${{ matrix.php }}-
7883
7984
- name: Install Doctrine Lexer dependency
8085
run: |
@@ -105,7 +110,12 @@ jobs:
105110
continue-on-error: ${{ matrix.continue-on-error || false }}
106111

107112
- name: Run unit test suite
108-
run: composer run-unit-tests
113+
run: |
114+
if [ "${{ matrix.calculate-code-coverage }}" = "true" ]; then
115+
XDEBUG_MODE=coverage composer run-unit-tests
116+
else
117+
composer run-unit-tests -- --no-coverage
118+
fi
109119
110120
- name: Upload coverage results to Coveralls
111121
if: matrix.calculate-code-coverage == true

.scrutinizer.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ build:
88
tests:
99
override:
1010
- php-scrutinizer-run
11-
- command: composer run-unit-tests
11+
- command: XDEBUG_MODE=coverage composer run-unit-tests
1212
coverage:
1313
file: var/logs/test-coverage/unit/clover.xml
1414
format: clover

composer.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,11 @@
7171
"phpstan": [
7272
"phpstan analyse --configuration=./ci/phpstan/config.neon"
7373
],
74-
"phpunit": [
75-
"XDEBUG_MODE=coverage phpunit"
76-
],
7774
"phpunit:unit": [
78-
"@phpunit --configuration=./ci/phpunit/config-unit.xml"
75+
"phpunit --configuration=./ci/phpunit/config-unit.xml"
7976
],
8077
"phpunit:integration": [
81-
"@phpunit --configuration=./ci/phpunit/config-integration.xml"
78+
"phpunit --configuration=./ci/phpunit/config-integration.xml"
8279
],
8380
"rector": [
8481
"rector --config=./ci/rector/config.php --ansi --no-progress-bar"

0 commit comments

Comments
 (0)