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

Make CI much more effective #4564

Merged
merged 23 commits into from Apr 6, 2022
Merged

Conversation

KnVerey
Copy link
Contributor

@KnVerey KnVerey commented Apr 1, 2022

In working on the linter config for #4560, I ended up discovering that our CI configuration as a whole is seriously problematic. Most seriously, many tests are run multiple times in the same env, and many others are never run at all. The license detection check doesn't work at all, and the linter is only applying to a few modules. 😱

I made a spreadsheet to inventory the situation, and it is perhaps the best way to see the before and after I'm trying to achieve with this PR: Kustomize test job inventory

Highlights of problems fixed

  • go test: This was being run up to five times per commit for some modules, and never for others. Most never ran master because they were only in the Prow check. They now fall into two categories: (1) everything outside the plugin/ directory runs once in each GOOS (except Windows, a la Fix breaking api tests on windows #4001) via the Github Action, including on master; (2) the plugin/ directory continues to only be run by Prow. We could revisit this later, but it didn't "just work" to move them over, and I am out of time to work on this for now.
  • go fix/fmt/tidy/vet: Prow (via kyaml precommit) ran go fix/fmt/tidy/vet on kyaml, cmd/config and functions/examples/*, but did nothing with the results. Those commands do not exit non-zero when they do something, and the git-based check that supposedly used to validate the result has been commented out for two years. I "fixed" this by not running most of them anymore, for any module. go mod tidy specifically is still run by Prow though, because it always ran that separately for all modules.
  • go build/generate: Prow (via kyaml precommit) also ran these for a few modules. I fixed this by adding a task that attempts to build all modules with a build target defined. Generate is only run if the build depends on it. There are generators that haven't been run for a long time and break things if you do run them, so generate couldn't simply be added globally.
  • make license: this was similarly only run in select places was similarly ineffective, since CI did not include the -check flag--it would make the changes, exit zero, and tests would pass. I fixed this by creating a single license file and a script to apply it to the entire repo. The script has a check mode, which CI now uses.
  • make lint: this was similarly only run in select places, but at least it worked for those places. Now it runs for all modules, including plugins. There are no actual linter fixes in this PR because the "since rev" option is pinned to such a recent commit. We could remove it on a branch and work on some of the existing issues like I did in Update and re-enable linters #4560, but that's out of scope for this PR.

Other notes

  • The Makefile symlinks were generated programmatically like this:
hack/for-each-module.sh 'if [[ ! -f Makefile ]]; then BACKTRACKS=$(pwd | sed -e "s|.*kustomize/||" -e "s|[^/]*|..|g"); ln -s $BACKTRACKS/Makefile-modules.mk Makefile; fi'

@k8s-ci-robot
Copy link
Contributor

@KnVerey: This PR has multiple commits, and the default merge method is: merge.
You can request commits to be squashed using the label: tide/merge-method-squash

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Apr 1, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: KnVerey

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 Apr 1, 2022
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Apr 4, 2022
@KnVerey
Copy link
Contributor Author

KnVerey commented Apr 4, 2022

/test all

@KnVerey
Copy link
Contributor Author

KnVerey commented Apr 5, 2022

/test kustomize-presubmit-master

@KnVerey
Copy link
Contributor Author

KnVerey commented Apr 5, 2022

/test kustomize-presubmit-master

@KnVerey KnVerey marked this pull request as ready for review April 5, 2022 01:32
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 5, 2022
@KnVerey KnVerey changed the title Rework ci Make CI much more effective Apr 5, 2022

### Begin kustomize plugin rules.
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 entire section was just lifted as-is into Makefile-plugins.mk to make this file easier to navigate.

make $MYGOBIN/helmV3
make $MYGOBIN/helm
Copy link
Contributor Author

Choose a reason for hiding this comment

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

neither old version seems to be used by anything anymore, so I removed the targets for these

@KnVerey
Copy link
Contributor Author

KnVerey commented Apr 5, 2022

/cc @natasha41575

Copy link
Contributor

@natasha41575 natasha41575 left a comment

Choose a reason for hiding this comment

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

Thanks for working on this! Some small comments

Makefile Show resolved Hide resolved
install-tools \
test-unit-kustomize-plugins \
test-go-mod \
build-non-plugin-all \
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we intentionally excluding test-non-plugin-all here?

Copy link
Contributor

Choose a reason for hiding this comment

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

If so, we should probably make the other CI jobs "required", right now only the CLA check and the kustomize-presubmit-master jobs are listed as required.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I did that because it seemed silly to run them twice, and desirable to (eventually) run all test in all three envs, which Github Actions is set up to do. If you can think of a reason we'd want to run them in prow as well, happy to add it back.

If so, we should probably make the other CI jobs "required", right now only the CLA check and the kustomize-presubmit-master jobs are listed as required.

Really surprised by this. I think they should be required either way. I'll change that now.

Copy link
Contributor

Choose a reason for hiding this comment

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

If you can think of a reason we'd want to run them in prow as well, happy to add it back.

No need to add it back. As long as it's running under a required job, removing redundancy SGTM.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makefile Outdated Show resolved Hide resolved
cmd/depprobcheck/Makefile Show resolved Hide resolved
.github/workflows/go.yml Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Makefile Outdated

.PHONY: test-unit-kustomize-plugins
test-unit-kustomize-plugins:
./hack/testUnitKustomizePlugins.sh

.PHONY: test-unit-kustomize-cli
test-unit-kustomize-cli:
cd kustomize; go test ./...
cd kustomize; $(MAKE) test
Copy link
Contributor

Choose a reason for hiding this comment

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

It won't let me comment on it, but right below this is test-unit-kustomize-all, is there any reason to have both that and test-unit-all?

It's also unclear to me why test-unit-kustomize-all chooses to test api, cli, and plugins, but not the rest of our unit tests. I'd lean towards just removing it unless there's a reason we need to keep it.

Makefile Outdated Show resolved Hide resolved
Makefile Outdated
@@ -125,8 +126,9 @@ lint: $(MYGOBIN)/golangci-lint $(MYGOBIN)/goimports $(builtinplugins)
./hack/for-each-module.sh "make lint"

.PHONY: test-unit-all
test-unit-all: $(builtinplugins)
./hack/for-each-module.sh "make test"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would be nice to use this definition, but it doesn't work right now. The plugin script is doing some setup / exlusions.

@natasha41575
Copy link
Contributor

/lgtm

We might want to take a look at kubernetes/test-infra#15611 (comment) to see if we can have tide take a look at the other Github checks.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 6, 2022
@k8s-ci-robot k8s-ci-robot merged commit 4fc0249 into kubernetes-sigs:master Apr 6, 2022
@KnVerey KnVerey deleted the rework_ci branch April 6, 2022 19:50
@KnVerey
Copy link
Contributor Author

KnVerey commented Apr 6, 2022

Looks like I forgot to apply the "merge-method-squash" and left 23 commits. Sorry! 😬

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. 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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants