-
Notifications
You must be signed in to change notification settings - Fork 371
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
Add local Changelog generation based on PR titles and labels #4219
base: main
Are you sure you want to change the base?
Add local Changelog generation based on PR titles and labels #4219
Conversation
introduce mod at changelog
tools/generatechangelog/go.mod
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move that into tools/go.mod
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved into tools/go.mod
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First of all:
Lines 359 to 363 in c299c53
4. In the pull request review conversations, | |
please either leave a new comment or resolve (close) the conversation, | |
which ensures other people can read all comments. | |
But do not do that simultaneously. | |
Conversations should typically be resolved by the conversation starter, not the PR author. |
Second, tools/go.mod
wasn't updated.
Third, CI fails: https://github.com/FerretDB/FerretDB/actions/runs/8506940135/job/23298489403?pr=4219. Please run formatting, linting, etc locally as described in CONTRIBUTING.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies regarding comment resolution.
I have updated tools/go.mod
to include the dependency for yaml.v3
(and amended formatting issues)
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #4219 +/- ##
==========================================
- Coverage 75.35% 67.21% -8.14%
==========================================
Files 323 316 -7
Lines 22407 22051 -356
==========================================
- Hits 16884 14821 -2063
- Misses 4303 6070 +1767
+ Partials 1220 1160 -60 see 127 files with indirect coverage changes
Flags with carried forward coverage won't be shown. Click here to find out more. |
@vigneshsankariyer1234567890 I will do a re-review shortly; please see our contribution documentation in the meantime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tools/go.mod
Outdated
@@ -20,6 +20,8 @@ require ( | |||
mvdan.cc/gofumpt v0.6.0 | |||
) | |||
|
|||
require gopkg.in/yaml.v3 v3.0.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move it to the group above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added to group as requested, and run task lint
to verify formatting.
tools/tools.go
Outdated
@@ -25,11 +25,14 @@ import ( | |||
_ "golang.org/x/tools/cmd/stringer" | |||
_ "golang.org/x/vuln/cmd/govulncheck" | |||
_ "mvdan.cc/gofumpt" | |||
|
|||
_ "github.com/FerretDB/FerretDB/tools/generatechangelog" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should not be there – note that checkdocs, checkswitch, checkcomments are all not imported
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed verified binary generation still works.
@AlekSi regarding tests for the introduced tool, I noticed that |
Yes, absolutely. Please follow existing things and style as close as possible |
@AlekSi requested your review, and ensured lint and formatting passes. At the moment, running |
- {{ .Title }} by @{{ .User.Login }} in {{ .URL }} | ||
{{- end }} | ||
{{- "\n" }} | ||
{{- end }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a missing line break there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added line break
const ( | ||
OrgOwner = "FerretDB" | ||
Repo = "FerretDB" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could remove those constants
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed constants, and used directly in github call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But they are still there?..
return &commit.Author.Date.Time, nil | ||
} | ||
|
||
func FetchPRs(ctx context.Context, client *github.Client, owner, repo, sinceDate string) ([]PRItem, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could remove owner
and repo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed params for owner and repo
query := fmt.Sprintf("repo:%s/%s is:pr is:merged merged:>=%s", owner, repo, sinceDate) | ||
opts := &github.SearchOptions{Sort: "created", Order: "desc", ListOptions: github.ListOptions{PerPage: 100}} | ||
|
||
issues, _, err := client.Search.Issues(ctx, query, opts) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would not work correctly if two versions were being developed and released in parallel. For example, v1.21.1 and v1.22.0.
Let's simplify all that: make the tool accept the Milestone title, get it, get a list of all PRs in it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood. Just to be clear, this would be the flow:
- Get the milestone based on title
- Search for PRs which are closed and merged based on the milestone number
- Format according to release template
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re 2 – not “search”. Search is a different and more complicated API. We just need to get a list of PRs within the milestone: https://github.com/FerretDB/FerretDB/milestone/63?closed=1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood. I used the "Issues" API instead, which has a ListByRepo
method which allows to pass the milestone number and filter by closed. Subsequently, I identified Issues as Pull Requests by using the Issue::IsPullRequest
method. However, I'm not sure about the distinction between Closed and Merged Pull requests, so I will take a further look at the API to clarify this.
res := []PRItem{} | ||
|
||
for _, issue := range issues.Issues { | ||
res = append(res, func(i *github.Issue) PRItem { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why we use anonymous inline function with struct and JSON tags, but I think we should not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the JSON tags, they were there originally for verification
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't understand why we use anonymous inline struct
s. I think we should not.
func TestGroupPRsByCategories(t *testing.T) { | ||
prItems := []PRItem{ | ||
{ | ||
URL: "http://example.com/pr1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there is a need to test each individual piece individually. We could use a real (old) milestone and real (old) PRs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added an integration test that does each individual part and checks based on the output, which has real PRs.
@AlekSi requested for your re-review. As requested, I have changed it such that |
@vigneshsankariyer1234567890 this pull request has merge conflicts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are multiple CI failures that mask linter failures. Please run them locally.
const ( | ||
OrgOwner = "FerretDB" | ||
Repo = "FerretDB" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But they are still there?..
} | ||
|
||
func NewGitHubClient() *github.Client { | ||
return github.NewClient(nil).WithAuthToken(os.Getenv("GITHUB_TOKEN")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use https://github.com/FerretDB/gh there
res := []PRItem{} | ||
|
||
for _, issue := range issues.Issues { | ||
res = append(res, func(i *github.Issue) PRItem { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't understand why we use anonymous inline struct
s. I think we should not.
@vigneshsankariyer1234567890 this pull request has merge conflicts. |
Description
Currently, we use Github's Changelog generator: https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes
However, this is not the best option since it increases reliance on Github actions themselves. Furthermore, there is a need for local changelog generation in order to simplify the release process.
In the initial issue, attempts were made to look for a tool that could generate the Changelogs directly. Some tools include git-chglog, which actually generate the logs based on the commits themselves. However, these tools are not useful because FerretDB does not follow Changelog commit message standards at the moment, which leads to non-standard commit messages. This also means that it is difficult to use a tool that groups commit messages to hence get the list of PRs.
Instead, I opted for a custom approach that utilised the existing changelog template found in FerretDB (under .github/release.yml). Instead of using commits directly, the idea is to get the merged PRs from the Github API endpoint after the latest tag (which indicates a release). With the definition provided in the release.yml, we can emulate the Changelog generation action locally by subsequently grouping the PRs by the labels defined in the template, and lastly rendering as markdown to stdout.
Here is a demo of how it works:
Screen.Recording.2024-04-03.at.1.15.46.PM.mov
To test it, generate binaries for tools as per instructions in the CONTRIBUTING.md, and launch task changelog directly from root folder, with an input MILESTONE_TITLE according to the milestone that you wish to generate the Changelog for.
Closes #2682 .
Readiness checklist
task all
, and it passed.@FerretDB/core
), Milestone (Next
), Labels, Project and project's Sprint fields.