Skip to content

Commit 6a8d3ba

Browse files
authoredMar 25, 2024··
Create coverage-upload.yml
1 parent 85a9380 commit 6a8d3ba

File tree

1 file changed

+190
-0
lines changed

1 file changed

+190
-0
lines changed
 

‎.github/workflows/coverage-upload.yml

+190
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
name: 'CI'
2+
on: # Build any PRs and main branch changes
3+
workflow_dispatch: # Allows to run the workflow manually from the Actions tab
4+
pull_request:
5+
types:
6+
- opened
7+
- synchronize
8+
push:
9+
branches: [ master ]
10+
schedule:
11+
- cron: '0 0 1 * *' # Every month
12+
13+
concurrency:
14+
group: "${{ github.workflow }}-${{ github.head_ref || github.ref }}"
15+
cancel-in-progress: true
16+
17+
env:
18+
TEST_OUTPUT_STYLE: pretty
19+
COMPOSER_OPTIONS: --optimize-autoloader
20+
21+
jobs:
22+
tests:
23+
name: UTs & FTs - PHP ${{ matrix.php-version }}
24+
runs-on: ubuntu-latest
25+
env:
26+
COVERAGE_TYPE: none
27+
strategy:
28+
fail-fast: true
29+
max-parallel: 4
30+
matrix:
31+
include:
32+
# Bare minimum => Lowest versions allowed by composer config
33+
- php-version: '8.0'
34+
composer-flag: --prefer-lowest
35+
# Up to date versions => Latest versions allowed by composer config
36+
- php-version: '8.2'
37+
steps:
38+
- name: Check out code
39+
uses: actions/checkout@v3
40+
41+
- name: Enable coverage
42+
if: ${{ matrix.php-version == '8.2' }}
43+
run: |
44+
echo "COVERAGE_OUTPUT_STYLE=clover" >> $GITHUB_ENV
45+
echo "COVERAGE_TYPE=xdebug" >> $GITHUB_ENV
46+
47+
- name: Setup PHP ${{ matrix.php-version }}
48+
uses: shivammathur/setup-php@v2
49+
env:
50+
update: true # Always use latest available patch for the version
51+
fail-fast: true # step will fail if an extension or tool fails to set up
52+
with:
53+
php-version: '${{ matrix.php-version }}'
54+
tools: composer
55+
coverage: ${{ env.COVERAGE_TYPE }}
56+
57+
- name: Setup cache
58+
id: cache
59+
uses: actions/cache@v3
60+
with:
61+
path: |
62+
~/.composer
63+
./vendor
64+
# Clear the cache if composer json (as composer.lock is in the repo) has been updated
65+
key: tests-${{ matrix.php-version }}-${{ matrix.composer-flag }}-${{ hashFiles('composer.json') }}
66+
67+
- name: Build
68+
run: |
69+
composer update ${{ env.COMPOSER_OPTIONS }} ${{ matrix.composer-flag }} \
70+
&& make build
71+
72+
- name: Tests
73+
run: make test-unit && make test-functional
74+
75+
- name: Create "unit tests" reports group
76+
if: ${{ env.COVERAGE_TYPE == 'xdebug' }}
77+
id: unit-tests-coverage-group
78+
uses: yoanm/tmp-reports-group-workspace/.github/actions/create-action@develop
79+
with:
80+
name: unit-tests
81+
format: clover
82+
files: build/coverage-phpunit/unit.clover
83+
flags: |
84+
unit-tests
85+
php-${{ matrix.php-version }}
86+
path: build/coverage-groups
87+
88+
- name: Create "functional tests" coverage group
89+
if: ${{ env.COVERAGE_TYPE == 'xdebug' }}
90+
id: functional-tests-coverage-group
91+
uses: yoanm/tmp-reports-group-workspace/.github/actions/create-action@develop
92+
with:
93+
name: functional-tests
94+
format: clover
95+
files: |
96+
build/coverage-phpunit/functional.clover
97+
build/coverage-behat/clover.xml
98+
flags: |
99+
functional-tests
100+
php-${{ matrix.php-version }}
101+
path: build/coverage-groups
102+
103+
- name: Upload coverage reports
104+
if: ${{ env.COVERAGE_TYPE == 'xdebug' }}
105+
uses: actions/upload-artifact@v4
106+
with:
107+
name: coverage-groups-php${{ matrix.php-version }}
108+
path: build/coverage-groups
109+
if-no-files-found: error
110+
111+
static-checks:
112+
name: Static checks
113+
runs-on: ubuntu-latest
114+
steps:
115+
- uses: actions/checkout@v3
116+
117+
- name: Setup PHP 8.2
118+
uses: shivammathur/setup-php@v2
119+
with:
120+
php-version: 8.2 # Latest supported
121+
tools: composer
122+
coverage: none
123+
env:
124+
# Always use latest available patch for the version
125+
update: true
126+
127+
- name: Setup cache
128+
id: cache
129+
uses: actions/cache@v3
130+
with:
131+
path: |
132+
~/.composer
133+
# Clear the cache if composer json (as composer.lock is in the repo) has been updated
134+
key: tests-${{ env.PHP_VERSION }}-${{ hashFiles('composer.json') }}
135+
136+
- name: Build
137+
run: make build
138+
139+
- name: ComposerRequireChecker
140+
uses: docker://webfactory/composer-require-checker:4.5.0
141+
142+
- name: Dependencies check
143+
if: ${{ github.event_name == 'pull_request' }}
144+
uses: actions/dependency-review-action@v1
145+
146+
nightly-tests:
147+
name: Nightly - PHP ${{ matrix.php-version }}
148+
runs-on: ubuntu-latest
149+
env:
150+
COMPOSER_OPTIONS: '--optimize-autoloader --ignore-platform-req=php+'
151+
continue-on-error: true
152+
needs: [ static-checks, tests ]
153+
strategy:
154+
fail-fast: false
155+
max-parallel: 4
156+
matrix:
157+
php-version:
158+
- '8.3' # Current php dev version
159+
160+
steps:
161+
- name: Check out code
162+
uses: actions/checkout@v3
163+
164+
- name: Setup PHP ${{ matrix.php-version }}
165+
uses: shivammathur/setup-php@v2
166+
with:
167+
php-version: '${{ matrix.php-version }}'
168+
tools: composer
169+
coverage: none
170+
env:
171+
# Always use latest available patch for the version
172+
update: true
173+
174+
- name: Setup cache
175+
id: cache
176+
uses: actions/cache@v3
177+
with:
178+
path: |
179+
~/.composer
180+
./vendor
181+
# Clear the cache if composer json (as composer.lock is in the repo) has been updated
182+
key: tests-${{ matrix.php-version }}-${{ hashFiles('composer.json') }}
183+
184+
- name: Build
185+
run: |
186+
composer update ${{ env.COMPOSER_OPTIONS }} \
187+
&& make build
188+
189+
- name: Test
190+
run: make test-unit && make test-functional

0 commit comments

Comments
 (0)
Please sign in to comment.