-
Notifications
You must be signed in to change notification settings - Fork 28
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
Automatically update and check copied code #13
Automatically update and check copied code #13
Conversation
We copy the GraphQL models from the `stolostron/search-api-v2` project in order to avoid additional dependencies. This patch adds `go:generate` directives to automatically update that code when `make generate` is executed. A wanted side effect of that is that if the copied code is changed manually the `check-generated-code` test will fail. Related: https://issues.redhat.com/browse/MGMT-16108 Related: https://github.com/stolostron/search-v2-api/blob/main/graph/schema.graphqls Related: https://github.com/stolostron/search-v2-api/blob/main/graph/model/models_gen.go Signed-off-by: Juan Hernandez <[email protected]>
FYI: @danielerez |
// project, but we don't want to import it because that would bring many other dependencies | ||
// that may be problematic in the future. Instead of that we copy that code into our project. | ||
// | ||
//go:generate curl -Lso searchapi.go https://raw.githubusercontent.com/stolostron/search-v2-api/234de1a26d82b3de2af74cf21aa1226db8e5f26a/graph/model/models_gen.go |
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.
Isn't it tied to a specific commit? I.e. I would expect it would fetch from latest 'master' branch? Or is there some other mechanism for fetching the latest bits?
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 is tied to a specific commit on purpose. We could get the latest from the master
branch with this:
https://github.com/stolostron/search-v2-api/blob/main/graph/model/models_gen.go
But that would make the build non-repeatable.
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.
Not that the point here is not really to automatically update, but rather to ensure that we don't manually change this file by accident. If we did, then the check-generated-code
action would detect it and fail the build. Not super important, just a tad better.
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.
Not that the point here is not really to automatically update, but rather to ensure that we don't manually change this file by accident. If we did, then the
check-generated-code
action would detect it and fail the build. Not super important, just a tad better.
Cool, makes sense.
/lgtm |
We copy the GraphQL models from the
stolostron/search-api-v2
project in order to avoid additional dependencies. This patch addsgo:generate
directives to automatically update that code whenmake generate
is executed.Related: https://issues.redhat.com/browse/MGMT-16108
Related: https://github.com/stolostron/search-v2-api/blob/main/graph/schema.graphqls
Related: https://github.com/stolostron/search-v2-api/blob/main/graph/model/models_gen.go