GitHub Actions / GitHub pull requests 在 HTML 报告中显示

25
有没有可能在GitHub的拉取请求检查中显示漂亮的HTML报告(来自测试运行器,如Jest、Mocha、Cypress、测试覆盖率等)的方法?
4个回答

4

1

1
有没有可能在 GitHub pull requests checks 中显示漂亮的 HTML 报告(例如来自测试运行器,如 Jest、Mocha、Cypress、测试覆盖率等)?
2023 年第二季:不能以这种方式(从第三方工具到 GitHub PR 检查)
例如,cypress-io/github-action 允许通过 GitHub Action 触发测试,并以良好的形式呈现结果。
on: push
jobs:
  test:
    name: Cypress run
    runs-on: ubuntu-22.04
    strategy:
      # when one test fails, DO NOT cancel the other
      # containers, because this will kill Cypress processes
      # leaving Cypress Cloud hanging ...
      # https://github.com/cypress-io/github-action/issues/48
      fail-fast: false
      matrix:
        # run 3 copies of the current job in parallel
        containers: [1, 2, 3]
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      # because of "record" and "parallel" parameters
      # these containers will load balance all found tests among themselves
      - name: Cypress run
        uses: cypress-io/github-action@v5
        with:
          record: true
          parallel: true
          group: 'Actions example'
        env:
          # pass the Cypress Cloud record key as an environment variable
          CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
          # Recommended: pass the GitHub token lets this action correctly
          # determine the unique run id necessary to re-run the checks
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

https://github.com/cypress-io/github-action/raw/master/images/parallel.png

但这会触发来自GitHub的第三方工具,并获取该工具的结果。
您将无法在PR检查中获得相同的结果。


1
也许不是解决方案,但可以绕开问题。GitHub Actions有下一个动作:actions/upload-artifact https://github.com/actions/upload-artifact,因此您可以将报告导出为artifact,然后下载它们。如果是公共repo,则可能可以通过API下载它们,但没有开箱即用的解决方案...祝你好运...

嗨,马克斯,这个问题还有其他解决方法吗?还是一年后还是原来的样子? - Hamid Mayeli
1
没有什么,说实话 - Max Vinogradov

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接