-
-
Notifications
You must be signed in to change notification settings - Fork 362
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
Is Danger always making a new comment? #856
Comments
I am also seeing this. I'm using I can inspect each comment's markdown and see the same I was also under the impression that it should search all the comments for ones with the same |
Same for me, adding a new comment every time |
Same for me in Bitbucket Cloud, any updates or any leads how can we solve this? |
Each platform has a
|
For |
That doesn't feel right to me - the bot should be able to ask for it's own user ID via the API and it likely does |
Yes, that's right, I've never thought about that before. |
I had set it as mentioned in the documentation. And yes it is in the format as mentioned by you |
We've just released version 9.2.9, could you remove I suspect that this issue would have something to do with brackets, some CI might encode it. At 9.2.9, we fetch UUID from Bitbucket Cloud Instead, and it works fine for me. |
Seems to be fixed and danger is now updating the comments in bitbucket cloud. Tested with |
It still creates new comments on Github |
Assumption: the version hosted in the GitHub action might have a bug when it comes to sticky messages. See danger/danger-js#856. Trying this to see if the latest version of the package itself has the same behavior or not.
Same as @zhongliangwang, I'm seeing new comments on GitHub as well. I made a dedicated repo to reproduce 👉 mokagio/danger-new-comments-example#3. I tried to fetch Danger JS from |
I made a new test, mokagio/danger-new-comments-example#5, with a import {warn} from "danger";
warn("This demo warning was generated on " + new Date()); Same result. |
FWIW, the Ruby version doesn't have this issue. See mokagio/danger-new-comments-example#6. |
I did a bit more investigation, and saw that Danger JS also makes multiple comments when given |
Interesting! Yeah, that check and update code was done before inline comments were added, and it makes sense why I rarely see it (I don't use multiline anywhere) My bet? the check to find the existing main comment might be hitting these and thinking there isn't an issue to update |
I think the reason why is doing multiple comments is that you are using GITHUB_TOKEN: ${{ secrets.MOKAGIO_BOT_GITHUB_TOKEN }} Try GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} Actions doesn't allow you to call (this is the response you get)
This is why the user id is hardcoded, then if you don't use the actions user danger can not understand which comment is the danger comment and edit it. |
It's possible that my understanding of how GitHub Actions secrets work and of which token to use if flawed. Maybe you need to use the same exact syntax as the Danger docs suggest? See danger/danger-js#856 (comment)
Hey @f-meloni, you're spot on! Once I changed the action Clearly, my understanding of what that token should have been was wrong. Or rather, I didn't spend enough time reading the docs. I though that the What I might do is open a PR to add the link to the Thanks again folks! ❤️ |
That's why we were seeing multiple comments. See: - danger/danger-js#856 (comment) - https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token
Hey @f-meloni, in your comment you mention
When you have time, could you point me to where in the code this happens? I don't understand how it ends up that even if I pass an |
What is hardcoded is the user id, not the danger id. |
Anyway, this is the code https://github.com/danger/danger-js/blob/master/source/platforms/github/GitHubAPI.ts#L133-L136 |
I use the It works well if I have Danger locally, but I'm having troubles with the GitHub Action. I've been experimenting with this yesterday. I'm probably doing something wrong, but it seems to me the Danger GitHub Action doesn't read the id. See this PR here for example. I'm calling - name: Run Consistency Checks
uses: danger/danger-js@9.1.8
with:
args: |
--dangerfile Automattic/peril-settings/org/pr/ios-macos.ts \
--id danger_id_same
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} But the resulting Danger comment has id |
Looks to me like the docker image for an action isn't respecting the args?
Was it definitely calling your dangerfile? |
Yes, it was. I made a commit to trigger a failure comment from Danger, and Danger posted it. |
Not understanding the GITHUB_TOKEN cost me a fair bit of time recently. Hopefully adding this link to the docs will save time to other people. See danger#856 (comment).
There are 2 ways one can provide Github Token to danger when using it on Github Actions:
When updating/deleting comments only the 1st case is being considered in the Github Actions env and the userId is never considered, instead a hardcoded ID is returned. danger-js/source/platforms/github/GitHubAPI.ts Lines 133 to 136 in 5ad5fd9
I think we should do that only if both the conditions are true, i.e.:
This would allow people to use method 2. (for whatever reasons) and it would still work properly. There would still be one case where it will fail and we probably can't detect it, just probably mention in docs not to use it this way
|
Yep, seems reasonable |
I keep seeing notifications in Slack about new comments by Danger, when they should be being edited.
The text was updated successfully, but these errors were encountered: