Skip to content

Commit e1d0979

Browse files
authored
Merge pull request #3908 from k0sproject/simpler-k0sctl-bumps
Automate k0sctl version setting across test suites
2 parents 5a8fb82 + df8b408 commit e1d0979

File tree

5 files changed

+37
-19
lines changed

5 files changed

+37
-19
lines changed

.github/workflows/check-network.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ jobs:
1515
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_TERRAFORM_KEY }}
1616
AWS_DEFAULT_REGION: eu-west-1
1717
TF_VERSION: 1.2.2
18-
K0SCTL_VERSION: 0.17.2
1918
KUBECONFIG: ${{ github.workspace }}/kubeconfig
2019

2120
name: "K8s Network Conformance Testing"
@@ -131,11 +130,16 @@ jobs:
131130
132131
terraform apply -auto-approve
133132
133+
- name: Set k0sctl version
134+
run: |
135+
version=$(cd hack/tool; go list -m -f '{{.Version}}' github.com/k0sproject/k0sctl)
136+
echo "K0SCTL_VERSION=${version}" >> $GITHUB_ENV
137+
134138
- name: Create k0s Cluster using k0sctl
135139
id: k0sctl
136140
run: |
137141
# download k0sctl
138-
curl --silent -L "https://github.com/k0sproject/k0sctl/releases/download/v${K0SCTL_VERSION}/k0sctl-linux-x64" -o k0sctl
142+
curl --silent -L "https://github.com/k0sproject/k0sctl/releases/download/${K0SCTL_VERSION}/k0sctl-linux-x64" -o k0sctl
139143
chmod +x ./k0sctl
140144
./k0sctl apply -c k0sctl.yaml
141145

.github/workflows/ostests-e2e.yaml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ on:
3535
k0sctl-version:
3636
type: string
3737
description: The k0sctl version to use when bootstrapping the test cluster.
38-
default: 0.17.2
3938
secrets:
4039
aws-access-key-id:
4140
description: The AWS access key ID to use when provisioning test resources.
@@ -93,17 +92,27 @@ jobs:
9392
name: k0s-linux-amd64
9493
path: ${{ github.workspace }}/.cache
9594

95+
- name: Set k0sctl version
96+
run: |
97+
if [ -z "${{ inputs.k0sctl-version }}" ]; then
98+
version=$(grep k0sproject/k0sctl hack/tool/go.mod|cut -d" " -f2)
99+
echo "Detected k0sctl dependency version ${version}"
100+
else
101+
version="${{ inputs.k0sctl-version }}"
102+
echo "Using given k0sctl version ${version}"
103+
fi
104+
echo "K0SCTL_VERSION=${version}" >> $GITHUB_ENV
105+
96106
- name: "Terraform :: Requisites :: Prepare"
97107
env:
98-
K0SCTL_VERSION: ${{ inputs.k0sctl-version }}
99108
K0S_VERSION: ${{ inputs.k0s-version }}
100109
K0S_EXECUTABLE_PATH: ${{ github.workspace }}/.cache/k0s
101110
run: |
102111
kubectl version --client
103112
jq --version
104113
105114
mkdir -p "$(dirname -- "$TF_VAR_k0sctl_executable_path")"
106-
curl -sSLo "$TF_VAR_k0sctl_executable_path" "https://github.com/k0sproject/k0sctl/releases/download/v${K0SCTL_VERSION}/k0sctl-linux-x64"
115+
curl -sSLo "$TF_VAR_k0sctl_executable_path" "https://github.com/k0sproject/k0sctl/releases/download/${K0SCTL_VERSION}/k0sctl-linux-x64"
107116
chmod +x -- "$TF_VAR_k0sctl_executable_path"
108117
"$TF_VAR_k0sctl_executable_path" version
109118

.github/workflows/release.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ on:
55
tags:
66
- v* # Push events to matching v*, i.e. v1.0, v20.15.10
77

8-
env:
9-
K0SCTL_VERSION: 0.13.2
10-
118
jobs:
129
release:
1310
env:
@@ -612,11 +609,16 @@ jobs:
612609
613610
terraform apply -auto-approve
614611
612+
- name: Set k0sctl version
613+
run: |
614+
version=$(cd hack/tool; go list -m -f '{{.Version}}' github.com/k0sproject/k0sctl)
615+
echo "K0SCTL_VERSION=${version}" >> $GITHUB_ENV
616+
615617
- name: Create k0s Cluster using k0sctl
616618
id: k0sctl
617619
run: |
618620
# download k0sctl
619-
curl --silent -L "https://github.com/k0sproject/k0sctl/releases/download/v${K0SCTL_VERSION}/k0sctl-linux-x64" -o k0sctl
621+
curl --silent -L "https://github.com/k0sproject/k0sctl/releases/download/${K0SCTL_VERSION}/k0sctl-linux-x64" -o k0sctl
620622
chmod +x ./k0sctl
621623
./k0sctl apply -c k0sctl.yaml
622624

inttest/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ check-nllb: TIMEOUT=15m
115115
include Makefile.variables
116116

117117
$(smoketests): K0S_PATH ?= $(realpath ../k0s)
118+
$(smoketests): K0SCTL_VERSION ?= $(shell grep k0sproject/k0sctl ../hack/tool/go.mod | cut -d" " -f2)
118119
$(smoketests): K0S_IMAGES_BUNDLE ?= $(realpath ../airgap-image-bundle-linux-$(ARCH).tar)
119120
$(smoketests): .bootloose-alpine.stamp
120121
$(smoketests): TEST_PACKAGE ?= $(subst check-,,$@)
@@ -123,6 +124,7 @@ $(smoketests):
123124
K0S_UPDATE_FROM_PATH='$(K0S_UPDATE_FROM_PATH)' \
124125
K0S_IMAGES_BUNDLE='$(K0S_IMAGES_BUNDLE)' \
125126
K0S_UPDATE_TO_VERSION='$(K0S_UPDATE_TO_VERSION)' \
127+
K0SCTL_VERSION='$(K0SCTL_VERSION)' \
126128
go test -count=1 -v -timeout $(TIMEOUT) github.com/k0sproject/k0s/inttest/$(TEST_PACKAGE)
127129
.PHONY: clean
128130

inttest/k0sctl/k0sctl_test.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,19 @@ import (
3737
"github.com/k0sproject/k0s/inttest/common"
3838
)
3939

40-
const k0sctlVersion = "v0.17.2"
41-
4240
type K0sctlSuite struct {
4341
common.BootlooseSuite
4442
k0sctlEnv []string
4543
}
4644

47-
func (s *K0sctlSuite) haveLatest() bool {
45+
func (s *K0sctlSuite) haveVersion(version string) bool {
4846
cmd := exec.Command("./k0sctl", "version")
4947
cmd.Env = s.k0sctlEnv
5048
out, err := cmd.Output()
5149
if err != nil {
5250
return false
5351
}
54-
return strings.Contains(string(out), fmt.Sprintf("%s\n", k0sctlVersion))
52+
return strings.Contains(string(out), fmt.Sprintf("%s\n", version))
5553
}
5654

5755
func k0sctlFilename() string {
@@ -76,15 +74,15 @@ func k0sctlFilename() string {
7674
return fmt.Sprintf("k0sctl-%s-%s%s", os, arch, ext)
7775
}
7876

79-
func (s *K0sctlSuite) downloadK0sctl() {
80-
if s.haveLatest() {
81-
s.T().Logf("Already have k0sctl %s", k0sctlVersion)
77+
func (s *K0sctlSuite) downloadK0sctl(version string) {
78+
if s.haveVersion(version) {
79+
s.T().Logf("Already have k0sctl %s", version)
8280
return
8381
}
8482

85-
s.T().Logf("Downloading k0sctl %s", k0sctlVersion)
83+
s.T().Logf("Downloading k0sctl %s", version)
8684

87-
req, err := http.NewRequest("GET", fmt.Sprintf("https://github.com/k0sproject/k0sctl/releases/download/%s/%s", k0sctlVersion, k0sctlFilename()), nil)
85+
req, err := http.NewRequest("GET", fmt.Sprintf("https://github.com/k0sproject/k0sctl/releases/download/%s/%s", version, k0sctlFilename()), nil)
8886
s.Require().NoError(err)
8987
resp, err := http.DefaultClient.Do(req)
9088
s.Require().NoError(err)
@@ -187,10 +185,13 @@ func (s *K0sctlSuite) k0sctlApply(cfg map[string]interface{}) {
187185

188186
func (s *K0sctlSuite) TestK0sGetsUp() {
189187
k0sBinaryPath := os.Getenv("K0S_PATH")
188+
s.Require().NotEmpty(k0sBinaryPath, "K0S_PATH env var must be set")
190189
k0sVersion, err := exec.Command(k0sBinaryPath, "version").Output()
191190
s.Require().NoError(err, "failed to get k0s version")
191+
k0sctlVersion := os.Getenv("K0SCTL_VERSION")
192+
s.Require().NotEmpty(k0sctlVersion, "K0SCTL_VERSION env var must be set")
192193

193-
s.downloadK0sctl()
194+
s.downloadK0sctl(k0sctlVersion)
194195
cfg := s.k0sctlInitConfig()
195196

196197
spec, ok := cfg["spec"].(map[string]interface{})

0 commit comments

Comments
 (0)