是否有可能在 GitHub 拉取请求检查中显示漂亮的 html 报告(来自 Jest、Mocha、Cypress、测试覆盖率等测试运行器)?
也许不是解决方案,而是解决方法。 GitHub Actions 有下一个动作:
actions/upload-artifact
https://github.com/actions/upload-artifact
因此您可以将报告导出为工件,然后下载它们。可能如果它是公共回购,你可以通过 API 下载它们,但没有开箱即用的东西......祝你好运......
这可能会解决您的问题: https://github.com/marketplace/actions/html-preview
- name: HTML Preview
id: html_preview
uses: pavi2410/html-preview-action@v2
with:
html_file: 'index.html'
它似乎正在使用这个(https://github.com/htmlpreview/htmlpreview.github.com),所以它可能不适用于私人回购。
是否有可能在 GitHub 拉取请求检查中显示漂亮的 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 }}
但这是从 GitHub 触发第三方工具,并将结果提供给所述工具。
你不会在 PR 检查中得到相同的结果。
您是否有机会通过工作摘要完成您正在寻找的东西?
https://github.blog/2022-05-09-supercharging-github-actions-with-job-summaries/
如果您在实际 PR 中需要一些东西,可以编写您自己的 Github Action,它将根据您确定的数据进行评论/更新。看看Github Actions Toolkit,具体
@actions/github
: