diff --git a/.github/workflows/test-e2e-shim.yml b/.github/workflows/test-e2e-shim.yml index 4f04776759..b79de0b0ca 100644 --- a/.github/workflows/test-e2e-shim.yml +++ b/.github/workflows/test-e2e-shim.yml @@ -37,6 +37,13 @@ jobs: run: | echo skipped + validate-without-cluster: + runs-on: ubuntu-latest + steps: + - name: Skipped + run: | + echo skipped + validate-k3d: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index c5ae014b6b..09f5ba7157 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -43,6 +43,38 @@ jobs: path: build/ retention-days: 1 + validate-without-cluster: + runs-on: ubuntu-latest + needs: build + steps: + - name: Checkout + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 + + - name: Download build artifacts + uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 + with: + name: build-artifacts + path: build/ + + - name: Setup golang + uses: ./.github/actions/golang + + - name: Make Zarf executable + run: | + chmod +x build/zarf + + # Before we run the regular tests we need to aggressively cleanup files to reduce disk pressure + - name: Cleanup files + uses: ./.github/actions/cleanup-files + + - name: Run tests + run: | + make test-e2e-without-cluster ARCH=amd64 + + - name: Save logs + if: always() + uses: ./.github/actions/save-logs + # Run the tests on k3d validate-k3d: runs-on: ubuntu-latest @@ -73,7 +105,7 @@ jobs: - name: Run tests run: | - make test-e2e ARCH=amd64 + make test-e2e-with-cluster ARCH=amd64 - name: Save logs if: always() @@ -109,7 +141,7 @@ jobs: # in a previous step. This test run will use Zarf to create a K3s cluster, and a brand new cluster will be # used for each test run: | - sudo env "PATH=$PATH" CI=true APPLIANCE_MODE=true make test-e2e ARCH=amd64 + sudo env "PATH=$PATH" CI=true APPLIANCE_MODE=true make test-e2e-with-cluster ARCH=amd64 - name: Save logs if: always() @@ -147,7 +179,7 @@ jobs: - name: Run tests run: | - make test-e2e ARCH=amd64 + make test-e2e-with-cluster ARCH=amd64 - name: Save logs if: always() @@ -183,7 +215,7 @@ jobs: - name: Run tests run: | - make test-e2e ARCH=amd64 + make test-e2e-with-cluster ARCH=amd64 - name: Save logs if: always() diff --git a/.github/workflows/test-upgrade.yml b/.github/workflows/test-upgrade.yml index 1b3810a1c1..bf79bd3d71 100644 --- a/.github/workflows/test-upgrade.yml +++ b/.github/workflows/test-upgrade.yml @@ -90,7 +90,7 @@ jobs: # NOTE: "PATH=$PATH" preserves the default user $PATH. This is needed to maintain the version of go installed # in a previous step. This test run will use this PR's Zarf to create a K3s cluster. run: | - sudo env "PATH=$PATH" CI=true APPLIANCE_MODE=true APPLIANCE_MODE_KEEP=true make test-e2e ARCH=amd64 + sudo env "PATH=$PATH" CI=true APPLIANCE_MODE=true APPLIANCE_MODE_KEEP=true make test-e2e-with-cluster ARCH=amd64 - name: "Describe nodes, pods and deployments" # NOTE: We describe nodes, pods and deployments here to help understand failures diff --git a/Makefile b/Makefile index 1c9af0815f..3c4d044cf6 100644 --- a/Makefile +++ b/Makefile @@ -34,7 +34,7 @@ BUILD_ARGS := -s -w -X 'github.com/defenseunicorns/zarf/src/config.CLIVersion=$( .PHONY: help help: ## Display this help information - @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \ + @grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) \ | sort | awk 'BEGIN {FS = ":.*?## "}; \ {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' @@ -142,9 +142,17 @@ build-injector-linux: ## Build the Zarf injector for AMD64 and ARM64 ## NOTE: Requires an existing cluster or the env var APPLIANCE_MODE=true .PHONY: test-e2e -test-e2e: build-examples ## Run all of the core Zarf CLI E2E tests (builds any deps that aren't present) +test-e2e: test-e2e-without-cluster test-e2e-with-cluster ## Run all of the core Zarf CLI E2E tests (builds any deps that aren't present) + +.PHONY: test-e2e-with-cluster +test-e2e-with-cluster: build-examples ## Run all of the core Zarf CLI E2E tests that DO require a cluster (builds any deps that aren't present) + @test -s ./build/zarf-init-$(ARCH)-$(CLI_VERSION).tar.zst || $(MAKE) init-package + cd src/test/e2e && go test ./main_test.go ./[2-9]*.go -failfast -v -timeout 35m + +.PHONY: test-e2e-without-cluster +test-e2e-without-cluster: build-examples ## Run all of the core Zarf CLI E2E tests that DO NOT require a cluster (builds any deps that aren't present) @test -s ./build/zarf-init-$(ARCH)-$(CLI_VERSION).tar.zst || $(MAKE) init-package - cd src/test/e2e && go test -failfast -v -timeout 35m + cd src/test/e2e && go test ./main_test.go ./[01]* -failfast -v -timeout 35m ## NOTE: Requires an existing cluster .PHONY: test-external diff --git a/src/test/external/ext_in_cluster_test.go b/src/test/external/ext_in_cluster_test.go index 4aa2f08a9f..c52d3c682f 100644 --- a/src/test/external/ext_in_cluster_test.go +++ b/src/test/external/ext_in_cluster_test.go @@ -34,7 +34,7 @@ func (suite *ExtInClusterTestSuite) SetupSuite() { suite.Assertions = require.New(suite.T()) // Install a gitea chart to the k8s cluster to act as the 'remote' git server - giteaChartURL := "https://dl.gitea.io/charts/gitea-5.0.8.tgz" + giteaChartURL := "https://dl.gitea.io/charts/gitea-8.3.0.tgz" helmInstallArgs := []string{"install", "gitea", giteaChartURL, "-f", "gitea-values.yaml", "-n=git-server", "--create-namespace"} err := exec.CmdWithPrint("helm", helmInstallArgs...) suite.NoError(err, "unable to install gitea chart") diff --git a/src/test/external/ext_out_cluster_test.go b/src/test/external/ext_out_cluster_test.go index c6b488dd1a..92be12ffe1 100644 --- a/src/test/external/ext_out_cluster_test.go +++ b/src/test/external/ext_out_cluster_test.go @@ -23,6 +23,7 @@ const ( giteaIP = "172.31.0.99" giteaHost = "gitea.localhost" registryHost = "registry.localhost" + clusterName = "zarf-external-test" ) var outClusterCredentialArgs = []string{ @@ -42,7 +43,7 @@ func (suite *ExtOutClusterTestSuite) SetupSuite() { suite.Assertions = require.New(suite.T()) // Teardown any leftovers from previous tests - _ = exec.CmdWithPrint("k3d", "cluster", "delete") + _ = exec.CmdWithPrint("k3d", "cluster", "delete", clusterName) _ = exec.CmdWithPrint("k3d", "registry", "delete", registryHost) _ = exec.CmdWithPrint("docker", "network", "remove", network) @@ -55,7 +56,7 @@ func (suite *ExtOutClusterTestSuite) SetupSuite() { suite.NoError(err, "unable to create the k3d registry") // Create a k3d cluster with the proper networking and aliases - err = exec.CmdWithPrint("k3d", "cluster", "create", "--registry-use", "k3d-"+registryHost+":5000", "--host-alias", giteaIP+":"+giteaHost, "--network", network) + err = exec.CmdWithPrint("k3d", "cluster", "create", clusterName, "--registry-use", "k3d-"+registryHost+":5000", "--host-alias", giteaIP+":"+giteaHost, "--network", network) suite.NoError(err, "unable to create the k3d cluster") // Install a gitea server via docker compose to act as the 'remote' git server @@ -75,7 +76,7 @@ func (suite *ExtOutClusterTestSuite) SetupSuite() { func (suite *ExtOutClusterTestSuite) TearDownSuite() { // Tear down all of that stuff we made for local runs - err := exec.CmdWithPrint("k3d", "cluster", "delete") + err := exec.CmdWithPrint("k3d", "cluster", "delete", clusterName) suite.NoError(err, "unable to teardown cluster") err = exec.CmdWithPrint("docker", "compose", "down")