|
| 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 |
0 commit comments