Skip to content

Commit f8cabab

Browse files
committed
ci: separate code coverage report to a separate workflow
1 parent 29bdeb3 commit f8cabab

2 files changed

Lines changed: 99 additions & 12 deletions

File tree

.github/workflows/coverage.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Coverage
2+
3+
on:
4+
# Run testing on all push and pull requests that have committed changes in PHP files
5+
push:
6+
paths:
7+
- '**/*.php'
8+
pull_request:
9+
paths:
10+
- '**/*.php'
11+
# Make it possible to run the workflow manually
12+
workflow_dispatch:
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
coverage:
19+
20+
runs-on: ubuntu-latest
21+
22+
name: Code coverage report
23+
24+
steps:
25+
26+
#- name: Configure operating system
27+
# run: sudo apt-get update && sudo apt-get install -y locales locales-all
28+
29+
- name: Checkout code
30+
uses: actions/checkout@v6.0.2
31+
with:
32+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
33+
34+
- name: Setup Node.js
35+
uses: actions/setup-node@v4
36+
with:
37+
node-version: '20'
38+
cache: 'npm'
39+
40+
- name: Cache Playwright browsers
41+
id: playwright-cache
42+
uses: actions/cache@v3
43+
with:
44+
path: ~/.cache/ms-playwright
45+
key: playwright-${{ runner.os }}-latest
46+
restore-keys: |
47+
playwright-${{ runner.os }}-latest
48+
playwright-${{ runner.os }}-
49+
50+
- name: Install and update Playwright
51+
run: |
52+
if [ ! -d ~/.cache/ms-playwright ]; then
53+
npm install playwright@latest
54+
npx playwright install --with-deps
55+
fi
56+
57+
- name: Validate composer.json and composer.lock
58+
run: composer validate --strict
59+
60+
- name: Cache Composer packages
61+
id: composer-cache
62+
uses: actions/cache@v5.0.5
63+
with:
64+
path: vendor
65+
key: coverage-${{ hashFiles('**/composer.lock') }}
66+
67+
- name: Setup PHP
68+
uses: shivammathur/setup-php@v2
69+
with:
70+
php-version: '8.3'
71+
coverage: xdebug
72+
extensions: mbstring, gd, intl, pcntl
73+
74+
- name: Install dependencies
75+
run: composer update --prefer-dist --no-progress --prefer-stable
76+
77+
- name: Setup testbench environment
78+
run: |
79+
cp workbench/.env.example workbench/.env
80+
sed -i 's/APP_KEY=/APP_KEY=base64:ZQvPGC7uVADkjOgtGIIuCI8u3\/Pzu+VaRObIbHsgjCc=/' workbench/.env
81+
sed -i 's/APP_ENV=local/APP_ENV=testing/' workbench/.env
82+
grep "APP_KEY=base64:" workbench/.env
83+
npm install
84+
php vendor/bin/testbench vendor:publish --tag='filament-shield-config'
85+
php vendor/bin/testbench filament:assets
86+
php vendor/bin/testbench package:sync-skeleton
87+
88+
- name: Run test suite with coverage
89+
run: vendor/bin/pest --coverage-clover ./coverage.xml
90+
91+
- name: Upload coverage reports to Codecov
92+
uses: codecov/codecov-action@v6.0.0
93+
env:
94+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
95+
with:
96+
files: ./coverage.xml
97+
verbose: true

.github/workflows/test-runner.yml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ jobs:
8484
uses: shivammathur/setup-php@v2
8585
with:
8686
php-version: ${{ matrix.php }}
87-
coverage: xdebug
87+
coverage: none
8888
extensions: mbstring, gd, intl, pcntl
8989

9090
- name: Install dependencies
@@ -105,14 +105,4 @@ jobs:
105105
php vendor/bin/testbench package:sync-skeleton
106106
107107
- name: Run test suite
108-
run: vendor/bin/pest --shard=${{ matrix.shard }}/4 --parallel --coverage-clover ./coverage.xml
109-
110-
- name: Upload coverage reports to Codecov
111-
# Make sure the Codecov action is only executed once
112-
if: matrix.php == '8.3' && matrix.laravel == '12.*' && matrix.dependency-version == 'prefer-stable' && matrix.shard == 1
113-
uses: codecov/codecov-action@v6.0.0
114-
env:
115-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
116-
with:
117-
files: ./coverage.xml
118-
verbose: true
108+
run: vendor/bin/pest --shard=${{ matrix.shard }}/4 --parallel

0 commit comments

Comments
 (0)