Skip to content

Add options to generate and push the JSON version of the release notes #1185

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

Merged
merged 1 commit into from
Mar 23, 2020

Conversation

puerco
Copy link
Member

@puerco puerco commented Mar 17, 2020

What type of PR is this?

/kind feature

What this PR does / why we need it:

This PR adds to krel a new feature to generate the kubernetes release notes in the json format required by relnotes.k8s.io. When enabling this feature via --create-website-pr it will create a branch in the user's fork of kubernetes/sig-release (determined by --website-org / --website-repo ) where it will generate the json file and patch the assets.ts file. After that, it will commit the changes and push them to the user's fork.

Which issue(s) this PR fixes:

Fixes #1061
Related to #834

Special notes for your reviewer:

Some notes for this PR:

Does this PR introduce a user-facing change?

This change adds four new flags to the krel release-notes subcommand
After this change it is not longer possible to run --create-website-pr and --create-draft-pr during the same invocation.

- This change adds four new flags to the krel release-notes subcommand:
`--create-website-pr`  - Flag to enable the release notes json generator
`--website-org` - GitHub Organization of the users fork of kubernetes/sig-release
`--website-repo` - Repository containing the fork of the user's repo
`--kubernetes-sigs-fork-path` - Filesystem path to the user's fork of k/sig-release
After this change it is not longer possible to run `--create-website-pr` and `--create-draft-pr` during the same invocation.
Implementation of --create-website-pr in the krel release-notes subcommand to generate the release notes in json format for relnotes.k8s.io

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-priority size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 17, 2020
@k8s-ci-robot k8s-ci-robot added area/release-eng Issues or PRs related to the Release Engineering subproject sig/release Categorizes an issue or PR as relevant to SIG Release. labels Mar 17, 2020
@puerco
Copy link
Member Author

puerco commented Mar 18, 2020

/retest

@puerco
Copy link
Member Author

puerco commented Mar 18, 2020

/retest

@puerco
Copy link
Member Author

puerco commented Mar 18, 2020

/test pull-release-test

@puerco
Copy link
Member Author

puerco commented Mar 18, 2020

Mmh I think something's up with this test ...

  changelog_test.go:202: 
        	Error Trace:	changelog_test.go:202
        	Error:      	Expected nil, but got: no latest tag available for branch release-1.16
        	Test:       	TestNewRCRelease

@saschagrunert
Copy link
Member

Hey @puerco, can you please change the release notes in this PR to contain everything within a single release-notes block? Like

- This change adds four new flags to the krel release-notes subcommand:
  `--create-website-pr` - Flag to enable the release notes json generator
  `--website-org` - GitHub Organization of the users fork of kubernetes/sig-release
  `--website-repo` - Repository containing the fork of the user's repo
  `--kubernetes-sigs-fork-path` - Filesystem path to the user's fork of k/sig-release
  After this change it is not longer possible to run --create-website-pr and --create-draft-pr during the same invocation.
  Implementation of --create-website-pr in the krel release-notes subcommand to generate the release notes in json format for relnotes.k8s.io

@puerco
Copy link
Member Author

puerco commented Mar 18, 2020

Is this a little better?

@saschagrunert
Copy link
Member

Is this a little better?

Yes this is better, thank you! :) I will take care of fixing the CI bug and reviewing your PR in the meanwhile.

Copy link
Member

@saschagrunert saschagrunert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, its generally LGTM. See my comments for more input 👇

Comment on lines 330 to 348
// amend the latest commit
userName, err := command.New("git", "config", "--get", "user.name").RunSuccessOutput()
if err != nil {
return errors.Wrap(err, "while trying to get the user's name")
}

userEmail, err := command.New("git", "config", "--get", "user.email").RunSuccessOutput()
if err != nil {
return errors.Wrap(err, "while trying to get the user's name")
}

logrus.Infof("amending the last commit to the user's config: %v <%v>", userName.OutputTrimNL(), userEmail.OutputTrimNL())

if err := command.NewWithWorkDir(
repository.Dir(), "git", "commit", "--amend", "--signoff", "--no-edit",
"--author", fmt.Sprintf("%v <%v>", userName.OutputTrimNL(), userEmail.OutputTrimNL()),
).RunSilentSuccess(); err != nil {
return errors.Wrap(err, "amending commit with user's data")
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel that we should change the repo.Commit method to streamline this. Can we add a TODO here to indicate that this might be simplified?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a new Commit function CommitWithOptions to the git package which can get custom options for the commit. I modified the Commit function to use it and to send the release notes PRs on behalf of the user, I added a new UserCommit function which reads the user data from the local git.

Comment on lines +574 to +571
// tryToFindPreviuousTag gets a release tag and returns the one before it
func tryToFindPreviuousTag(tag string) (string, error) {
url, err := git.GetDefaultKubernetesRepoURL()
if err != nil {
return "", err
}

status, err := command.New(
"git", "ls-remote", "--sort=v:refname",
"--tags", url,
).
Pipe("grep", "-Eo", "v[0-9].[0-9]+.[0-9]+[-a-z0-9\\.]*$").
Pipe("grep", "-B1", tag).
Pipe("head", "-1").
RunSilentSuccessOutput()

if err != nil {
return "", err
}

return strings.TrimSpace(status.Output()), nil
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function should be part of the git package. I would also make it a bit more flexible by maybe introducing only a new LSRemote() function.

(I think this can be done in a follow-up PR as well.)

@droslean
Copy link
Member

/retest

@droslean
Copy link
Member

/test pull-release-test

@saschagrunert
Copy link
Member

We probably have to increase the timeout in .bazelrc

//cmd/krel/cmd:go_default_test                                          TIMEOUT in 1815.0s

@saschagrunert
Copy link
Member

@puerco can you please rebase on top of the latest master and drop that merge commit?

@puerco
Copy link
Member Author

puerco commented Mar 19, 2020

@saschagrunert yes I'm sorry, I switched computers to continue work on this and accidentally pushed the merge commit. I'll send the updates in a little bit.

Copy link
Member

@saschagrunert saschagrunert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 23, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: puerco, saschagrunert

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 23, 2020
@k8s-ci-robot k8s-ci-robot merged commit 63e6396 into kubernetes:master Mar 23, 2020
@k8s-ci-robot k8s-ci-robot added this to the v1.19 milestone Mar 23, 2020
@puerco puerco deleted the relnotes-json branch May 13, 2020 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/release-eng Issues or PRs related to the Release Engineering subproject cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/release Categorizes an issue or PR as relevant to SIG Release. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[krel] Generate JSON release notes
4 participants