barecheck / code-coverage-action

GitHub Action that generates code coverage reports
https://barecheck.com
MIT License
57 stars 14 forks source link

Couldn't fetch access token for Github application #172

Open dguettler opened 2 years ago

dguettler commented 2 years ago

Hi,

I followed the instructions, created a token, made it available as a secret in the application, but I'm running into this error

(node:6456) UnhandledPromiseRejectionWarning: Error: Couldn't fetch access token for Github application. Check if you use the correct `BARECHECK_GITHUB_APP_TOKEN`
    at createGithubAccessToken (/actions-runner/_work/_actions/barecheck/code-coverage-action/v0.6.1/dist/index.js:11291:11)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async createNewAccessToken (/actions-runner/_work/_actions/barecheck/code-coverage-action/v0.6.1/dist/index.js:11011:21)

Any idea what is going wrong here?

Thank you.

vitaliimelnychuk commented 2 years ago

Hello @dguettler!

I am sorry for the issue we have with that version of barecheck. Can you please update barecheck github action to v1?

Like here: barecheck/code-coverage-action@v1. I will update all docs to use proper version.

dguettler commented 2 years ago

Hi,

I updated the version, now the error changed to

Error: Couldn't fetch accessToken token by using apiKey. Check if you use
the correct `API_KEY`

Do I need to change the environment secret name?

Thanks, Daniel

On Tue, Apr 26, 2022 at 4:15 AM Vitalii Melnychuk @.***> wrote:

Hello @dguettler https://github.com/dguettler!

I am sorry for the issue we have with that version of barecheck. Can you please update barecheck github action to v1?

Like here: @.*** I will update all docs to use proper version.

— Reply to this email directly, view it on GitHub https://github.com/barecheck/code-coverage-action/issues/172#issuecomment-1109492065, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAAP7SDROGD5KNBZRM2JDDVG6QZFANCNFSM5UDKQGCA . You are receiving this because you were mentioned.Message ID: @.***>

vitaliimelnychuk commented 2 years ago

Thanks for your feedback @dguettler.

I am sorry you have faced those problems with action.

I already fixed the issue here https://github.com/barecheck/code-coverage-action/pull/175. You don't need to update anything, just run your workflow once more and it should pass and post a comment.

You always are able to use https://www.barecheck.com/ to store results and make comparison with previous executions but it's not required.

Let me know if you still experiencing any issues.

vitaliimelnychuk commented 2 years ago

Hello @dguettler!

Do you still have the issue with action after running action one more time?

andrey-sheremeta commented 2 years ago

Hi @vitaliimelnychuk.

Thanks a lot for a great job.

I also faced the similar issue. we used v.0.51 for a while, but the last week it stopped posting the summary commit, after upgrading to v1 (barecheck/code-coverage-action@v1), it throws the error

Error: Couldn't fetch accessToken token by using appToken. Check if you use the correct `BARECHECK_APP_KEY`

image

I tried to rerun the job several times, but it did not help.

Could you please help with this?

vitaliimelnychuk commented 2 years ago

Hello @andrey-sheremeta!

I released v1 as a stable version and will deprecate all previous releases soon. I am sorry that you faced the issue with the old version.

Can you please try to uninstall and install the application again to get a new token to post comments?

If it will not help please send here your config of the action. I am more than happy to fix the issue you're facing.

dguettler commented 2 years ago

No the action did run thank you. I think though that it doesn’t do anything unless I also provide a base coverage report. Is this assumption correct?

On Sat, Apr 30, 2022 at 7:48 AM Vitalii Melnychuk @.***> wrote:

Hello @dguettler https://github.com/dguettler!

Do you still have the issue with action after running action one more time?

— Reply to this email directly, view it on GitHub https://github.com/barecheck/code-coverage-action/issues/172#issuecomment-1113974306, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAAP7TJK47TITD4P5XCZNTVHUMYHANCNFSM5UDKQGCA . You are receiving this because you were mentioned.Message ID: @.***>

vitaliimelnychuk commented 2 years ago

Hello @dguettler!

If you don't have the base coverage report passed it should still post a comment with all uncovered lines but without the comparison part.

It usually helps to pass base coverage reports or use Barecheck cloud to have diff in percentages.

dguettler commented 2 years ago

Hi @vitaliimelnychuk

this is what I currently get in the logs

Run barecheck/code-coverage-action@v1
  with:
    barecheck-github-app-token: ***
    lcov-file: coverage/lcov.info
    show-annotations: warning
lcov-file: coverage/lcov.info
Current code coverage: NaN%
Base branch code coverage: 0%
Code coverage diff: NaN%
Code coverage diff: NaN%
minimum-ratio: NaN
minimum-ratio is disabled for this workflow
Show annotations feature enabled

There is no comment, but I'm also just testing this on a PR which only adds the check. So not sure if this is or isn't the expected outcome.

dguettler commented 2 years ago

This is on a 2nd project

Run barecheck/code-coverage-action@v1
  with:
    barecheck-github-app-token: ***
    lcov-file: ./osl.info
    show-annotations: warning
lcov-file: ./osl.info
Current code coverage: 33.99%
Base branch code coverage: 0%
Code coverage diff: 33.99%
Code coverage diff: 33.99%
minimum-ratio: NaN
minimum-ratio is disabled for this workflow
Show annotations feature enabled

again, no comment. Only change in the PR is adding the actions to run the check.

vitaliimelnychuk commented 2 years ago

It's strange that you have NaN% current code coverage. Can you check if the file is properly fulfilled with Lcov data rows?

Another thing, what do you pass as barecheck-github-app-token? Is it a token received after the Barecheck application installation?

dguettler commented 2 years ago

I'll check on the file. Yes it's the token received after installation.

vitaliimelnychuk commented 2 years ago

Hello @dguettler!

Maybe you can also try to uninstall/install Barecheck application to make sure that token is valid.

andrey-sheremeta commented 2 years ago

Hi @vitaliimelnychuk

We reinstalled the Barecheck application and updated the token, but it did not help.

attach the config of the action, so you can review it:

name: Test Coverage Check

on: [pull_request]

jobs:
  base_branch_cov:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [14.x]

    steps:
      - uses: actions/checkout@v2
        with:
          ref: ${{ github.base_ref }}
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v1
        with:
          node-version: ${{ matrix.node-version }}

      - run: yarn
      - run: yarn test:coverage-cli-report

      - name: Upload code coverage for ref branch
        uses: actions/upload-artifact@v2
        with:
          name: ref-lcov.info
          path: ./coverage/lcov.info

  checks:
    runs-on: ubuntu-latest
    needs: base_branch_cov
    steps:
      - uses: actions/checkout@v2
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v1
        with:
          node-version: ${{ matrix.node-version }}

      - name: Download code coverage report from base branch
        uses: actions/download-artifact@v2
        with:
          name: ref-lcov.info

      - run: yarn
      - run: yarn test:coverage-cli-report

      #  Compares two code coverage files and generates report as a comment
      - name: Generate Code Coverage report
        id: code-coverage
        uses: barecheck/code-coverage-action@v1
        with:
          barecheck-github-app-token: ${{ secrets.BARECHECK_GITHUB_APP_TOKEN }}
          lcov-file: './coverage/lcov.info'
          base-lcov-file: './lcov.info'
          minimum-ratio: 10 # Fails Github action once code coverage is decreasing
          show-annotations: 'warning' # Possible options warning|error

Thanks.

vitaliimelnychuk commented 2 years ago

Hey @andrey-sheremeta!

It's really weird. I just added PR to test https://github.com/barecheck/code-coverage-action/pull/184 and it looks fine, not sure what is different on your side. I also did regenerate a token and updated secret with a new one?

You've got the token from here, right?

Screenshot 2022-05-19 at 09 14 39
andrey-sheremeta commented 2 years ago

yes, right. we removed and installed the app several times but it did not help. also, we found the sematic pull request stopped working for some reason as well. we think the problem is somewhere in our repo settings, so we will try to fix this issue by ourselves.

thanks a lot for the help.

vitaliimelnychuk commented 2 years ago

@andrey-sheremeta Sure, let me know if you will need any help. This is really weird that you have this access issue. Maybe, check if your secrets are passed properly.

dguettler commented 1 year ago

Wait, I have the barecheck-github-app-token configured, but it’s looking for barecheck-api-key, where is this one coming from?

On Tue, Apr 26, 2022 at 8:01 AM Daniel Guettler @.***> wrote:

Hi,

I updated the version, now the error changed to

Error: Couldn't fetch accessToken token by using apiKey. Check if you use
the correct `API_KEY`

Do I need to change the environment secret name?

Thanks, Daniel

On Tue, Apr 26, 2022 at 4:15 AM Vitalii Melnychuk < @.***> wrote:

Hello @dguettler https://github.com/dguettler!

I am sorry for the issue we have with that version of barecheck. Can you please update barecheck github action to v1?

Like here: @.*** I will update all docs to use proper version.

— Reply to this email directly, view it on GitHub https://github.com/barecheck/code-coverage-action/issues/172#issuecomment-1109492065, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAAP7SDROGD5KNBZRM2JDDVG6QZFANCNFSM5UDKQGCA . You are receiving this because you were mentioned.Message ID: @.***>

vitaliimelnychuk commented 1 year ago

Hello @dguettler! Hope you're doing well.

barecheck-github-app-token - Barecheck application token, received after application installation comment. Basically, this one is just to give access to the Barecheck GitHub application to post comments. You can receive this token after installing the application as I mentioned in the comment above https://github.com/barecheck/code-coverage-action/issues/172#issuecomment-1131383551

barecheck-api-key - Your project API_KEY generated from https://barecheck.com/. Use this property to avoid running coverage for the base branch. This is an optional field, but some people find it useful to use to avoid rerunning coverage for the base branch and keep historical data stored in Barecheck.

Let me know if this works for you

aodhgan commented 1 month ago

@andrey-sheremeta did you ever resolve this? having the same issue

devactivity-app[bot] commented 1 month ago

@aodhgan, ⭐3 XP earned, 🏆First Comment Added completed! Contribute more to raise your XP/Level, complete challenges for extra achievements! [Sign up for personal dashboard]

icon
vitaliimelnychuk commented 1 month ago

Hello @aodhgan,

I am not still aware with what exactly we're having issue here.

If you look into my comment above about using different tokens, what is the one you're using? if it's barecheck-api-key, did you try to regenerate it?