Skip to content

CI: Fix uploading code coverage reports to Codecov #200

CI: Fix uploading code coverage reports to Codecov

CI: Fix uploading code coverage reports to Codecov #200

Workflow file for this run

name: Tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
# Allow job to be triggered manually.
workflow_dispatch:
# Cancel in-progress jobs when pushing to the same branch.
concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.ref }}
jobs:
tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ 'ubuntu-latest' ] #, macos-latest, windows-latest ]
php-version: [ '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ]
name: PHP ${{ matrix.php-version }} on OS ${{ matrix.os }}
steps:
- name: Acquire sources
uses: actions/checkout@v3
with:
fetch-depth: 2
# With GHA's "services", you cannot map volumes to your codebase BEFORE checking out the codebase.
# So, let's use `docker-compose` to bring in services AFTER checking out the code.
# https://github.community/t/services-and-volumes/16313
- name: Run CrateDB
run: docker-compose --file test/provisioning/docker-compose.yml up --detach
# https://github.com/marketplace/actions/setup-php-action
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
tools: composer, phpunit:^9.5
- uses: ramsey/composer-install@v2
- name: Run code style checks
run: composer run check-style
- name: Run tests
run: composer run test
# https://github.com/codecov/codecov-action
- name: Upload coverage results to Codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
files: ./build/logs/clover.xml
flags: unittests
env_vars: OS,PYTHON
name: codecov-umbrella
fail_ci_if_error: true
if: always() && (matrix.php-version == '7.4' || startsWith(matrix.php-version, '8.'))
- name: Upload coverage results to Scrutinizer CI
if: always() && (matrix.php-version == '7.4' || startsWith(matrix.php-version, '8.'))
run: |
echo "Git HEAD ref:"
git log --pretty=%P -n1 HEAD
composer global require scrutinizer/ocular
ocular code-coverage:upload --format=php-clover build/logs/clover.xml
# https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#failure
# https://github.community/t/how-do-i-get-the-logs-for-a-service/16422
- name: The job has failed
if: failure()
run: docker-compose --file test/provisioning/docker-compose.yml logs