-
Notifications
You must be signed in to change notification settings - Fork 506
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 release notes API record feature #1039
Add release notes API record feature #1039
Conversation
Ready for review. This allows us to record the release notes API and replay for later (mocked) integration testing. |
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.
All in all I think this is a great feature!
Yeah I thought it would be not only good for testing, but also for development: If I want to change the layout/parsing of the release notes it would be good to be able to fastly replay the latest recording without having the need for any GitHub API access. WDYT?
👍
Given I understand your approach and proposed feature correctly, my remaining main concerns are:
- Nit: naming things an slice them into packages: things like
client.Client
andoptions.Options
always read weird to me. I thinkgolint
would also flag them as "stutter". - The replay client could be way easier and should not mix prod- and test-code (the counterfeiter client), and frankly I can't see any reason why it would need to wrap any client, neither test/fake nor real. Am I missing something?
- It feels a bit strange to me that we kinda pass 2 potentially different clients into the gatherer, one directly and one via the options. Is that just me maybe?
i := 0 | ||
if j, ok := c.recordState[api]; ok { | ||
i = j + 1 | ||
} | ||
c.recordState[api] = i |
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.
Why not simply do
c.recordState[api]++
?
You initialise c.recordState
in the constructor anyway and the githubNotesRecordClient
is not exported and therefore cannot be used by external users anyway.
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 need the i
later on for the filename :)
I changed the layout of the packages and addressed most of your review notes. Thanks for the detailed review 🙏 I think we're moving into the right direction. PTAL. :) |
/test pull-release-cluster-up |
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.
mostly nits, just remove the hold if you don't agree / don't want to address them :)
/lgtm
/approve
/hold
@@ -1,5 +1,5 @@ | |||
/* | |||
Copyright 2019 The Kubernetes Authors. | |||
Copyright 2020 The Kubernetes Authors. |
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.
JFYI: There are a couple of things going on which hopefully help a bit with counterfeiter fakes in future:
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.
Ah cool, awesome! 👍
This patch adds the ability to record the release notes API via two new release notes command line flags `--record <DIR>` and `--replay <DIR>`. This allows us to create custom test cases and implement changes to the release notes tool faster without actually having the need to interact with the GitHub API. How does it work? A recorded session can be created for example via: ``` > go run cmd/release-notes/main.go \ --github-token $TOKEN \ --branch release-1.16 \ --start-rev v1.16.2 \ --end-rev v1.16.3 \ --output v1.16.3.md \ --record rec ``` Now the created directory `rec` contains all the serialized API calls: ``` > ls -1 rec | head GetCommit-0.json GetCommit-1.json GetPullRequest-0.json GetPullRequest-1.json GetPullRequest-2.json GetPullRequest-3.json GetPullRequest-4.json GetPullRequest-5.json GetPullRequest-6.json GetPullRequest-7.json ``` To replay the session without having the need for a valid token, we can now invoke: ``` > go run cmd/release-notes/main.go \ --replay rec \ --output v1.16.3-replayed.md ``` Signed-off-by: Sascha Grunert <sgrunert@suse.com>
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: hoegaarden, 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 |
This patch adds the ability to record the release notes API via two new
release notes command line flags
--record <DIR>
and--replay <DIR>
.This allows us to create custom test cases and implement changes to the
release notes tool faster without actually having the need to interact
with the GitHub API.
How does it work? A recorded session can be created for example via:
Now the created directory
rec
contains all the serialized API calls:To replay the session without having the need for a valid token, we can
now invoke:
Signed-off-by: Sascha Grunert sgrunert@suse.com