changesets-gitlab icon indicating copy to clipboard operation
changesets-gitlab copied to clipboard

comment adds new comment with every commit

Open maxkarkowski opened this issue 1 year ago • 63 comments

since we updated changesets-gitlab we have now the issue that with every commit the changesets-gitlab comment command creates a new comment in our merge request. before the update it only created one comment for a merge request.

maxkarkowski avatar Nov 27 '23 14:11 maxkarkowski

Any screenshot?

Should be related to #138 or #143(most likely)

cc @alan910127

JounQin avatar Nov 27 '23 14:11 JounQin

Hello @maxkarkowski, are you upgraded from v0.11.0 or v0.10.x? This information can help me locate the issue faster 😄

alan910127 avatar Nov 27 '23 17:11 alan910127

hey @alan910127 sorry of course i can. we are currently on version 0.10.3

Update: update to latest version and the problem is still there

maxkarkowski avatar Nov 28 '23 07:11 maxkarkowski

Any screenshot?

Should be related to #138 or #143(most likely)

cc @alan910127

here is a screenshot screen

maxkarkowski avatar Nov 28 '23 07:11 maxkarkowski

but even if there is a changeset found, new comment will appear with everey command run SCR-20231128-idwj

maxkarkowski avatar Nov 28 '23 07:11 maxkarkowski

Hey @maxkarkowski, I couldn't reproduce the error on a project created on gitlab.com. Could you provide some information that might be related to this issue?

Here's something I think might be relevant:

alan910127 avatar Nov 29 '23 07:11 alan910127

@alan910127 I have the same problem, we are using a self-hosted instance of GitLab if that helps, but when I tested on gitlab.com I also did not get any error.

idumancic avatar Nov 29 '23 09:11 idumancic

@alan910127 I have the same problem, we are using a self-hosted instance of GitLab if that helps, but when I tested on gitlab.com I also did not get any error.

we are also using a self hosted gitlab

maxkarkowski avatar Nov 29 '23 09:11 maxkarkowski

Hey @maxkarkowski, I couldn't reproduce the error on a project created on gitlab.com. Could you provide some information that might be related to this issue?

Here's something I think might be relevant:

this is the comment job we have . it runs on every merge request

comment:
  rules:
    - if: '$CI_MERGE_REQUEST_IID && $CI_COMMIT_BRANCH != "changeset-release/main"'
  extends:
    - .init-pnpm
  script:
    - pnpm changesets-gitlab comment # comment automatically like https://github.com/changesets/bot
    
.init-pnpm:
  before_script:
    - corepack enable
    - corepack prepare [email protected] --activate
    - node --max-old-space-size=8192
    - pnpm config set store-dir .pnpm-store
    - pnpm install # install dependencies
  cache:
    key:
      files:
        - pnpm-lock.yaml
    paths:
      - .pnpm-store

maxkarkowski avatar Nov 29 '23 09:11 maxkarkowski

Got it. I will try to spin up a self-hosted GitLab instance and test the issue inside that. What's your GitLab version in case it helps?

alan910127 avatar Nov 30 '23 07:11 alan910127

Got it. I will try to spin up a self-hosted GitLab instance and test the issue inside that. What's your GitLab version in case it helps?

ist GitLab Community Edition v16.6.0

maxkarkowski avatar Nov 30 '23 15:11 maxkarkowski

I may have opportunity to test and debug this issue on our internal GitLab service today, I'll try to give a fix soon.


I'm meeting bigger issues...:

image

JounQin avatar Dec 04 '23 09:12 JounQin

@JounQin I have found that the /projects/:id/merge_requests/:merge_request_iid/diffs is only available on GitLab 15.7 or above. However, it's not documented very well though 😕, there is only a mention at the docs for changes API.

image

Reverting #143 could solve the 404 issue and potentially this issue as well.


Update:

Using [email protected] in a GitLab 13 instance does not have the issue of commenting repeatedly. So, reverting #143 should also solve this one, but there will always be a deprecation warning in the pipeline though 😅.

alan910127 avatar Dec 04 '23 15:12 alan910127

@maxkarkowski @idumancic It should be fixed in version 0.11.4, you can try it out!

Untitled

alan910127 avatar Dec 04 '23 18:12 alan910127

@maxkarkowski @idumancic It should be fixed in version 0.11.4, you can try it out!

Untitled

didnt fix it for me :/

maxkarkowski avatar Dec 05 '23 10:12 maxkarkowski

@maxkarkowski Please provide more details, such as GitLab instance version?

JounQin avatar Dec 05 '23 10:12 JounQin

@maxkarkowski Please provide more details, such as GitLab instance version?

it is still GitLab Community Edition v16.6.0. ;) i just updated to the newest version of changesets-gitlab. the pipeline then executes pnpm changesets-gitlab comment . i first commited without a changeset. then i added a changeset and commit this as well. and now i have still 2 comments in my merge request

maxkarkowski avatar Dec 05 '23 12:12 maxkarkowski

I'm a bit hesitant to admit this, but I'm having difficulty configuring a GitLab CE instance in a newer version with runners correctly. Would anyone be willing to grant me access to their GitLab instance so that I can test for the issue?

alan910127 avatar Dec 06 '23 11:12 alan910127

I'm a bit hesitant to admit this, but I'm having difficulty configuring a GitLab CE instance in a newer version with runners correctly. Would anyone be willing to grant me access to their GitLab instance so that I can test for the issue?

sorry for the inconvenience but i cannot share my gitlab instance because it is owned by customer with very sensitive data

maxkarkowski avatar Dec 06 '23 12:12 maxkarkowski

@alan910127 Just wanted to tell you that it's fixed for me, it only generates one comment. Sorry for being so late to respond, honestly I forgot about it.

idumancic avatar Dec 12 '23 17:12 idumancic

@alan910127 Just wanted to tell you that it's fixed for me, it only generates one comment. Sorry for being so late to respond, honestly I forgot about it.

that is weird. can you maybe share what command you execute in your pipeline? i still get multiple comments :/

maxkarkowski avatar Dec 15 '23 14:12 maxkarkowski

@maxkarkowski Maybe you can help to use patch-package to add some logs for debugging? I don't have a GitLab CE v16.6.0 for debugging for you, sorry.

JounQin avatar Dec 15 '23 14:12 JounQin

@maxkarkowski Maybe you can help to use patch-package to add some logs for debugging? I don't have a GitLab CE v16.6.0 for debugging for you, sorry.

what exactly should i do with patch package? run it before changesets-gitlab on my pipeline? i use pnpm so i can only use pnpm patch.

maxkarkowski avatar Dec 18 '23 09:12 maxkarkowski

what exactly should i do with patch package? run it before changesets-gitlab on my pipeline? i use pnpm so i can only use pnpm patch.

Thanks that you're willing to help for debugging.

You can try to patch node_modules/changesets-gitlab/lib/comment.js accordingly.

Mostly you should add some logs at the following:

https://github.com/un-ts/changesets-gitlab/blob/9c6e79263f38d552f65103e6199ef9054d2f2d4a/src/comment.ts#L107-L132

So that we can check why the previous mr was not found.


After seeing api.MergeRequestDiscussions, I have a theory that it could be API changed between MR discussions vs notes.

JounQin avatar Dec 18 '23 10:12 JounQin

# yarn 1
yarn add https://pkg.csb.dev/un-ts/changesets-gitlab/commit/569933f7/changesets-gitlab
# yarn 2, 3
yarn add changesets-gitlab@https://pkg.csb.dev/un-ts/changesets-gitlab/commit/569933f7/changesets-gitlab/_pkg.tgz
# npm
npm i https://pkg.csb.dev/un-ts/changesets-gitlab/commit/569933f7/changesets-gitlab

@maxkarkowski Please help to test.

JounQin avatar Dec 18 '23 10:12 JounQin

# yarn 1
yarn add https://pkg.csb.dev/un-ts/changesets-gitlab/commit/569933f7/changesets-gitlab
# yarn 2, 3
yarn add changesets-gitlab@https://pkg.csb.dev/un-ts/changesets-gitlab/commit/569933f7/changesets-gitlab/_pkg.tgz
# npm
npm i https://pkg.csb.dev/un-ts/changesets-gitlab/commit/569933f7/changesets-gitlab

@maxkarkowski Please help to test.

i will try this. didn't try patching the version yet.

width your version i got the following message

$ pnpm changesets-gitlab comment
(node:181) DeprecationWarning: This endpoint was deprecated in Gitlab API 15.7 and will be removed in API v5. Please use the "allDiffs" function instead.
(Use `node --trace-deprecation ...` to show where the warning was created)

maxkarkowski avatar Dec 18 '23 11:12 maxkarkowski

The warning is not related and expected. Does the comment functionality works as expected?

JounQin avatar Dec 18 '23 12:12 JounQin

The warning is not related and expected. Does the comment functionality works as expected?

no it still creates a new comment with every commit. i try to patch your comment version manually. maybe there es a cache issue with your package at the moment.

maxkarkowski avatar Dec 18 '23 12:12 maxkarkowski

If you're not using note type comment, my fix should be useless. So hope you could help to debug later.

JounQin avatar Dec 18 '23 12:12 JounQin

If you're not using note type comment, my fix should be useless. So hope you could help to debug later.

how can i set it ? as i said, i only execute changesets-gitlab comment. i am happy to help to debug if you tell me what i should do :)

maxkarkowski avatar Dec 18 '23 12:12 maxkarkowski