Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TASK] Move the coverage generation to a separate CI workflow #427

Merged
merged 3 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 2 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ jobs:
fail-fast: false
matrix:
php-version: [ '7.2', '7.3' ]
coverage: [ 'none' ]
include:
- php-version: '7.4'
coverage: xdebug

steps:
- name: Checkout
Expand All @@ -57,7 +53,7 @@ jobs:
php-version: ${{ matrix.php-version }}
ini-values: error_reporting=E_ALL
tools: composer:v2
coverage: "${{ matrix.coverage }}"
coverage: none
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What uses this? Is it possible to lose the coverage: none?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting coverage: none has the result of no code coverage tool (like Xdebug of PCOV) getting loaded, which should speed up the non-coverage tasks a bit.


- name: Show the Composer configuration
run: composer config --global --list
Expand All @@ -76,14 +72,7 @@ jobs:
composer show;

- name: Run Tests
run: ./vendor/bin/phpunit --coverage-clover build/coverage/xml

- name: Upload coverage results to Codacy
env:
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
if: "${{ matrix.coverage != 'none' && env.CODACY_PROJECT_TOKEN != '' }}"
run: |
./vendor/bin/codacycoverage clover build/coverage/xml
run: ./vendor/bin/phpunit

static-analysis:
name: Static Analysis
Expand Down
57 changes: 57 additions & 0 deletions .github/workflows/codecoverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions

on:
push:
branches:
- master
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the indentation wrong here? Something seems to preventing a match.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra spaces should not matter. It looks correct, so IDK why it's not working.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just rebased and repushed, an the coverage job seems to have run fine for me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't see a problem now, though the checks run this time have been the pull_request checks rather than the push checks. I'll approve and hopefully will see some checks run on 'push' from the merge.

Oh, I've just realized why the code coverage wasn't run - you're pushing to the task/coverage-separate branch, not master - it's only supposed to run on pushes to master. D'oh, sorry.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CI should have run for the pull_request trigger, though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CI should have run for the pull_request trigger, though.

Strange. When I reviewed last night, it definitely showed 12 succussful checks on 'push', rather than 13 on 'pull_request'. I wouldn't have spotted this potential problem otherwise.

pull_request:

name: Code coverage

jobs:
code-coverage:
name: Code coverage

runs-on: ubuntu-22.04

strategy:
matrix:
php-version: [ '7.4' ]

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

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
ini-values: error_reporting=E_ALL
tools: composer:v2
coverage: xdebug

- name: Show the Composer configuration
run: composer config --global --list

- name: Cache dependencies installed with composer
uses: actions/cache@v4
with:
path: ~/.cache/composer
key: php${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: |
php${{ matrix.php-version }}-composer-

- name: Install Composer dependencies
run: |
composer update --with-dependencies --no-progress;
composer show;

- name: Run Tests
run: ./vendor/bin/phpunit --coverage-clover build/coverage/xml

- name: Upload coverage results to Codacy
env:
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
if: "${{ env.CODACY_PROJECT_TOKEN != '' }}"
run: |
./vendor/bin/codacycoverage clover build/coverage/xml