Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change codecov reports from auto comment to file outputs #26

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

HackingGate
Copy link

@HackingGate HackingGate commented Jun 18, 2021

Changes

Stop comment to pull requests and commits but output the HTML body as a file instead.
Default output path is ./coverage/body.html.

Why

  1. This gives user more control of it.
  2. Less error-prone? (I got Bad credentials error before I create a fork. Move to actions/github-script solved my issue. Possible same issue found on Bad credentials error on POST #25)

How to try this pull request

- uses: HackingGate/lcov-reporter-action@7bf132b5f872f17fde607a37b7ca2308510abbb4

In your GitHub Workflow YAML file.

How to create a pull_request or commit comment

For example use actions/github-script.

This is the GitHub Workflow YAML I currently in use. Add it after HackingGate/lcov-reporter-action.

- uses: actions/github-script@v4
      with:
        script: |
          fs = require('fs');
          fs.readFile('./coverage/body.html', 'utf8', function (error,data) {
            if (error) {
              console.log(error)
            }
            if (context.eventName === "pull_request") {
              github.issues.createComment({
                issue_number: context.issue.number,
                owner: context.repo.owner,
                repo: context.repo.repo,
                body: data
              })
            } else if (context.eventName === "push") {
              github.repos.createCommitComment({
                commit_sha: context.sha,
                owner: context.repo.owner,
                repo: context.repo.repo,
                body: data
              })
            }
          });

@HackingGate HackingGate changed the title Change report from auto comment to an output file Change codecov reports from auto comment to file outputs Jun 18, 2021
@vitaliimelnychuk
Copy link

@romeovs @HackingGate Hello!

I am having the same problems in the https://github.com/barecheck/code-coverage-action. I also recently added a bunch of features and trying to support action for my projects.

I already created an application where we can request all needed access to make a comment for a specific commit. If you're interested, you can take a look at the action and collaborate there.

So far, we have barecheck/code-coverage-action#47 this request and I am going to start working on it. If you have any comments what would be useful for you to see inside the comment for 'push' events, let me know.

Thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants