有没有可能在GitHub的拉取请求检查中显示漂亮的HTML报告(来自测试运行器,如Jest、Mocha、Cypress、测试覆盖率等)的方法?
你有没有可能通过工作摘要实现你想要的功能?
https://github.blog/2022-05-09-supercharging-github-actions-with-job-summaries/
如果您需要在实际的PR中进行某些操作,可以编写自己的Github Action,根据您确定的数据进行评论/更新。请查看Github Actions Toolkit,特别是@actions/github
:
- name: HTML Preview
id: html_preview
uses: pavi2410/html-preview-action@v2
with:
html_file: 'index.html'
它似乎正在使用这个(https://github.com/htmlpreview/htmlpreview.github.com),所以它可能无法很好地与私有repos一起使用。
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检查中获得相同的结果。
actions/upload-artifact
https://github.com/actions/upload-artifact,因此您可以将报告导出为artifact,然后下载它们。如果是公共repo,则可能可以通过API下载它们,但没有开箱即用的解决方案...祝你好运...