Skip to content

Commit 90441cd

Browse files
chore: split unit tests from the main CI workflow and report combined coverage to Coveralls
1 parent c4d3188 commit 90441cd

File tree

4 files changed

+157
-75
lines changed

4 files changed

+157
-75
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -30,39 +30,19 @@ jobs:
3030
echo "::notice::CI checks will execute - the actor is not the release-please bot"
3131
fi
3232
33-
tests:
33+
code-quality:
3434
needs: should-run
3535
if: needs.should-run.outputs.run == 'true'
3636
runs-on: ubuntu-latest
37-
name: "PHP ${{ matrix.php }} + Doctrine ORM ${{ matrix.doctrine-orm }} + Doctrine Lexer ${{ matrix.doctrine-lexer }}"
38-
strategy:
39-
fail-fast: false
40-
matrix:
41-
php: ['8.1', '8.2', '8.3', '8.4']
42-
doctrine-lexer: ['2.1', '3.0', 'latest']
43-
doctrine-orm: ['2.14', '2.18', '3.0', 'latest']
44-
include:
45-
- php: '8.1'
46-
doctrine-orm: '2.14'
47-
doctrine-lexer: '1.2'
48-
- php: '8.4' # Run coverage report only based on the latest dependencies
49-
doctrine-lexer: 'latest'
50-
doctrine-orm: 'latest'
51-
calculate-code-coverage: true
52-
exclude:
53-
- doctrine-orm: '2.14'
54-
doctrine-lexer: '3.0'
55-
- doctrine-orm: '3.0'
56-
doctrine-lexer: '2.1'
37+
name: "Code Quality"
5738

5839
steps:
5940
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
6041

61-
- name: Set up PHP with PECL extension
42+
- name: Set up PHP
6243
uses: shivammathur/setup-php@20529878ed81ef8e78ddf08b480401e6101a850f # v2
6344
with:
64-
php-version: ${{ matrix.php }}
65-
coverage: xdebug
45+
php-version: '8.4'
6646
extensions: ctype, json, mbstring
6747
tools: composer
6848

@@ -78,60 +58,11 @@ jobs:
7858
restore-keys: |
7959
${{ runner.os }}-php-
8060
81-
- name: Install Doctrine Lexer dependency
82-
run: |
83-
if [ "${{ matrix.doctrine-lexer }}" = "1.2" ]; then
84-
composer require doctrine/lexer "~1.2" --dev --prefer-dist --no-interaction --no-progress
85-
elif [ "${{ matrix.doctrine-lexer }}" = "2.1" ]; then
86-
composer require doctrine/lexer "~2.1" --dev --prefer-dist --no-interaction --no-progress
87-
elif [ "${{ matrix.doctrine-lexer }}" = "3.0" ]; then
88-
composer require doctrine/lexer "~3.0" --dev --prefer-dist --no-interaction --no-progress
89-
else
90-
composer update --prefer-dist --no-interaction --no-progress
91-
fi
92-
93-
- name: Install Doctrine ORM dependency
94-
run: |
95-
if [ "${{ matrix.doctrine-orm }}" = "2.14" ]; then
96-
composer require doctrine/orm "~2.14" --prefer-dist --no-interaction --no-progress --with-all-dependencies
97-
elif [ "${{ matrix.doctrine-orm }}" = "2.18" ]; then
98-
composer require doctrine/orm "~2.18" --prefer-dist --no-interaction --no-progress --with-all-dependencies
99-
elif [ "${{ matrix.doctrine-orm }}" = "3.0" ]; then
100-
composer require doctrine/orm "~3.0" --prefer-dist --no-interaction --no-progress --with-all-dependencies
101-
else
102-
composer update --prefer-dist --no-interaction --no-progress
103-
fi
104-
105-
- name: Run static analysis
106-
run: composer run-static-analysis
107-
continue-on-error: ${{ matrix.continue-on-error || false }}
61+
- name: Install dependencies
62+
run: composer install --prefer-dist --no-interaction --no-progress
10863

10964
- name: Check code style
11065
run: composer check-code-style
11166

11267
- name: Check for security vulnerabilities in 3rd party dependencies
11368
run: composer audit
114-
115-
- name: Run unit test suite
116-
run: composer run-unit-tests
117-
118-
- name: Upload coverage results to Coveralls
119-
if: matrix.calculate-code-coverage == true
120-
uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b # v2
121-
with:
122-
github-token: ${{ secrets.GITHUB_TOKEN }}
123-
file: ./var/logs/test-coverage/unit/clover.xml
124-
parallel: true
125-
flag-name: "Unit"
126-
fail-on-error: false
127-
128-
coveralls-finish:
129-
needs: tests
130-
if: always()
131-
runs-on: ubuntu-latest
132-
steps:
133-
- name: Finalize Coveralls parallel run
134-
uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b # v2
135-
with:
136-
github-token: ${{ secrets.GITHUB_TOKEN }}
137-
parallel-finished: true
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Coveralls Finish
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Unit Tests", "Integrations"]
6+
types:
7+
- completed
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
coveralls-finish:
14+
runs-on: ubuntu-latest
15+
if: >
16+
github.event.workflow_run.conclusion == 'success' ||
17+
github.event.workflow_run.conclusion == 'failure'
18+
steps:
19+
- name: Finalize Coveralls parallel run
20+
uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b # v2
21+
with:
22+
github-token: ${{ secrets.GITHUB_TOKEN }}
23+
parallel-finished: true

.github/workflows/integration-tests.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,13 @@ jobs:
114114
POSTGRES_DB: postgres_doctrine_test
115115
POSTGRES_USER: postgres
116116
POSTGRES_PASSWORD: postgres
117+
118+
- name: Upload coverage results to Coveralls
119+
if: matrix.calculate-code-coverage == true
120+
uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b # v2
121+
with:
122+
github-token: ${{ secrets.GITHUB_TOKEN }}
123+
file: ./var/logs/test-coverage/integration/clover.xml
124+
parallel: true
125+
flag-name: "Integration"
126+
fail-on-error: false

.github/workflows/unit-tests.yml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
name: Unit Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths-ignore:
8+
- '.github/actions/release-please/**'
9+
pull_request:
10+
branches:
11+
- main
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
should-run:
18+
runs-on: ubuntu-latest
19+
outputs:
20+
run: ${{ steps.check.outputs.run }}
21+
steps:
22+
- name: Skip for release-please
23+
id: check
24+
run: |
25+
if [ "${{ github.event.pull_request.user.id }}" = "41898282" ]; then
26+
echo "run=false" >> $GITHUB_OUTPUT
27+
echo "::notice::Skipping unit tests - this a release-please bot's interaction"
28+
else
29+
echo "run=true" >> $GITHUB_OUTPUT
30+
echo "::notice::Unit tests will execute - the actor is not the release-please bot"
31+
fi
32+
33+
unit-tests:
34+
needs: should-run
35+
if: needs.should-run.outputs.run == 'true'
36+
runs-on: ubuntu-latest
37+
name: "PHP ${{ matrix.php }} + Doctrine ORM ${{ matrix.doctrine-orm }} + Doctrine Lexer ${{ matrix.doctrine-lexer }}"
38+
39+
strategy:
40+
fail-fast: false
41+
matrix:
42+
php: ['8.1', '8.2', '8.3', '8.4']
43+
doctrine-lexer: ['2.1', '3.0', 'latest']
44+
doctrine-orm: ['2.14', '2.18', '3.0', 'latest']
45+
include:
46+
- php: '8.1'
47+
doctrine-orm: '2.14'
48+
doctrine-lexer: '1.2'
49+
- php: '8.4' # Run coverage report only based on the latest dependencies
50+
doctrine-lexer: 'latest'
51+
doctrine-orm: 'latest'
52+
calculate-code-coverage: true
53+
exclude:
54+
- doctrine-orm: '2.14'
55+
doctrine-lexer: '3.0'
56+
- doctrine-orm: '3.0'
57+
doctrine-lexer: '2.1'
58+
59+
steps:
60+
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
61+
62+
- name: Set up PHP with PECL extension
63+
uses: shivammathur/setup-php@20529878ed81ef8e78ddf08b480401e6101a850f # v2
64+
with:
65+
php-version: ${{ matrix.php }}
66+
coverage: xdebug
67+
extensions: ctype, json, mbstring
68+
tools: composer
69+
70+
- name: Cache Composer packages
71+
id: composer-cache
72+
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4
73+
with:
74+
path: vendor
75+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
76+
restore-keys: |
77+
${{ runner.os }}-php-
78+
79+
- name: Install Doctrine Lexer dependency
80+
run: |
81+
if [ "${{ matrix.doctrine-lexer }}" = "1.2" ]; then
82+
composer require doctrine/lexer "~1.2" --dev --prefer-dist --no-interaction --no-progress
83+
elif [ "${{ matrix.doctrine-lexer }}" = "2.1" ]; then
84+
composer require doctrine/lexer "~2.1" --dev --prefer-dist --no-interaction --no-progress
85+
elif [ "${{ matrix.doctrine-lexer }}" = "3.0" ]; then
86+
composer require doctrine/lexer "~3.0" --dev --prefer-dist --no-interaction --no-progress
87+
else
88+
composer update --prefer-dist --no-interaction --no-progress
89+
fi
90+
91+
- name: Install Doctrine ORM dependency
92+
run: |
93+
if [ "${{ matrix.doctrine-orm }}" = "2.14" ]; then
94+
composer require doctrine/orm "~2.14" --prefer-dist --no-interaction --no-progress --with-all-dependencies
95+
elif [ "${{ matrix.doctrine-orm }}" = "2.18" ]; then
96+
composer require doctrine/orm "~2.18" --prefer-dist --no-interaction --no-progress --with-all-dependencies
97+
elif [ "${{ matrix.doctrine-orm }}" = "3.0" ]; then
98+
composer require doctrine/orm "~3.0" --prefer-dist --no-interaction --no-progress --with-all-dependencies
99+
else
100+
composer update --prefer-dist --no-interaction --no-progress
101+
fi
102+
103+
- name: Run static analysis
104+
run: composer run-static-analysis
105+
continue-on-error: ${{ matrix.continue-on-error || false }}
106+
107+
- name: Run unit test suite
108+
run: composer run-unit-tests
109+
110+
- name: Upload coverage results to Coveralls
111+
if: matrix.calculate-code-coverage == true
112+
uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b # v2
113+
with:
114+
github-token: ${{ secrets.GITHUB_TOKEN }}
115+
file: ./var/logs/test-coverage/unit/clover.xml
116+
parallel: true
117+
flag-name: "Unit"
118+
fail-on-error: false

0 commit comments

Comments
 (0)