-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
CI: fix GHA CI not running unit tests in cmd #2972
Conversation
The code was correct but too long. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Hi @kolyshkin. Thanks for your PR. I'm waiting for a google member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
/ok-to-test |
@bobbypage PTAL (this fixes quite a big issue in GHA CI) |
Hmm, I followed the second link and got an impression that I need to be a kubernetes member in order to avoid waiting for Only after doing that I realized that the first link points to https://github.com/orgs/google/people, not https://github.com/orgs/kubernetes/people. @bobbypage please let me know if you're still OK to sponsor me for being a kubernetes member. |
build/unit-in-container.sh
Outdated
} | ||
|
||
GO_FLAGS=${GO_FLAGS:-"-tags=netgo -race"} | ||
BUILD_PACKAGES=${BUILD_PACKAGES:-} | ||
PACKAGES=${PACKAGES:-"sudo"} |
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 little confused here, why do we need to install sudo?
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's in the commit message, copy/pasting here to save you a click:
Now, when these tests are enabled, we see that sudo is missing from the
image, so add it.
IOW some tests under ./cmd
use sudo
(although at the moment I don't remember which ones). Let me do this
-PACKAGES=${PACKAGES:-"sudo"}
+PACKAGES=${PACKAGES:-"apt"}
in this PR and see what happens.
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.
OK, I'm not sure why but tests passes. I remember sudo was needed for integration tests, and these are unit tests. Maybe I mixed those up when writing this. Will fix.
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.
OK, there were 3 bugs in the code 🤦🏻
sudo
was no needed;s/BUILD_PACKAGES/PACKAGES/
was wrong, as tests need BUILD_PACKAGES to build test binaries;GO_FLAGS
were not propagated to docker container, thus tests were not performed with proper tags -- this was also the reason why (2) was not resulted in a ❌ CI.
All fixed now 😅
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.
OK, apparently I mixed this up; sudo removed.
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.
wow, thanks for the debugging and fixing this up :)
/ok-to-test |
Thanks @kolyshkin for fixing this. +1 on your k8s sponsorship, happy to do that. |
/hold |
5491ea6
to
76b5d28
Compare
1. Honor GO_FLAGS; if unset, use -race. As a result, integration tests are now built with -race. 2. Instead of using -short to avoid integration tests, filter out packages under integration. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
So, build/unit-in-container.sh never ran any tests under cmd. This happened because the $(go list ...) in BUILD_CMD was not escaped, and therefore the expansion happened before cd. Here is a demo: [kir@kir-rhat cadvisor]$ BUILD_CMD="pwd && cd cmd && echo $(pwd)" [kir@kir-rhat cadvisor]$ echo $BUILD_CMD pwd && cd cmd && echo /home/kir/go/src/github.com/google/cadvisor The fix would be to escape the $ in $(go list): [kir@kir-rhat cadvisor]$ BUILD_CMD="pwd && cd cmd && echo \$(pwd)" [kir@kir-rhat cadvisor]$ echo $BUILD_CMD pwd && cd cmd && echo $(pwd) [kir@kir-rhat cadvisor]$ sh -c "$BUILD_CMD" /home/kir/go/src/github.com/google/cadvisor /home/kir/go/src/github.com/google/cadvisor/cmd Yet, it's easier just to reuse the make test target which already has the exclusion logic. For that to work properly with custom test configs from ./build/config, we need to export GO_FLAGS env var into container. While at it, slightly simplify the BUILD_CMD by adding -e to bash, so we do not have to specify && every time. Fixes: 74b513b Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
7beb677
to
2cdb020
Compare
1. Go package no longer needs to be in a particular directory (since Go 1.10 or so). 2. fetch-depth: 1 is the default -- no need to specify it. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
6a08747
to
2ae3813
Compare
There is no need to spawn a docker container for unit tests; run those locally. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
no longer a draft; PTAL @bobbypage |
LGTM, thanks again for fixing this up. |
This fixes GHA CI not running unit tests in cmd, and simplifies some things along the way. For details, see commit messages.
Please review commit by commit.