danger / danger-js

⚠️ Stop saying "you forgot to …" in code review
http://danger.systems/js/
MIT License
5.26k stars 368 forks source link

[BUG] Inline comments deleted in GitLab pipeline #1380

Closed Xiaobo2020 closed 1 year ago

Xiaobo2020 commented 1 year ago

Describe the bug

I need both normal comment and maybe inline comment.

To Reproduce Steps to reproduce the behavior:

  1. write an inline comment message in dangerfile.js. e.g. message("inline comment", "package.json", 1)
  2. write a normal comment message in dangerfile.js. e.g. message("normal comment")
  3. make a merge request in Gitlab and let pipeline run
  4. only show inline comment or normal comment.

Expected behavior

Both comments should display

Screenshots

image

Your Environment

software version
danger.js 11.2.6
node 16.14.0
npm 8.3.1
Operating System MacOS
orta commented 1 year ago

I dont know if gitlab have the same constraints as github - but inline comments there can only be added to files in the diff. So if the package.json line one is not changed, then it would show up in the main body

Xiaobo2020 commented 1 year ago

Hi @orta . Here you can think that there are some changes in package.json. So theoretically inline comment should show up. But I found some instructions about Danger in gitlab. It is mentioned that danger will only post one comment, I am not sure if this is related to the problem I am encountering. https://docs.gitlab.com/ee/development/dangerbot.html#danger-comments-in-merge-requests

orta commented 1 year ago

That's Danger in Ruby, so it has different constraints. Without being able to show a repro, there's not much I can tell you - I'd recommend running with DEBUG=true or -verbose and looking into what its sending then sending us a PR with what you think should fix it

Xiaobo2020 commented 1 year ago

I try to run DEBUG='*' npx danger ci -v -f in my gitlab pipeline. Through the printed information, I did find a strange phenomenon. It seems that danger did create an inline comment through createMergeRequestDiscussion, but then the inline comment was deleted.

Create Delete
image image

This is my dangerfile.js and I'm sure there are some diff in both file.

message('@xiaobo_wang inline comment', 'danger/tools/rules/common/mrDescription.js', 19);
message('@xiaobo_wang inline comment', 'package.json', 35);

These two inline comments have the same performance, first created and then deleted

Xiaobo2020 commented 1 year ago

I think I can use --newComment and --removePreviousComments to avoid this issue. But it indeed exists in GitLab. BTW, I found another bug about createComment called in Executor.ts.

glensc commented 1 year ago

Re-created https://github.com/danger/danger-js/pull/1381 PR using review notes: