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

Couldn't fetch access token for Github application #172

Open
dguettler opened this issue Apr 22, 2022 · 19 comments
Open

Couldn't fetch access token for Github application #172

dguettler opened this issue Apr 22, 2022 · 19 comments
Assignees
Labels
bug Something isn't working

Comments

@dguettler
Copy link

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 vitaliimelnychuk self-assigned this Apr 26, 2022
@vitaliimelnychuk vitaliimelnychuk added the bug Something isn't working label Apr 26, 2022
@vitaliimelnychuk
Copy link
Member

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
Copy link
Author

dguettler commented Apr 26, 2022 via email

@vitaliimelnychuk
Copy link
Member

Thanks for your feedback @dguettler.

I am sorry you have faced those problems with action.

I already fixed the issue here #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
Copy link
Member

Hello @dguettler!

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

@andrey-sheremeta
Copy link

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
Copy link
Member

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
Copy link
Author

dguettler commented May 16, 2022 via email

@vitaliimelnychuk
Copy link
Member

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
Copy link
Author

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
Copy link
Author

dguettler commented May 16, 2022

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
Copy link
Member

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
Copy link
Author

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

@vitaliimelnychuk
Copy link
Member

Hello @dguettler!

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

@andrey-sheremeta
Copy link

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
Copy link
Member

Hey @andrey-sheremeta!

It's really weird. I just added PR to test #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
Copy link

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
Copy link
Member

@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
Copy link
Author

dguettler commented Oct 11, 2022 via email

@vitaliimelnychuk
Copy link
Member

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 #172 (comment)

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants