Skip to content

Commit 6a4a053

Browse files
committed
Refactor CI pipeline
1 parent 051afe5 commit 6a4a053

File tree

11 files changed

+626
-522
lines changed

11 files changed

+626
-522
lines changed

.github/workflows/backward-compatibility.yml

Lines changed: 0 additions & 45 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 277 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,277 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "src/**"
7+
- "tests/**"
8+
- "composer.json"
9+
- "phpstan.neon.dist"
10+
- "phpunit.xml.dist"
11+
- ".php-cs-fixer.dist.php"
12+
- "rector.php"
13+
- "composer-dependency-analyser.php"
14+
- ".github/workflows/ci.yml"
15+
- ".github/workflows/secure-tests.yml"
16+
push:
17+
branches: ['8.x']
18+
paths:
19+
- "src/**"
20+
- "tests/**"
21+
- "composer.json"
22+
- "phpstan.neon.dist"
23+
- "phpunit.xml.dist"
24+
- ".php-cs-fixer.dist.php"
25+
- "rector.php"
26+
- "composer-dependency-analyser.php"
27+
- ".github/workflows/ci.yml"
28+
- ".github/workflows/secure-tests.yml"
29+
workflow_dispatch:
30+
31+
permissions:
32+
contents: read
33+
34+
concurrency:
35+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
36+
cancel-in-progress: true
37+
38+
jobs:
39+
dependency-validation:
40+
name: Dependency Validation
41+
runs-on: ubuntu-latest
42+
timeout-minutes: 20
43+
44+
steps:
45+
- name: Checkout code
46+
uses: actions/checkout@v6
47+
48+
- name: Setup PHP
49+
uses: shivammathur/setup-php@v2
50+
with:
51+
php-version: "8.5"
52+
coverage: none
53+
tools: composer
54+
55+
- name: Get Composer cache directory
56+
id: composer-cache
57+
shell: bash
58+
run: |
59+
echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
60+
61+
- name: Cache Composer cache directory
62+
uses: actions/cache@v5
63+
with:
64+
path: ${{ steps.composer-cache.outputs.dir }}
65+
key: ${{ runner.os }}-composer-${{ hashFiles('composer.json', 'composer.lock') }}
66+
restore-keys: ${{ runner.os }}-composer-
67+
68+
- name: Validate composer.json
69+
run: composer validate --strict
70+
71+
- name: Ensure dependencies can be installed
72+
run: composer install --no-interaction --no-progress --ansi --dry-run --ignore-platform-req=ext-grpc
73+
74+
static-analysis:
75+
name: "PHPStan (PHP ${{ matrix.php }})"
76+
needs:
77+
- dependency-validation
78+
runs-on: ubuntu-latest
79+
timeout-minutes: 20
80+
81+
strategy:
82+
fail-fast: false
83+
matrix:
84+
php:
85+
- "8.3"
86+
- "8.4"
87+
- "8.5"
88+
89+
steps:
90+
- name: Checkout code
91+
uses: actions/checkout@v6
92+
93+
- name: Setup PHP
94+
uses: shivammathur/setup-php@v2
95+
with:
96+
php-version: ${{ matrix.php }}
97+
tools: composer, pecl
98+
coverage: none
99+
100+
- name: Get Composer cache directory
101+
id: composer-cache
102+
shell: bash
103+
run: |
104+
echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
105+
106+
- name: Cache Composer cache directory
107+
uses: actions/cache@v5
108+
with:
109+
path: ${{ steps.composer-cache.outputs.dir }}
110+
key: ${{ runner.os }}-composer-${{ hashFiles('composer.json', 'composer.lock') }}
111+
restore-keys: ${{ runner.os }}-composer-
112+
113+
- name: Install dependencies with Composer
114+
run: composer install --no-interaction --no-progress --ansi --ignore-platform-req=ext-grpc
115+
116+
- name: Setup problem matchers for PHP
117+
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
118+
119+
- name: Run PHPStan
120+
run: XDEBUG_MODE=off vendor/bin/phpstan analyse --no-progress --error-format=github
121+
122+
tests:
123+
name: "PHP ${{ matrix.php }}, ${{ matrix.dependencies }} deps"
124+
needs:
125+
- static-analysis
126+
runs-on: ubuntu-latest
127+
timeout-minutes: 20
128+
129+
strategy:
130+
fail-fast: false
131+
matrix:
132+
php:
133+
- "8.3"
134+
- "8.4"
135+
- "8.5"
136+
dependencies:
137+
- "lowest"
138+
- "highest"
139+
140+
steps:
141+
- name: Checkout code
142+
uses: actions/checkout@v6
143+
144+
- name: Setup PHP
145+
uses: shivammathur/setup-php@v2
146+
with:
147+
php-version: ${{ matrix.php }}
148+
tools: composer, pecl
149+
coverage: none
150+
151+
- name: Get Composer cache directory
152+
id: composer-cache
153+
shell: bash
154+
run: |
155+
echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
156+
157+
- name: Cache Composer cache directory
158+
uses: actions/cache@v5
159+
with:
160+
path: ${{ steps.composer-cache.outputs.dir }}
161+
key: ${{ runner.os }}-composer-${{ hashFiles('composer.json', 'composer.lock') }}
162+
restore-keys: ${{ runner.os }}-composer-
163+
164+
- name: Install dependencies with Composer
165+
run: |
166+
if [ "${{ matrix.dependencies }}" = "lowest" ]; then
167+
composer update --prefer-lowest --prefer-stable --no-interaction --no-progress --ansi --ignore-platform-req=ext-grpc
168+
else
169+
composer update --no-interaction --no-progress --ansi --ignore-platform-req=ext-grpc
170+
fi
171+
172+
- name: Setup problem matchers for PHP
173+
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
174+
175+
- name: Setup Problem Matchers for PHPUnit
176+
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
177+
178+
- name: Run PHPUnit
179+
run: vendor/bin/phpunit --testsuite=unit --testdox
180+
181+
code-coverage:
182+
name: Unit Test Coverage (PHP 8.5)
183+
needs:
184+
- tests
185+
runs-on: ubuntu-latest
186+
timeout-minutes: 20
187+
188+
steps:
189+
- name: Checkout code
190+
uses: actions/checkout@v6
191+
192+
- name: Setup PHP
193+
uses: shivammathur/setup-php@v2
194+
with:
195+
php-version: "8.5"
196+
tools: composer, pecl
197+
coverage: xdebug
198+
199+
- name: Get Composer cache directory
200+
id: composer-cache
201+
shell: bash
202+
run: |
203+
echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
204+
205+
- name: Cache Composer cache directory
206+
uses: actions/cache@v5
207+
with:
208+
path: ${{ steps.composer-cache.outputs.dir }}
209+
key: ${{ runner.os }}-composer-${{ hashFiles('composer.json', 'composer.lock') }}
210+
restore-keys: ${{ runner.os }}-composer-
211+
212+
- name: Install dependencies with Composer
213+
run: composer install --no-interaction --no-progress --ansi --ignore-platform-req=ext-grpc
214+
215+
- name: Setup problem matchers for PHP
216+
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
217+
218+
- name: Setup Problem Matchers for PHPUnit
219+
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
220+
221+
- name: Run PHPUnit with coverage
222+
run: vendor/bin/phpunit --testsuite=unit --coverage-clover=coverage.xml --log-junit=test-report.xml --testdox
223+
224+
- name: Upload test results to Codecov
225+
if: ${{ !cancelled() }}
226+
uses: codecov/codecov-action@v5
227+
with:
228+
token: ${{ secrets.CODECOV_TOKEN }}
229+
flags: unit
230+
report_type: test_results
231+
fail_ci_if_error: false
232+
233+
- name: Upload coverage to Codecov
234+
if: ${{ !cancelled() }}
235+
uses: codecov/codecov-action@v5
236+
with:
237+
token: ${{ secrets.CODECOV_TOKEN }}
238+
files: ./coverage.xml
239+
flags: unit
240+
fail_ci_if_error: false
241+
242+
bc-check:
243+
name: Backward Compatibility Check
244+
needs:
245+
- dependency-validation
246+
runs-on: ubuntu-latest
247+
timeout-minutes: 20
248+
249+
steps:
250+
- name: Checkout code
251+
uses: actions/checkout@v6
252+
with:
253+
fetch-depth: 0
254+
fetch-tags: true
255+
256+
- name: "Workaround: Configure Git safe.directory for roave-bc-check Docker action"
257+
run: |
258+
mkdir -p /home/runner/work/_temp/_github_home
259+
printf "[safe]\n\tdirectory = /github/workspace\n" > /home/runner/work/_temp/_github_home/.gitconfig
260+
261+
- name: Check whether repository has tags
262+
id: check-tags
263+
shell: bash
264+
run: |
265+
if git tag --list | grep -q .; then
266+
echo "has_tags=true" >> "$GITHUB_OUTPUT"
267+
else
268+
echo "has_tags=false" >> "$GITHUB_OUTPUT"
269+
fi
270+
271+
- name: Run Roave BC Check
272+
if: ${{ steps.check-tags.outputs.has_tags == 'true' }}
273+
uses: docker://nyholm/roave-bc-check-ga
274+
275+
- name: Skip Roave BC Check (no tags found)
276+
if: ${{ steps.check-tags.outputs.has_tags != 'true' }}
277+
run: echo "Skipping BC check because no git tags were found."

.github/workflows/docs.yml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
name: Check links
1+
name: Docs
22

33
on:
44
pull_request:
55
paths:
6-
- 'docs/**'
7-
- '.github/workflows/docs.yml'
8-
- 'CHANGELOG.md'
9-
- 'README.md'
10-
- 'lychee.toml'
6+
- "docs/**"
7+
- ".github/workflows/docs.yml"
8+
- "CHANGELOG.md"
9+
- "README.md"
10+
- "lychee.toml"
1111
push:
1212
branches: ['8.x']
1313
paths:
14-
- 'docs/**'
15-
- '.github/workflows/docs.yml'
16-
- 'CHANGELOG.md'
17-
- 'README.md'
18-
- 'lychee.toml'
14+
- "docs/**"
15+
- ".github/workflows/docs.yml"
16+
- "CHANGELOG.md"
17+
- "README.md"
18+
- "lychee.toml"
1919
release:
2020
types: [published]
2121
workflow_dispatch:
@@ -31,6 +31,7 @@ jobs:
3131
links:
3232
name: Check Links
3333
runs-on: ubuntu-latest
34+
timeout-minutes: 20
3435

3536
steps:
3637
- name: Checkout repository

0 commit comments

Comments
 (0)