当代码覆盖率不是 100% 时,Github Action CI 应该会失败
我想检查 Github Action CI 中推送和拉取请求的代码覆盖率。我正在使用 Symfony。我找到了针对 Javascript 的操作,但没有找到针对 PHP 或基于 Symfony 的操作。
我已经创建了一个 GitHub 操作工作流程,如下所示:
name: Running Code Coverage
on: [push, pull_request]
jobs:
build:
name: Code Coverage
runs-on: ubuntu-latest
strategy:
matrix:
php-version: [8.1]
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_SECRET_TOKEN }}
fail_ci_if_error: true
files: ./coverage_report.xml
但我无法使用上述方法实现我的最终目标,因为它将代码覆盖率上传到 codecov,在那里我可以看到 %age。
我的目标是,当代码覆盖率低于 100% 等阈值时,CI 应该失败。
I want to check the code coverage percentage in the Github Action CI on push and pull requests. I'm using Symfony. I've found actions for Javascript but not for PHP or Symfony-based.
I've already created a GitHub action workflow which is as below:
name: Running Code Coverage
on: [push, pull_request]
jobs:
build:
name: Code Coverage
runs-on: ubuntu-latest
strategy:
matrix:
php-version: [8.1]
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_SECRET_TOKEN }}
fail_ci_if_error: true
files: ./coverage_report.xml
But I cannot achieve my end goal using the above as it uploads the code coverage to codecov and there I can see the %age.
My goal is that the CI should fail when the code coverage is below a threshold like 100%.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
参考关于阈值的官方文档:
以下是来自同一文档的示例
codecov.yml
引用:Referencing from the official docs on threshold:
Here is an example
codecov.yml
reference from the same docs: