如何使用 Github Action 配置工作服? [英] How to configure Coveralls with Github Action?

查看:10
本文介绍了如何使用 Github Action 配置工作服?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 github 存储库配置出现问题.这是 -

  • 覆盖率信息在测试后向我显示的内容和工作服统计数据中显示的内容不同(即在工作服中显示FIRST BUILD ON DEVELOPER AT 90.072%,但根本没有这样的百分比!覆盖的行数为 93.43%,平均所有内容为 89.4%)
  • 无论我尝试更改,覆盖率徽章都是未知"
  • 我做错了什么,我应该怎么做才能解决这个问题?

    解决方案

    我也尝试了很多东西,最后,coverallsapp/github-action@v1.1.2 有帮助!现在我可以成功地将覆盖结果发布到coveralls.io

    不幸的是,直接的方法要么导致错误响应 422 - 找不到与此作业匹配的存储库";或来自 lcovParse 的错误:'无法解析字符串'".

    直截了当的方法(不起作用):

    - 名称:发布到 coveralls.io运行:cat ./coverage/lcov.info ||./node_modules/coveralls/bin/coveralls.js

    使用来自 GH 市场的 Actions 应用(工作):

    - 名称:发布到 coveralls.io用途:coverallsapp/github-action@v1.1.2和:github-token: ${{ github.token }}

    这是 工作 .yml配置,希望对其他人也有帮助.

    请记住,我需要覆盖的场景有点棘手,我们需要合并多个覆盖结果,然后将其用作单个输出结果到 coveralls.io.

    如果有人好奇,以下是我尝试过但失败的事情:

    • 使用 NODE_ENV 进行发布 -

      运行:NODE_ENV=test cat ./coverage/lcov.info |./node_modules/coveralls/bin/coveralls.js

    • 指定确切的节点版本11.8.0 及更高版本

    • 为步骤指定 github.token、repo 和 env:

    • 创建一个单独的 Github Actions 作业.

      使用:actions/setup-node@v1和:回购令牌:${{ github.token }}存储库:${{ github.repository }}GITHUB_TOKEN: ${{ github.token }}

    I'm experiencing problems with my github repo configuration. Here it is - umbress. I have Github Actions CI enabled and configured and I want to have the coverage badge in my repo so everyone who wants to use my code in their projects knows that my code is well-tested. But it seems that I missing something because my coverage badge has an "unknown" status for a long time already.

    CI steps are:

    1. Run build
    2. Run tests and generate coverage (jest --coverage --config config/jest.js). This will generate ./coverage/lcov.info in root directory
    3. Finally Coveralls GitHub Action should upload coverage to their website and display the results

    There are a few issues:

    1. When I run builds on pull requests, it says "First build" (but it's not, I've ran a lot of builds on this branch already)
    2. Coverage info is differs in what jest shows me after tests and what is displaying in Coveralls stats (i.e. in Coveralls it says FIRST BUILD ON DEVELOPER AT 90.072%, but there's no such percentage at all! Lines covered is 93.43% and everything in average is 89.4%)
    3. Coverage badge is "unknown" no matter I try to change

    What am I doing wrong and what should I do to fix this?

    解决方案

    I've tried many things as well and in the end, the usage of the coverallsapp/github-action@v1.1.2 helped! Now I can successfully publish the coverage results to coveralls.io

    Unfortunately, the straightforward approach was either leading to "Bad Response 422 - Couldn't find a repository matching this job" or "Error from lcovParse: 'Failed to parse string'".

    Straightforward approach (not working):

    - name: Publish to coveralls.io
      run: cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
    

    Using Actions app from GH marketplace (working):

    - name: Publish to coveralls.io
      uses: coverallsapp/github-action@v1.1.2
      with:
        github-token: ${{ github.token }}
    

    This is the working .yml configuration, hope it will help someone else as well.

    Keep in mind that the scenario that I needed to cover was a little bit tricky, we have multiple coverage results that needed to be combined and later on used as a single output result to coveralls.io.

    If someone is curious, here are the things that I've tried, but failed:

    • Use of NODE_ENV for publishing -

      run: NODE_ENV=test cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js

    • Specifying exact node version 11.8.0 and above

    • Specifying a github.token, repo and env for the steps:

    • Creating a separate Github Actions Job.

      uses: actions/setup-node@v1
      with:
        repo-token: ${{ github.token }}
        repository: ${{ github.repository }}
        GITHUB_TOKEN: ${{ github.token }}
      

    这篇关于如何使用 Github Action 配置工作服?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆