Skip to content

Commit

Permalink
wip: ocular upload 2
Browse files Browse the repository at this point in the history
  • Loading branch information
mtvbrianking committed Apr 16, 2024
1 parent b84cd12 commit 8da634c
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 40 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/gen-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: gen-coverage

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
coverage:
runs-on: ubuntu-latest

name: Coverage

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, pcov
tools: composer:v2
coverage: pcov

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache composer dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
run: |
composer install --no-interaction --no-progress --prefer-dist --optimize-autoloader
- name: Create tests database
run: |
mkdir -p database
touch database/database.sqlite
- name: Execute tests, generate code coverage report
env:
DB_CONNECTION: sqlite
DB_DATABASE: database/database.sqlite
run: vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover

- name: Upload code coverage report
run: |
composer global require scrutinizer/ocular
composer global config --list | grep "vendor-dir"
~/.composer/vendor/bin/ocular code-coverage:upload --format=php-clover coverage.clover
41 changes: 1 addition & 40 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,43 +64,4 @@ jobs:
env:
DB_CONNECTION: sqlite
DB_DATABASE: database/database.sqlite
run: vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover

- name: Save code coverage report
uses: actions/upload-artifact@v4
with:
name: coverage
path: coverage.clover
overwrite: true

coverage:
needs: tests

runs-on: ubuntu-latest

strategy:
fail-fast: true
matrix:
php: [8.2]

name: Coverage P${{ matrix.php }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}

- name: Retrieve code coverage report
uses: actions/download-artifact@v4
with:
name: coverage

- name: Upload code coverage report
run: |
composer global require scrutinizer/ocular
composer global config --list | grep "vendor-dir"
~/.composer/vendor/bin/ocular code-coverage:upload --format=php-clover coverage.clover
run: vendor/bin/phpunit

0 comments on commit 8da634c

Please sign in to comment.