diff --git a/pkg/minikube/detect/detect.go b/pkg/minikube/detect/detect.go index 7e4fce08d3..ebb9dd41b1 100644 --- a/pkg/minikube/detect/detect.go +++ b/pkg/minikube/detect/detect.go @@ -107,3 +107,9 @@ func DockerInstalledViaSnap() bool { return strings.Contains(string(o), "snap") } + +// GithubActionRunner returns true if running inside a github action runner +func GithubActionRunner() bool { + // based on https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables + return os.Getenv("GITHUB_ACTIONS") == "true" +} diff --git a/pkg/minikube/download/download.go b/pkg/minikube/download/download.go index 3b4ea62f5d..83c2c3c862 100644 --- a/pkg/minikube/download/download.go +++ b/pkg/minikube/download/download.go @@ -28,6 +28,7 @@ import ( "github.com/juju/mutex" "github.com/pkg/errors" "k8s.io/klog/v2" + "k8s.io/minikube/pkg/minikube/detect" "k8s.io/minikube/pkg/minikube/out" "k8s.io/minikube/pkg/minikube/style" "k8s.io/minikube/pkg/util/lock" @@ -60,7 +61,7 @@ func CreateDstDownloadMock(src, dst string) error { // download is a well-configured atomic download function func download(src string, dst string) error { var clientOptions []getter.ClientOption - if out.IsTerminal(os.Stdout) { + if out.IsTerminal(os.Stdout) && !detect.GithubActionRunner() { progress := getter.WithProgress(DefaultProgressBar) if out.JSON { progress = getter.WithProgress(DefaultJSONOutput) diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index a268c058ff..80c408af38 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -43,6 +43,7 @@ import ( "k8s.io/minikube/pkg/drivers/kic/oci" "k8s.io/minikube/pkg/minikube/config" + "k8s.io/minikube/pkg/minikube/detect" "k8s.io/minikube/pkg/minikube/localpath" "k8s.io/minikube/pkg/minikube/reason" "k8s.io/minikube/pkg/util/retry" @@ -67,7 +68,7 @@ var apiPortTest = 8441 // Store the proxy session so we can clean it up at the end var mitm *StartSession -var runCorpProxy = GithubActionRunner() && runtime.GOOS == "linux" && !arm64Platform() +var runCorpProxy = detect.GithubActionRunner() && runtime.GOOS == "linux" && !arm64Platform() // TestFunctional are functionality tests which can safely share a profile in parallel func TestFunctional(t *testing.T) { @@ -278,7 +279,7 @@ func validateImageCommands(ctx context.Context, t *testing.T, profile string) { t.Skip("image commands are not available on the none driver") } // docs(skip): Skips on GitHub Actions and macOS as this test case requires a running docker daemon - if GithubActionRunner() && runtime.GOOS == "darwin" { + if detect.GithubActionRunner() && runtime.GOOS == "darwin" { t.Skip("skipping on darwin github action runners, as this test requires a running docker daemon") } @@ -1034,7 +1035,7 @@ func validateCacheCmd(ctx context.Context, t *testing.T, profile string) { // docs: Run `minikube cache add` and make sure we can build and add a local image to the cache t.Run("add_local", func(t *testing.T) { - if GithubActionRunner() && runtime.GOOS == "darwin" { + if detect.GithubActionRunner() && runtime.GOOS == "darwin" { t.Skipf("skipping this test because Docker can not run in macos on github action free version. https://github.community/t/is-it-possible-to-install-and-configure-docker-on-macos-runner/16981") } @@ -2062,7 +2063,7 @@ func startMinikubeWithProxy(ctx context.Context, t *testing.T, profile string, p // Use more memory so that we may reliably fit MySQL and nginx memoryFlag := "--memory=4000" // to avoid failure for mysq/pv on virtualbox on darwin on free github actions, - if GithubActionRunner() && VirtualboxDriver() { + if detect.GithubActionRunner() && VirtualboxDriver() { memoryFlag = "--memory=6000" } // passing --api-server-port so later verify it didn't change in soft start. diff --git a/test/integration/functional_test_tunnel_test.go b/test/integration/functional_test_tunnel_test.go index d3e8fc3f80..77d323a3f5 100644 --- a/test/integration/functional_test_tunnel_test.go +++ b/test/integration/functional_test_tunnel_test.go @@ -38,6 +38,7 @@ import ( "k8s.io/minikube/pkg/kapi" "k8s.io/minikube/pkg/minikube/config" + "k8s.io/minikube/pkg/minikube/detect" "k8s.io/minikube/pkg/util" "k8s.io/minikube/pkg/util/retry" ) @@ -133,7 +134,7 @@ func validateTunnelStart(ctx context.Context, t *testing.T, profile string) { // validateServiceStable starts nginx pod, nginx service and waits nginx having loadbalancer ingress IP func validateServiceStable(ctx context.Context, t *testing.T, profile string) { - if GithubActionRunner() && runtime.GOOS == "darwin" { + if detect.GithubActionRunner() && runtime.GOOS == "darwin" { t.Skip("The test WaitService is broken on github actions in macos https://github.com/kubernetes/minikube/issues/8434") } checkRoutePassword(t) @@ -192,7 +193,7 @@ func validateAccessDirect(ctx context.Context, t *testing.T, profile string) { if runtime.GOOS == "windows" { t.Skip("skipping: access direct test is broken on windows: https://github.com/kubernetes/minikube/issues/8304") } - if GithubActionRunner() && runtime.GOOS == "darwin" { + if detect.GithubActionRunner() && runtime.GOOS == "darwin" { t.Skip("skipping: access direct test is broken on github actions on macos https://github.com/kubernetes/minikube/issues/8434") } @@ -240,7 +241,7 @@ func validateAccessDirect(ctx context.Context, t *testing.T, profile string) { // validateDNSDig validates if the DNS forwarding works by dig command DNS lookup // NOTE: DNS forwarding is experimental: https://minikube.sigs.k8s.io/docs/handbook/accessing/#dns-resolution-experimental func validateDNSDig(ctx context.Context, t *testing.T, profile string) { - if GithubActionRunner() && runtime.GOOS == "darwin" { + if detect.GithubActionRunner() && runtime.GOOS == "darwin" { t.Skip("skipping: access direct test is broken on github actions on macos https://github.com/kubernetes/minikube/issues/8434") } @@ -275,7 +276,7 @@ func validateDNSDig(ctx context.Context, t *testing.T, profile string) { // validateDNSDscacheutil validates if the DNS forwarding works by dscacheutil command DNS lookup // NOTE: DNS forwarding is experimental: https://minikube.sigs.k8s.io/docs/handbook/accessing/#dns-resolution-experimental func validateDNSDscacheutil(ctx context.Context, t *testing.T, profile string) { - if GithubActionRunner() && runtime.GOOS == "darwin" { + if detect.GithubActionRunner() && runtime.GOOS == "darwin" { t.Skip("skipping: access direct test is broken on github actions on macos https://github.com/kubernetes/minikube/issues/8434") } @@ -300,7 +301,7 @@ func validateDNSDscacheutil(ctx context.Context, t *testing.T, profile string) { // validateAccessDNS validates if the test service can be accessed with DNS forwarding from host // NOTE: DNS forwarding is experimental: https://minikube.sigs.k8s.io/docs/handbook/accessing/#dns-resolution-experimental func validateAccessDNS(ctx context.Context, t *testing.T, profile string) { - if GithubActionRunner() && runtime.GOOS == "darwin" { + if detect.GithubActionRunner() && runtime.GOOS == "darwin" { t.Skip("skipping: access direct test is broken on github actions on macos https://github.com/kubernetes/minikube/issues/8434") } diff --git a/test/integration/main_test.go b/test/integration/main_test.go index b59b7705e6..67e85b6b8b 100644 --- a/test/integration/main_test.go +++ b/test/integration/main_test.go @@ -165,12 +165,6 @@ func ContainerRuntime() string { return constants.DefaultContainerRuntime } -// GithubActionRunner returns true if running inside a github action runner -func GithubActionRunner() bool { - // based on https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables - return os.Getenv("GITHUB_ACTIONS") == "true" -} - // arm64Platform returns true if running on arm64/* platform func arm64Platform() bool { return runtime.GOARCH == "arm64"