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

Improve changelog detection for monorepos #2926

Closed
rarkins opened this issue Dec 10, 2018 · 28 comments · Fixed by #10501
Closed

Improve changelog detection for monorepos #2926

rarkins opened this issue Dec 10, 2018 · 28 comments · Fixed by #10501
Assignees
Labels
priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others type:feature Feature (new functionality)

Comments

@rarkins
Copy link
Collaborator

rarkins commented Dec 10, 2018

The original data model for changelog was to assume a 1:1 mapping between package and source repository.

For monorepos, there are multiple challenges:

So our challenge is:

  1. Find the right GitHub Release or changelog file for the package
  2. De-duplicate them in PR bodies

Also related: what to do if a changelog.md file is updated (e.g. improved) in master branch well after publication of the package? Most of the time we'd want to update the PRs with that new info, but perhaps not always.

  • If it is a github repo and then look for a "Release" named [email protected], [email protected], v1.0.0 and 1.0.0
  • If there is a changelog file in the root of the repo, use it
  • If there is a file like ........./package/changelog.md, then use it (i.e. changelog nested)

Then the challenge is how to de-duplicate it within the PR body. If each package has identical from/to versions and identical content, then we should just display it once. But what if it's a mix of shared and non-shared?

@rarkins rarkins added type:feature Feature (new functionality) help wanted Help is needed or welcomed on this issue needs-requirements priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others labels Dec 10, 2018
@rarkins rarkins self-assigned this Dec 10, 2018
@rarkins
Copy link
Collaborator Author

rarkins commented Dec 10, 2018

In they the release notes for manager-package-release should always be the same. But the raw commit "compare" link can be different, namely whether the user is comparing it to the previous stable version or the previous unstable version.

Each "release" should have a "gitRef", whether that's a tag (e.g. v1.0.1) or a raw commit hash. Then the exact compare links can be generated per-PR.

@Flydiverny
Copy link
Contributor

Flydiverny commented Feb 4, 2019

Having just found this issue after trying to get changelogs working for our monorepo packages, I take it there's no workaround at the moment? Using lerna with individual versioning and have one CHANGELOG.md in each package and also tried to update the release tags (@scope/[email protected]) with changelog entries with no success. Found it curious that changelogs wouldn't be picked up while compare links are using the correct tags and versions as well as showing all the links for each release.

@rarkins
Copy link
Collaborator Author

rarkins commented Feb 4, 2019

Can you replicate it in a public repo or find a public lerna repo that uses the same approach you do, that can be tested against?

@Flydiverny
Copy link
Contributor

Not sure if this is something thats interesting or not but figured I'd share it here:
https://github.com/npm/rfcs/blob/latest/implemented/0010-monorepo-subdirectory-declaration.md

Suppose this could potentially help with detecting changelog files for monorepo packages? :)

@rarkins
Copy link
Collaborator Author

rarkins commented Mar 7, 2019

Thanks, I've seen that one and partially implemented it already. We already do a search for subdirectories containing the package name so that captures nearly all the use cases already anyway.

@felixfbecker
Copy link

Even if a changelog could not be detected, it would be nice if Renovate could add a "Compare source" link that links to comparison page of that subfolder so I can inspect the commits

@rarkins
Copy link
Collaborator Author

rarkins commented Mar 8, 2019

@felixfbecker I've never seen a subfolder compare link before. Do you have an example for GitHub?

@felixfbecker
Copy link

Hmm, doesn't seem to exit in the UI. Maybe a link to the history page of the folder then? https://github.com/renovatebot/renovate/commits/master/docs

@rarkins
Copy link
Collaborator Author

rarkins commented Mar 8, 2019

OK so if source directory is defined in package.json but no CHANGELOG file is found within that directory, then link to the directory's commit history?

@Flydiverny
Copy link
Contributor

Thanks, I've seen that one and partially implemented it already. We already do a search for subdirectories containing the package name so that captures nearly all the use cases already anyway.

Does this mean that if I have a monorepo with a package name banana
and these files

- ..stuff in root..
- packages/banana/package.json
- packages/banana/CHANGELOG.md

It would detect the changelog and present it already?

I suppose this doesn't work for scoped packages where I would have eg @flydiverny/banana as package name but same file structure as above.

Is there anything I can set in package.json files to make it detect nested changelogs today?

@rarkins
Copy link
Collaborator Author

rarkins commented Mar 10, 2019

Can you describe your situation in full? Eg self hosted or GitHub.com? Directory structure, etc

@Flydiverny
Copy link
Contributor

Its on github. So using this as an example:
monorepo with lerna + yarn

packages/renovate-bug-dep contains a package with name @flydiverny/renovate-bug-dep.
There I have a nested CHANGELOG.md.

For version 1.1.4 of the package there's also a github release tagged as @flydiverny/[email protected]

Here's a PR from renovate trying to update this dependency: Flydiverny/renovate-workspace#2

Don't mind the repo and package names :)

In our project its similar with the main difference being private github repo and private packages on npm.

@rarkins
Copy link
Collaborator Author

rarkins commented Mar 11, 2019

@Flydiverny thanks for the example! That's exactly what I needed. Can I assume that the GitHub Releases entry and CHANGELOG.md entries should always be identical, i.e. we can use whichever one works best for our internal logic?

@Flydiverny
Copy link
Contributor

Flydiverny commented Mar 11, 2019

@rarkins Yes they are supposed to match :) using lerna to generate both of them here as they recently added a --github-release flag.

The github release requires the end user to specify github token tho so its a bit more of a hassle to use. But I personally prefer github releases anyway.

@rarkins
Copy link
Collaborator Author

rarkins commented Mar 11, 2019

Alright thanks, I think we have enough info to fix it!

@rarkins rarkins added ready and removed help wanted Help is needed or welcomed on this issue needs-requirements labels Mar 11, 2019
@rarkins
Copy link
Collaborator Author

rarkins commented Mar 11, 2019

Next steps: debug changelog retrieval using the reproduction repos from @Flydiverny here: #2926 (comment)

Either fix/improve our existing release parsing (we should be able to locate the package/release combination) or locate the nested CHANGELOG.md files

@koba04
Copy link

koba04 commented Jan 15, 2020

Is there any update on this?
I have the same issue.

We use yarn workspaces + lerna for a monorepo and publish a new package using lerna publish.
As a result, the CHANGELOG.md is placed in each package and doesn't exist in the root directory on the repository.

Should I put CHANGELOG.md that aggregates all changelog for packages in the root directory?
Or should I put the changes in the GitHub releases?

The following is the monorepo.
https://github.com/kintone/js-sdk

The following is a PR to update the package version by Renovate.
koba04/gatsby-source-kintone#13

Thanks!

@rarkins
Copy link
Collaborator Author

rarkins commented Jan 16, 2020

@koba04 No, you shouldn't need to change the way your do the individual CHANGELOG files, Renovate should be updated to accommodate/detect that.

@rarkins rarkins removed their assignment Jan 16, 2020
@rarkins
Copy link
Collaborator Author

rarkins commented Jan 16, 2020

@koba04 actually, you do need to make some changes though. Currently your monorepo is not complying with npm's package.json recommendation:

image

Notably here: https://github.com/kintone/js-sdk/blob/edc5d0cd75e577b90d22c0234bbbcfaa5263a946/packages/rest-api-client/package.json#L37-L39

bigpopakap pushed a commit to bigpopakap-crap/shared-node-tools that referenced this issue Jan 16, 2020
Previosly, when RenovateBot would update this package in other projects, it was unable to read the
CHANGELOG.md file. This is because the package lives in a monorepo, so RenovateBot didn't know where
to look for the changelog of the specific package being updated. This follows RenovateBot's
suggestion, and should fix the issue. See the suggestion here:
renovatebot/renovate#2926 (comment)
bigpopakap pushed a commit to bigpopakap-crap/shared-node-tools that referenced this issue Jan 16, 2020
Previosly, when RenovateBot would update this package in other projects, it was unable to read the
CHANGELOG.md file. This is because the package lives in a monorepo, so RenovateBot didn't know where
to look for the changelog of the specific package being updated. This follows RenovateBot's
suggestion, and should fix the issue. See the suggestion here:
renovatebot/renovate#2926 (comment)
bigpopakap pushed a commit to bigpopakap-crap/shared-node-tools that referenced this issue Jan 16, 2020
# [@bigpopakap/eslint-config-v1.1.15](https://github.com/bigpopakap/shared-node-tools/compare/v1.1.14-@bigpopakap/eslint-config...v1.1.15-@bigpopakap/eslint-config) (2020-01-16)

### Bug Fixes

* **package.json:** add directory to package.json within monorepo ([85e9ef9](85e9ef9)), closes [/github.com/renovatebot/renovate/issues/2926#issuecomment-575094237](https://github.com//github.com/renovatebot/renovate/issues/2926/issues/issuecomment-575094237)
* **package.json:** add license, keywords and bug tracker link ([9d795b1](9d795b1))
* **readme:** fix erroneous trailing comma in package.json snippet ([4d21a9e](4d21a9e))
bigpopakap pushed a commit to bigpopakap-crap/shared-node-tools that referenced this issue Jan 16, 2020
# [@bigpopakap/renovate-config-v1.0.4](https://github.com/bigpopakap/shared-node-tools/compare/v1.0.3-@bigpopakap/renovate-config...v1.0.4-@bigpopakap/renovate-config) (2020-01-16)

### Bug Fixes

* **package.json:** add directory to package.json within monorepo ([85e9ef9](85e9ef9)), closes [/github.com/renovatebot/renovate/issues/2926#issuecomment-575094237](https://github.com//github.com/renovatebot/renovate/issues/2926/issues/issuecomment-575094237)
* **package.json:** add license, keywords and bug tracker link ([9d795b1](9d795b1))
bigpopakap pushed a commit to bigpopakap-crap/shared-node-tools that referenced this issue Jan 16, 2020
# [@bigpopakap/stylelint-config-v1.0.10](https://github.com/bigpopakap/shared-node-tools/compare/v1.0.9-@bigpopakap/stylelint-config...v1.0.10-@bigpopakap/stylelint-config) (2020-01-16)

### Bug Fixes

* **package.json:** add directory to package.json within monorepo ([85e9ef9](85e9ef9)), closes [/github.com/renovatebot/renovate/issues/2926#issuecomment-575094237](https://github.com//github.com/renovatebot/renovate/issues/2926/issues/issuecomment-575094237)
* **package.json:** add license, keywords and bug tracker link ([9d795b1](9d795b1))
@rarkins rarkins removed the ready label Jun 18, 2020
@viceice
Copy link
Member

viceice commented Sep 30, 2020

Always seeing duplicate version entries for traefik

image

@koba04
Copy link

koba04 commented Feb 5, 2021

@rarkins
As you mentioned at #2926 (comment), I've added the repostitory.directory property in a package in monorepo at kintone/js-sdk#29, but Renovate doesn't recognize CHANGELOG.md in the packages/*** directory.

koba04/gatsby-source-kintone#28

Am I missing something?

@rarkins
Copy link
Collaborator Author

rarkins commented Feb 5, 2021

@koba04 can create a minimal reproduction to debug against?

@koba04
Copy link

koba04 commented Feb 12, 2021

@github-actions
Copy link
Contributor

Thank you for providing a reproduction.
The label will be updated to reproduction:confirmed once someone else has confirmed they can reproduce the problem with it.

@k-yle
Copy link
Contributor

k-yle commented Mar 10, 2021

Hi @rarkins, I had a go at fixing this but ran out of time. I think the issue are:

  1. this API call needs ?recursive=1 to return all files, not just the root level one; and
  2. the regex from changelog-filename-regex uses ^ and $ so it doesn't work if the file name is packages/x/CHANGELOG.md

but, this approach still fails if the package doesn't specify repository.directory in package.json.

So perhaps #9061 is a better approach?

@github-actions
Copy link
Contributor

Thank you for providing a reproduction! 🎉 🚀

The Renovate team will take a look at the reproduction repository. Once we confirm the provided repository reproduces the problem, the label will be changed to reproduction:confirmed.

@renovate-release
Copy link
Collaborator

🎉 This issue has been resolved in version 25.47.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others type:feature Feature (new functionality)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants