From b53e082d536d3da6d04b6a478452f806f7939745 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 5 Jun 2019 12:03:19 -0700 Subject: [PATCH] Add support for codecov badge --- scripts/class-wordpress-readme-parser.php | 4 ++++ scripts/generate-markdown-readme | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/scripts/class-wordpress-readme-parser.php b/scripts/class-wordpress-readme-parser.php index 6f09b5d..de130fd 100644 --- a/scripts/class-wordpress-readme-parser.php +++ b/scripts/class-wordpress-readme-parser.php @@ -190,6 +190,7 @@ function ( $tag ) { 'travis_ci_pro_url', 'travis_ci_url', 'coveralls_url', + 'codecov_url', 'grunt_url', 'david_url', 'david_dev_url', @@ -213,6 +214,9 @@ function ( $tag ) { if ( 'coveralls_url' === $badge ) { $badge_md .= sprintf( '[![Coverage Status](%s)](%s) ', $params['coveralls_badge_src'], $url ); } + if ( 'codecov_url' === $badge ) { + $badge_md .= sprintf( '[![Coverage Status](%s)](%s) ', $params['codecov_badge_src'], $url ); + } if ( 'grunt_url' === $badge ) { $badge_md .= sprintf( '[![Built with Grunt](https://%1$s/cdn/builtwith.svg)](http://%1$s) ', $url ); } diff --git a/scripts/generate-markdown-readme b/scripts/generate-markdown-readme index d9ed504..c73fd0f 100755 --- a/scripts/generate-markdown-readme +++ b/scripts/generate-markdown-readme @@ -113,6 +113,11 @@ try { $md_args['coveralls_badge_src'] .= "&service=github&t=$coveralls_badge"; } } + if ( file_exists( $readme_root . '/codecov.yml' ) || file_exists( $readme_root . '/.codecov.yml' ) ) { + $branch = isset( $env_vars['DEFAULT_BASE_BRANCH'] ) ? $env_vars['DEFAULT_BASE_BRANCH'] : 'master'; + $md_args['codecov_url'] = "https://codecov.io/gh/$github_account_repo"; + $md_args['codecov_badge_src'] = "https://img.shields.io/codecov/c/github/$github_account_repo/$branch.svg"; + } if ( file_exists( $readme_root . '/Gruntfile.js' ) ) { $md_args['grunt_url'] = 'gruntjs.com'; }