diff --git a/.github/workflows/check-network.yaml b/.github/workflows/check-network.yaml index 8ff7ef1fb861..d2d6ff994f9a 100644 --- a/.github/workflows/check-network.yaml +++ b/.github/workflows/check-network.yaml @@ -15,7 +15,6 @@ jobs: AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_TERRAFORM_KEY }} AWS_DEFAULT_REGION: eu-west-1 TF_VERSION: 1.2.2 - K0SCTL_VERSION: 0.17.2 KUBECONFIG: ${{ github.workspace }}/kubeconfig name: "K8s Network Conformance Testing" @@ -131,11 +130,16 @@ jobs: terraform apply -auto-approve + - name: Set k0sctl version + run: | + version=$(cd hack/tool; go list -m -f '{{.Version}}' github.com/k0sproject/k0sctl) + echo "K0SCTL_VERSION=${version}" >> $GITHUB_ENV + - name: Create k0s Cluster using k0sctl id: k0sctl run: | # download k0sctl - curl --silent -L "https://github.com/k0sproject/k0sctl/releases/download/v${K0SCTL_VERSION}/k0sctl-linux-x64" -o k0sctl + curl --silent -L "https://github.com/k0sproject/k0sctl/releases/download/${K0SCTL_VERSION}/k0sctl-linux-x64" -o k0sctl chmod +x ./k0sctl ./k0sctl apply -c k0sctl.yaml diff --git a/.github/workflows/ostests-e2e.yaml b/.github/workflows/ostests-e2e.yaml index 8d4103361b0a..1176c132729e 100644 --- a/.github/workflows/ostests-e2e.yaml +++ b/.github/workflows/ostests-e2e.yaml @@ -35,7 +35,6 @@ on: k0sctl-version: type: string description: The k0sctl version to use when bootstrapping the test cluster. - default: 0.17.2 secrets: aws-access-key-id: description: The AWS access key ID to use when provisioning test resources. @@ -93,9 +92,19 @@ jobs: name: k0s-linux-amd64 path: ${{ github.workspace }}/.cache + - name: Set k0sctl version + run: | + if [ -z "${{ inputs.k0sctl-version }}" ]; then + version=$(grep k0sproject/k0sctl hack/tool/go.mod|cut -d" " -f2) + echo "Detected k0sctl dependency version ${version}" + else + version="${{ inputs.k0sctl-version }}" + echo "Using given k0sctl version ${version}" + fi + echo "K0SCTL_VERSION=${version}" >> $GITHUB_ENV + - name: "Terraform :: Requisites :: Prepare" env: - K0SCTL_VERSION: ${{ inputs.k0sctl-version }} K0S_VERSION: ${{ inputs.k0s-version }} K0S_EXECUTABLE_PATH: ${{ github.workspace }}/.cache/k0s run: | @@ -103,7 +112,7 @@ jobs: jq --version mkdir -p "$(dirname -- "$TF_VAR_k0sctl_executable_path")" - curl -sSLo "$TF_VAR_k0sctl_executable_path" "https://github.com/k0sproject/k0sctl/releases/download/v${K0SCTL_VERSION}/k0sctl-linux-x64" + curl -sSLo "$TF_VAR_k0sctl_executable_path" "https://github.com/k0sproject/k0sctl/releases/download/${K0SCTL_VERSION}/k0sctl-linux-x64" chmod +x -- "$TF_VAR_k0sctl_executable_path" "$TF_VAR_k0sctl_executable_path" version diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e6d5db5c8c46..f435c989cc13 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,9 +5,6 @@ on: tags: - v* # Push events to matching v*, i.e. v1.0, v20.15.10 -env: - K0SCTL_VERSION: 0.13.2 - jobs: release: env: @@ -612,11 +609,16 @@ jobs: terraform apply -auto-approve + - name: Set k0sctl version + run: | + version=$(cd hack/tool; go list -m -f '{{.Version}}' github.com/k0sproject/k0sctl) + echo "K0SCTL_VERSION=${version}" >> $GITHUB_ENV + - name: Create k0s Cluster using k0sctl id: k0sctl run: | # download k0sctl - curl --silent -L "https://github.com/k0sproject/k0sctl/releases/download/v${K0SCTL_VERSION}/k0sctl-linux-x64" -o k0sctl + curl --silent -L "https://github.com/k0sproject/k0sctl/releases/download/${K0SCTL_VERSION}/k0sctl-linux-x64" -o k0sctl chmod +x ./k0sctl ./k0sctl apply -c k0sctl.yaml diff --git a/inttest/Makefile b/inttest/Makefile index 889e49c80480..721dd835af90 100644 --- a/inttest/Makefile +++ b/inttest/Makefile @@ -115,6 +115,7 @@ check-nllb: TIMEOUT=15m include Makefile.variables $(smoketests): K0S_PATH ?= $(realpath ../k0s) +$(smoketests): K0SCTL_VERSION ?= $(shell grep k0sproject/k0sctl ../hack/tool/go.mod | cut -d" " -f2) $(smoketests): K0S_IMAGES_BUNDLE ?= $(realpath ../airgap-image-bundle-linux-$(ARCH).tar) $(smoketests): .bootloose-alpine.stamp $(smoketests): TEST_PACKAGE ?= $(subst check-,,$@) @@ -123,6 +124,7 @@ $(smoketests): K0S_UPDATE_FROM_PATH='$(K0S_UPDATE_FROM_PATH)' \ K0S_IMAGES_BUNDLE='$(K0S_IMAGES_BUNDLE)' \ K0S_UPDATE_TO_VERSION='$(K0S_UPDATE_TO_VERSION)' \ + K0SCTL_VERSION='$(K0SCTL_VERSION)' \ go test -count=1 -v -timeout $(TIMEOUT) github.com/k0sproject/k0s/inttest/$(TEST_PACKAGE) .PHONY: clean diff --git a/inttest/k0sctl/k0sctl_test.go b/inttest/k0sctl/k0sctl_test.go index db4b9fe133a1..386a97578602 100644 --- a/inttest/k0sctl/k0sctl_test.go +++ b/inttest/k0sctl/k0sctl_test.go @@ -37,21 +37,19 @@ import ( "github.com/k0sproject/k0s/inttest/common" ) -const k0sctlVersion = "v0.17.2" - type K0sctlSuite struct { common.BootlooseSuite k0sctlEnv []string } -func (s *K0sctlSuite) haveLatest() bool { +func (s *K0sctlSuite) haveVersion(version string) bool { cmd := exec.Command("./k0sctl", "version") cmd.Env = s.k0sctlEnv out, err := cmd.Output() if err != nil { return false } - return strings.Contains(string(out), fmt.Sprintf("%s\n", k0sctlVersion)) + return strings.Contains(string(out), fmt.Sprintf("%s\n", version)) } func k0sctlFilename() string { @@ -76,15 +74,15 @@ func k0sctlFilename() string { return fmt.Sprintf("k0sctl-%s-%s%s", os, arch, ext) } -func (s *K0sctlSuite) downloadK0sctl() { - if s.haveLatest() { - s.T().Logf("Already have k0sctl %s", k0sctlVersion) +func (s *K0sctlSuite) downloadK0sctl(version string) { + if s.haveVersion(version) { + s.T().Logf("Already have k0sctl %s", version) return } - s.T().Logf("Downloading k0sctl %s", k0sctlVersion) + s.T().Logf("Downloading k0sctl %s", version) - req, err := http.NewRequest("GET", fmt.Sprintf("https://github.com/k0sproject/k0sctl/releases/download/%s/%s", k0sctlVersion, k0sctlFilename()), nil) + req, err := http.NewRequest("GET", fmt.Sprintf("https://github.com/k0sproject/k0sctl/releases/download/%s/%s", version, k0sctlFilename()), nil) s.Require().NoError(err) resp, err := http.DefaultClient.Do(req) s.Require().NoError(err) @@ -187,10 +185,13 @@ func (s *K0sctlSuite) k0sctlApply(cfg map[string]interface{}) { func (s *K0sctlSuite) TestK0sGetsUp() { k0sBinaryPath := os.Getenv("K0S_PATH") + s.Require().NotEmpty(k0sBinaryPath, "K0S_PATH env var must be set") k0sVersion, err := exec.Command(k0sBinaryPath, "version").Output() s.Require().NoError(err, "failed to get k0s version") + k0sctlVersion := os.Getenv("K0SCTL_VERSION") + s.Require().NotEmpty(k0sctlVersion, "K0SCTL_VERSION env var must be set") - s.downloadK0sctl() + s.downloadK0sctl(k0sctlVersion) cfg := s.k0sctlInitConfig() spec, ok := cfg["spec"].(map[string]interface{})