【问题标题】:CircleCI upload to CodeCov cannot find coverage report?CircleCI 上传到 CodeCov 找不到覆盖率报告?
【发布时间】:2022-01-13 22:24:51
【问题描述】:

由于 TravisCI.org 不再对小型开源项目免费,我正在尝试设置 CircleCI 和 CodeCov。

在 CircleCI 中创建覆盖率报告似乎可行:

但是上传到CodeCov失败,找不到认领报告:

我按照https://circleci.com/docs/2.0/code-coverage/#codecov的说明进行操作

  • 使用orb codecov/codecov@1.0.2
  • 允许非私人球体
  • 使用 CircleCI 2.1
  • 生成 phpdbg
  • 我尝试使用 store_artificats 而没有,我不清楚这是否应该与 codecov 一起使用,但都失败了

那是我的 config.yml:

# PHP CircleCI 2.0 configuration file
# See: https://circleci.com/docs/2.0/language-php/
version: 2.1

orbs:
  codecov: codecov/codecov@1.0.2

# Define a job to be invoked later in a workflow.
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
jobs:
  build:
    # Specify the execution environment. You can specify an image from Dockerhub or use one of our Convenience Images from CircleCI's Developer Hub.
    # See: https://circleci.com/docs/2.0/configuration-reference/#docker-machine-macos-windows-executor
    docker:
      # Specify the version you desire here
      - image: circleci/php:7.2-node-browsers

      # Specify service dependencies here if necessary
      # CircleCI maintains a library of pre-built images
      # documented at https://circleci.com/docs/2.0/circleci-images/
      # Using the RAM variation mitigates I/O contention
      # for database intensive operations.
      # - image: circleci/mysql:5.7-ram
      #
      # - image: redis:2.8.19

    # Add steps to the job
    # See: https://circleci.com/docs/2.0/configuration-reference/#steps
    steps:
      - checkout

      - run: sudo apt update # PHP CircleCI 2.0 Configuration File# PHP CircleCI 2.0 Configuration File sudo apt install zlib1g-dev libsqlite3-dev
      - run: sudo docker-php-ext-install zip

      # Download and cache dependencies
      - restore_cache:
          keys:
            # "composer.lock" can be used if it is committed to the repo
            - v1-dependencies-{{ checksum "composer.json" }}
            # fallback to using the latest cache if no exact match is found
            - v1-dependencies-

      - run: composer install -n --prefer-dist

      - save_cache:
          key: v1-dependencies-{{ checksum "composer.json" }}
          paths:
            - ./vendor

      # run tests with phpunit or codecept
      #- run: ./vendor/bin/phpunit

      - run:
          name: "Run tests"
          command: phpdbg -qrr vendor/bin/phpunit --coverage-html build/coverage-report
      - codecov/upload:
          file: build/coverage-report

这是失败的构建:

https://app.circleci.com/pipelines/github/iwasherefirst2/laravel-multimail/25/workflows/57e6a71c-7614-4a4e-a7cc-53f015b3d437/jobs/35

【问题讨论】:

  • 您也可以添加test metadata,这样您就可以更好地查看失败的测试(在 CircleCI 中)。

标签: phpunit code-coverage circleci codecov


【解决方案1】:

Codecov 无法处理 HTML 覆盖率报告。您应该要求phpunit 输出 XML 以及通过更改或附加您的命令来读取--coverage-clover coverage.xml

您可以在https://docs.codecov.com/docs/supported-report-formats查看支持和不支持的覆盖格式列表

[1] 已保存https://web.archive.org/web/20220113142241/https://docs.codecov.com/docs/supported-report-formats

【讨论】:

  • 非常感谢!将其更改为上传coverage.xml 是一种改进,因为现在可以找到该文件,但我现在得到无效的请求参数:app.circleci.com/pipelines/github/iwasherefirst2/… 知道是什么原因造成的吗?
  • 我将不得不将您推荐给 community.codecov.com 以进行任何进一步的故障排除,但您似乎没有使用最新版本,并且令牌也以 -y 的形式传递,如果您查看正在生成的 URL。
  • 确定我会继续。谢谢。
  • 我刚刚升级了版本,现在可以了:)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-03-06
  • 2017-03-17
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多