Skip to content

Commit 5c323f0

Browse files
committed
#24 - workflow split based on php versions
1 parent fd54a93 commit 5c323f0

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

.github/workflows/php.yml

+27-6
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@ jobs:
2828
coverage: pcov
2929
tools: composer:v2
3030

31-
- name: Adjust composer dependencies based on PHP version
32-
run: php php-version-deps-adjust.php
31+
- name: Adjust composer dependencies for older PHP versions
32+
if: contains(matrix.php-version, '8.0, 8.1')
33+
run: |
34+
php php-version-deps-adjust.php
35+
composer update --no-progress --no-interaction
3336
3437
- name: Cache Composer packages
3538
id: composer-cache
@@ -41,9 +44,27 @@ jobs:
4144
${{ runner.os }}-php-${{ matrix.php-version }}-
4245
4346
- name: Install dependencies
44-
run: composer install --prefer-dist --no-progress
47+
run: composer install --no-progress --no-interaction
48+
49+
- name: Run test suites for older PHP versions
50+
if: contains(matrix.php-version, '8.0, 8.1, 8.2, 8.3')
51+
run: composer run-script test-all
52+
53+
- name: Run test suites with coverage for latest PHP version
54+
if: matrix.php-version == '8.4'
55+
run: |
56+
mkdir -p var/coverage
57+
php -d xdebug.mode=coverage vendor/bin/phpunit --coverage-text --coverage-clover=var/coverage/clover.xml | tee var/coverage/coverage.txt
58+
59+
- name: Extract Line Coverage
60+
if: matrix.php-version == '8.4'
61+
id: coverage
62+
run: echo "COVERAGE=$(grep -oP '(?<=Lines:\s+)[\d\.]+' coverage.txt | tail -1)" >> $GITHUB_ENV
4563

46-
- name: Run test suite with coverage
64+
- name: Update GitHub Status
65+
if: matrix.php-version == '8.4'
4766
run: |
48-
composer run-script test-coverage
49-
codecov -f var/coverage/html-report/index.html
67+
curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
68+
-H "Accept: application/vnd.github.v3+json" \
69+
https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.sha }} \
70+
-d "{\"state\":\"success\",\"context\":\"Code Coverage\",\"description\":\"Line Coverage: ${{ env.COVERAGE }}%\",\"target_url\":\"https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}"

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
vendor/
22
var/
3+
!var/coverage/.gitkeep
34
.idea
45
tests/php-unit/reports/
56
.phpunit.result.cache

var/coverage/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)