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

🌱 Add integration test for release notes tool #9617

Merged

Conversation

g-gaston
Copy link
Contributor

What this PR does / why we need it:
We make changes to the notes tool pretty frequently, mostly around formatting and handling edge cases. However, the lack of unit tests and the difficulty to add more (given the current structure of the code and the dependency on cli tools) makes it risky to perform these changes with speed. In order to gain confidence on the change, a lot of manual testing is required which is time consuming and prone to errors. This also makes testing for regression difficult.

This PR adds some integration tests (almost e2e): it checks out the right commit, runs the tool and compares the output with a golden file. I decided to test the code directly instead of a built cli to avoid having to build the binary every time we test and also to be able to step with a debugger easily.

This is not perfect since it depends on local git (it uses worktrees to create an "replicable" environment). In addition, it depends on having gh with a valid Github authentication, so it won't be trivial to automate. However, it should do the trick for now so folks can run it locally when making changes to the code. If there are changes to the expected output, these will have to be included in the PR, so we can all review them and see if the match the code changes.

/area release
cc @kubernetes-sigs/cluster-api-release-team

@k8s-ci-robot k8s-ci-robot added area/release Issues or PRs related to releasing cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Oct 25, 2023
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 25, 2023
@g-gaston g-gaston force-pushed the release-notes-integration-test branch 2 times, most recently from 0bed7b6 to c82d49c Compare October 25, 2023 22:08
@g-gaston g-gaston force-pushed the release-notes-integration-test branch from c82d49c to 5c5315b Compare October 25, 2023 22:34
Copy link
Contributor

@mjlshen mjlshen 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 Oct 30, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: e0bb13ca8b31bdd9659584af2b79b8ec7979d4b0

Copy link
Member

@furkatgofurov7 furkatgofurov7 left a comment

Choose a reason for hiding this comment

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

Looks great, thanks!

Nothing major, some minor comments:

hack/tools/release/release_notes_integration_test.go Outdated Show resolved Hide resolved
hack/tools/release/test/run_notes_test.sh Outdated Show resolved Hide resolved
@g-gaston g-gaston force-pushed the release-notes-integration-test branch from 5c5315b to 3222ba5 Compare October 31, 2023 15:14
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 31, 2023
@g-gaston g-gaston force-pushed the release-notes-integration-test branch from 3222ba5 to ce3a7f0 Compare October 31, 2023 15:15
Copy link
Member

@furkatgofurov7 furkatgofurov7 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 Oct 31, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 49688c510b9bd92059bce7fd8a2c25977613d2a5

@g-gaston g-gaston force-pushed the release-notes-integration-test branch from ce3a7f0 to 52da748 Compare October 31, 2023 16:24
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 31, 2023
@g-gaston g-gaston force-pushed the release-notes-integration-test branch from 52da748 to d8bef5c Compare October 31, 2023 16:25
@nawazkh
Copy link
Member

nawazkh commented Oct 31, 2023

/lgtm

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

@killianmuldoon killianmuldoon left a comment

Choose a reason for hiding this comment

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

Haven't given this a code level review - but a couple of questions.

1 - could we have this entire test in Go instead of using a shell script + the golden files + a go file?
2 -We should add a make target and try to run it as a normal part of our test suite if possible.

@g-gaston
Copy link
Contributor Author

g-gaston commented Nov 7, 2023

@killianmuldoon

Haven't given this a code level review - but a couple of questions.

1 - could we have this entire test in Go instead of using a shell script + the golden files + a go file?

I can give that a try. I can probably get rid of the bash script by doing all the setup in go running git commands. However, what's is the issue you see with golden files? We still need something to compare the output with.

2 -We should add a make target and try to run it as a normal part of our test suite if possible.

The problem with running this in CI is it depends on local git (it uses worktrees to create an "replicable" environment). I'm not sure if the git tree is available when running tests, although we can probably configure it if necessary.

In addition, it depends on having gh with a valid Github authentication, so it won't be trivial to automate.

Given the complexity of automating this, I would prefer if we move forward with this PR and have the CI addition as in improvement for the next release cycle. At least that gives us something to verify changes against in the meantime, even if it has to be run manually. In addition, if we merge #9618, we remove the dependency on git, which should make automating this easier.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 14, 2023
@g-gaston g-gaston force-pushed the release-notes-integration-test branch from d8bef5c to ad5c70c Compare November 22, 2023 22:31
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 22, 2023
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 22, 2023
@g-gaston g-gaston force-pushed the release-notes-integration-test branch from ad5c70c to 445370b Compare November 22, 2023 22:33
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 22, 2023
@@ -9,6 +9,7 @@ replace sigs.k8s.io/cluster-api/test => ../../test
require (
cloud.google.com/go/storage v1.35.1
github.com/blang/semver/v4 v4.0.0
github.com/onsi/gomega v1.30.0
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is my only real change
The other modules just come from running go mod tidy

@g-gaston
Copy link
Contributor Author

@killianmuldoon got rid of the bash script and did everything in the go test file

@sbueringer
Copy link
Member

@killianmuldoon got rid of the bash script and did everything in the go test file

Just fyi, Killian is on PTO (IIRC for another 2-3 weeks)

@g-gaston
Copy link
Contributor Author

/test pull-cluster-api-test-main

Copy link
Member

@furkatgofurov7 furkatgofurov7 left a comment

Choose a reason for hiding this comment

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

Few small nits, otherwise looks good to me.

hack/tools/release/notes/main.go Outdated Show resolved Hide resolved
hack/tools/release/notes/release_notes_integration_test.go Outdated Show resolved Hide resolved
@g-gaston g-gaston force-pushed the release-notes-integration-test branch from 445370b to f2f1dea Compare November 28, 2023 16:01
Copy link
Member

@furkatgofurov7 furkatgofurov7 left a comment

Choose a reason for hiding this comment

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

/approve

Copy link
Member

@furkatgofurov7 furkatgofurov7 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 Nov 28, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: f263a4d38e8e583e90e5ad39bdafdd01f218a305

@furkatgofurov7
Copy link
Member

cc @CecileRobertMichon @vincepri hey folks 👋🏼 Can you please take a look and help with reviewing/merging this one? Thank you!

@g-gaston
Copy link
Contributor Author

cc @CecileRobertMichon @vincepri hey folks 👋🏼 Can you please take a look and help with reviewing/merging this one? Thank you!

PS: I think the only reason why Furkat can't approve this one is because I added a new target to the Makefile and change the go.mod (which are both outside of the release folder)

Copy link
Contributor

@CecileRobertMichon CecileRobertMichon left a comment

Choose a reason for hiding this comment

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

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: CecileRobertMichon, furkatgofurov7

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 Nov 28, 2023
@k8s-ci-robot k8s-ci-robot merged commit 42c18de into kubernetes-sigs:main Nov 28, 2023
21 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.7 milestone Nov 28, 2023
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 Issues or PRs related to releasing cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants