-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Makefile,*: cleanup and refactoring, support reproducible tests locally #4023
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
Makefile,*: cleanup and refactoring, support reproducible tests locally #4023
Conversation
@camilamacedo86 no rush, but when you get a chance, can you try out each of the make targets in this PR to see if everything works as expected in macOS? |
Successful build in my fork is here: https://travis-ci.org/github/joelanford/operator-sdk/builds/735424396 |
Expect(tc.LoadImageToKindClusterWithName("quay.io/operator-framework/scorecard-test:dev")).To(Succeed()) | ||
Expect(tc.LoadImageToKindClusterWithName("quay.io/operator-framework/custom-scorecard-tests:dev")).To(Succeed()) |
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.
Could not the name of the images be a const in the operator-sdk/internal/testutils/scorecard.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.
It certainly could. I could go either way.
- If we leave it as is, there would be less indirection in the test code, which would make it easier to comprehend and debug, but if we change the scorecard image name (though we probably can't until 2.x), then we'd have to change this string in multiple places.
- If we introduce a constant in a separate package, we decrease duplication and centralize the definition of the scorecard image names used in the e2e tests, but we add indirection and make the code slightly more difficult to directly read and understand.
In general, I would usually choose option 2, but I'm leaning toward 1 in this case for two reasons: the image names are extremely unlikely to change for the duration of 1.x and it's nice for tests to have as little indirection as possible so that it is clear what the expectations of the test are.
But I'm good either way. If there's another vote for using constants, I'll switch it over.
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.
A 3. option (my vote) would be a func such as LoadScorercardDevImages which would centralize all. Then, this func would try to load all images and not panic (may just log) when the image X is not found to address the ansible/helm scenarios where is not required both.
./hack/check-error-log-msg-format.sh | ||
go run ./hack/generate/changelog/gen-changelog.go -validate-only | ||
go vet ./... | ||
./tools/scripts/fetch golangci-lint 1.31.0 && ./tools/bin/golangci-lint run |
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.
Could we have the make lint
and make lint-fix
as well?
IHMO many times we do not need to check all and it is very common to run only make lint and would be make lint-fix which I believe that was removed by mistake to automatic perform the required fixes.
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.
With this PR, I'm intentionally trying to decrease the number of make targets down to a much more manageable set with just the ones that are truly necessary.
IMO make lint
isn't much easier or better than just directly running ./tools/bin/golangci-lint run
. Personally, I never used make lint
and always just ran make test-sanity
.
At the end of the day it comes down to what other contributors want, so if there's more support for keeping lint
and/or lint-fix
around, we can.
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.
With this PR, I'm intentionally trying to decrease the number of make targets down to a much more manageable set with just the ones that are truly necessary.
I am totally all in to reduce the number of targets. However, I think we need to keep some targets as helpers for the developers/contributors.
IMO make lint isn't much easier or better than just directly running ./tools/bin/golangci-lint run. Personally, I never used make lint and always just ran make test-sanity.
So, I'd vote to keep them since (IHMO):
- the test-sanity do many checks
- I have the impression that contributors have more difficult to understand why the sanity logs and know why the test is not working at all.
- and mainly, because the test-sanity requires that we have all committed to passing on that which make harder work with and solve the lint issues. I do not want need to commit to check if has or not lint issues.
- the make lint and make lint-fix are easier to remember than
./tools/bin/golangci-lint run
and./tools/bin/golangci-lint run --fix
- it would keep the same standard adopted in the KB, controller-runtime and operator-lib.
However, I let it to you folks.
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.
My typical approach to submitting PRs is to make all the necessary changes and commits, and then run through the tests locally before submitting the PR.
When I follow this approach, I am effectively running ALL of the same tests that run in CI. If we stick with each individual thing being its own make target, we end up with (IMO) two negative outcomes:
- There would be so many make targets that contributors don't really know what they should or shouldn't use.
- Contributors will be less likely to run the full set of CI tests locally before submitting a PR, taking up more CI cycles unnecessarily.
My goal with this PR is to make that process easier and more foolproof. This PR:
- Decreases the number of targets to make it easier for contributors to know what's what (the make targets now generally align with the phases of the CI run). Now contributors will have less guessing to do to know what to run prior to submitting a PR.
- Makes the e2e tests run in an isolated kind cluster that is used only for operator-sdk e2e tests. Now contributors can run e2e tests in the same way no matter what their local environment looks like.
IMO the benefits far outweigh the drawbacks.
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.
Just a few nits/comments.
Otherwise, it shows great for me 👍
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.
Looks great. Quite a few more make targets will be removed in #4034
/lgtm
b748fdc
to
6b37b5e
Compare
New changes are detected. LGTM label has been removed. |
6b37b5e
to
8bab1f9
Compare
It looks like the way travis does checkouts may cause a recent tag (from a release) that isn't in a PR's branch to not be present on |
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.
IHMO : It is missing :
- have a target to gen the samples
make samples
(we need a target to gen the samples). In POV we could have the make generate which would run make install and gen the docs + samples. - call make install when we run make generate - calling the build instead
- have a target to run just the lint and add the lint-fix to the new target fix (it has been discussed)
.PHONY: fix | ||
fix: ## Fixup files in the repo. | ||
go mod tidy | ||
go fmt ./... |
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.
WDYT about to add here the lint-fix so?
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 hesitant to put that in the critical path of PRs. What if we don't agree with one of the fixes that it makes? I've never personally used the --fix
flag or the lint-fix
target, so I don't have first-hand experience, but it always struck me as a convenience wrapper to run if the linter failed to quickly resolve whatever it's complaining about. And then contributors would have a chance to manually review the changes before committing.
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.
the --fix usually fix spaces and go fmt issues. It does not fix all scenarios. if we add the lint check gofmt in https://github.com/operator-framework/operator-sdk/blob/master/.golangci.yml#L2 which I think should have, then we can replace the go fmt ./... here by the lint fix. PS: the go vet is also missing in the lint checks. (govet check)
@camilamacedo86 As I mentioned before, my goal in this PR was to simplify the Makefile and decrease the number of make targets. Samples generation has been folded in under the
|
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 am ok with we move forward with this one 👍
/lgtm
IHMO: the lint is missing the checks gofmt and govet and then we do not need to it in the sanity. Also, instead of having them in the fix we could call the lint -fix which solve these checks + the spaces issues such as when is missing that at the end of the file.
We can do it a follow up as well.
382a998
to
c8b9cea
Compare
Description of the change:
Refactoring and cleanup of the Makefile and hack scripts
Motivation for the change:
The e2e and integration tests are now runnable locally. Overall reduction of complexity and spaghetti.
Checklist
If the pull request includes user-facing changes, extra documentation is required:
Add a new changelog fragment inchangelog/fragments
(seechangelog/fragments/00-template.yaml
)website/content/en/docs