timkrase / phpunit-coverage-badge Goto Github PK
View Code? Open in Web Editor NEWGithub Action to create a static test coverage badge from PHPUnit reports and automatically commit and push it to the repository.
License: MIT License
Github Action to create a static test coverage badge from PHPUnit reports and automatically commit and push it to the repository.
License: MIT License
I got a error with GitHub push when I try to update the badge.
! [remote rejected] HEAD -> refs/pull/[6](https://github.com/****/bando/actions/runs/4231050905/jobs/7349093212#step:16:6)2/merge (shallow update not allowed) error: failed to push some refs to 'https://github.com/****/bando.git'
Exact same issue with the #11
My workflow is like so:
jobs:
laravel-tests:
runs-on: ubuntu-latest
steps:
- uses: shivammathur/setup-php@####
with:
php-version: '8.0'
- uses: actions/checkout@v3
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.example', '.env');"
- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: phpunit-coverage-badge
uses: timkrase/[email protected]
Only possible difference between #11 that I can see is: I use checkout@v3 opposed to the documentaion which demonstrates with checkout@v2. Or maybe it is the PHP version that is causing the problem. Either way I'm confused.
I also attempted it by giving your action report
parameter for clover file, no chance.
Can you help me with this ? Thanks.
Update: changed actions/checkout@v3
usage to actions/checkout@v2
, made no visible difference, still got the same error: Fatal error: Uncaught Assert\InvalidArgumentException: File "/github/workspace/clover.xml" was expected to exist. in /srv/vendor/beberlei/assert/lib/Assert/Assertion.php:2725
Hi, I tried implementing your work in my github action. The build passes succesfuly, unfortunatly I don't get a badge.svg in my repo at the end. I looked in the action log when I call your action and you can find bellow what it tells me. You can also find my configuration for the action. It seams like it doesn't push the commit or doesn't make the commit.
array(17) {
[0]=>
string(9) "total 300"
[1]=>
string(46) "drwxr-xr-x 3 1001 116 4096 Jan 27 20:49 bin"
[2]=>
string(53) "-rw-r--r-- 1 root root 8326 Jan 27 20:50 clover.xml"
[3]=>
string(56) "-rw-r--r-- 1 1001 116 1950 Jan 27 20:48 composer.json"
[4]=>
string(56) "-rw-r--r-- 1 1001 116 226688 Jan 27 20:48 composer.lock"
[5]=>
string(49) "drwxr-xr-x 5 1001 116 4096 Jan 27 20:48 config"
[6]=>
string(61) "-rw-r--r-- 1 root root 1823 Jan 27 20:50 coverage_badge.svg"
[7]=>
string(49) "drwxr-xr-x 4 1001 116 4096 Jan 27 20:49 docker"
[8]=>
string(61) "-rw-r--r-- 1 1001 116 733 Jan 27 20:48 docker-compose.yml"
[9]=>
string(53) "drwxr-xr-x 2 1001 116 4096 Jan 27 20:48 migrations"
[10]=>
string(59) "-rw-r--r-- 1 1001 116 1127 Jan 27 20:48 phpunit.xml.dist"
[11]=>
string(49) "drwxr-xr-x 2 1001 116 4096 Jan 27 20:48 public"
[12]=>
string(46) "drwxr-xr-x 7 1001 116 4096 Jan 27 20:48 src"
[13]=>
string(55) "-rw-r--r-- 1 1001 116 9141 Jan 27 20:48 symfony.lock"
[14]=>
string(48) "drwxr-xr-x 4 1001 116 4096 Jan 27 20:48 tests"
[15]=>
string(46) "drwxr-xr-x 2 root root 4096 Jan 27 20:49 var"
[16]=>
string(49) "drwxr-xr-x 2 root root 4096 Jan 27 20:49 vendor"
}
array(17) {
[0]=>
string(9) "total 204"
[1]=>
string(54) "-rw-r--r-- 1 root root 406 Jan 25 20:22 Dockerfile"
[2]=>
string(54) "-rw-r--r-- 1 root root 1066 Jan 25 20:22 LICENSE.md"
[3]=>
string(53) "-rw-r--r-- 1 root root 3660 Jan 25 20:22 README.md"
[4]=>
string(54) "-rw-r--r-- 1 root root 2975 Jan 25 20:22 action.yml"
[5]=>
string(53) "-rw-r--r-- 1 root root 1825 Jan 25 20:22 badge.svg"
[6]=>
string(54) "-rw-r--r-- 1 root root 14548 Jan 25 20:22 clover.xml"
[7]=>
string(57) "-rw-r--r-- 1 root root 1168 Jan 25 20:22 composer.json"
[8]=>
string(57) "-rw-r--r-- 1 root root 134569 Jan 25 20:22 composer.lock"
[9]=>
string(57) "-rwxr-xr-x 1 root root 63 Jan 25 20:22 entrypoint.sh"
[10]=>
string(55) "-rw-r--r-- 1 root root 1143 Jan 25 20:22 phpunit.xml"
[11]=>
string(53) "-rw-r--r-- 1 root root 444 Jan 25 20:22 psalm.xml"
[12]=>
string(55) "-rw-r--r-- 1 root root 1751 Jan 25 20:22 ruleset.xml"
[13]=>
string(47) "drwxr-xr-x 4 root root 4096 Jan 27 20:46 src"
[14]=>
string(56) "-rw-r--r-- 1 root root 1837 Jan 25 20:22 template.svg"
[15]=>
string(49) "drwxr-xr-x 4 root root 4096 Jan 27 20:46 tests"
[16]=>
string(50) "drwxr-xr-x 31 root root 4096 Jan 27 20:48 vendor"
}
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not in a git directory
fatal: not in a git directory
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
uses: timkrase/[email protected]
with:
push_badge: true
repo_token: ${{ secrets.GITHUB_TOKEN }}
Unfortunately I can't get phpunit-coverage-badge
working, running the action always results in a
Could not open input file: src/entry.php
error. I'm a GitHub Actions beginner, so maybe I just do it wrong.
Here's my workflow config: https://github.com/PhrozenByte/phpunit-throwable-asserts/blob/master/.github/workflows/coverage.yml
And here's a failing run: https://github.com/PhrozenByte/phpunit-throwable-asserts/runs/1757698367#step:7:12
Since today github actions is failing on pulling the docker image used by this package:
Pull down action image 'ghcr.io/timkrase/phpunit-coverage-badge:v1.0.0'
error pulling image configuration: download failed after attempts=1: unauthorized: unauthenticated: User cannot be authenticated with the token provided.
If I do this locally in the terminal I get the exact same error:
docker pull ghcr.io/timkrase/phpunit-coverage-badge:v1.0.0
v1.0.0: Pulling from timkrase/phpunit-coverage-badge
a076a628af6f: Pulling fs layer
02bab8795938: Pulling fs layer
657d9d2c68b9: Pulling fs layer
f47b5ee58e91: Waiting 6973310537d6: Waiting
14f6cef0315a: Waiting
7d47eb8061bd: Waiting
d589d3e69c54: Waiting
b48640c33bd0: Waiting
d0d8b74f2359: Waiting
85b5ac56f36e: Waiting
80800994fbe4: Waiting
33c4db1512e5: Waiting
3458fab7e2da: Waiting
cc34d1f1f826: Waiting
error pulling image configuration: unauthorized: unauthenticated: User cannot be authenticated with the token provided.
Did something break?
Hi Tim,
Thank you for the nice action, I would suggest adjusting the readme a bit to make it easier to use. Let me explain, now on every push, the action runs, creates the badge and makes a new commit on the master branch. That's causing some problems because I always need to pull the latest changes from remote before I can push (I use git pull --rebase for that purpose).
There's another possibility which doesn't create that problem:
- name: Make code coverage badge
uses: timkrase/[email protected]
with:
coverage_badge_path: output/coverage.svg
# push badge later on
push_badge: false
- name: Git push to image-data branch
uses: peaceiris/actions-gh-pages@v3
with:
publish_dir: ./output
publish_branch: image-data
github_token: ${{ secrets.GITHUB_TOKEN }}
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
Commiting that the badge is changing is triggering github actions to run again. I don't know if you can configure that in your github action but maybe adding documentation may do the job. I found that if you add the following line and you add [ci skip] in your commit then it might skip the github action.
jobs:
build:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[ci skip]')"
Hello, I'm trying to use the action but alway I got the below message.
The clover.xml file is in the root project.
Can anyone cal help me?
Bye
Fatal error: Uncaught Assert\InvalidArgumentException: File "/github/workspace/clover.xml" was expected to exist. in /srv/vendor/beberlei/assert/lib/Assert/Assertion.php:2725
Stack trace:
#0 /srv/vendor/beberlei/assert/lib/Assert/Assertion.php(1604): Assert\Assertion::createException('/github/workspa...', 'File "/github/w...', 102, NULL)
#1 /srv/src/Config.php(32): Assert\Assertion::file('/github/workspa...')
#2 /srv/src/WorkflowService.php(26): PhpUnitCoverageBadge\Config->__construct()
#3 /srv/src/entry.php(15): PhpUnitCoverageBadge\WorkflowService->run()
#4 {main}
thrown in /srv/vendor/beberlei/assert/lib/Assert/Assertion.php on line 2725
Hi @timkrase
I've tried to implement this action with the Moodle GHA workflow. But it always gives this failure https://github.com/adpe/moodle-local_pluginsfetcher/runs/2149406206?check_suite_focus=true#step:19:1.
Can you help out?
Thanks
Adrian
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.