Skip to content

Commit 3b99682

Browse files
committed
Don't use Bazel for tests
1 parent 906f077 commit 3b99682

File tree

7 files changed

+153
-79
lines changed

7 files changed

+153
-79
lines changed

.github/workflows/bazel.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Bazel
2+
3+
on:
4+
- push
5+
- pull_request
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- name: Install bazelisk
15+
run: |
16+
curl -LO "https://github.com/bazelbuild/bazelisk/releases/download/v1.20.0/bazelisk-linux-amd64"
17+
mkdir -p "${GITHUB_WORKSPACE}/bin/"
18+
mv bazelisk-linux-amd64 "${GITHUB_WORKSPACE}/bin/bazel"
19+
chmod +x "${GITHUB_WORKSPACE}/bin/bazel"
20+
21+
- name: Build etcd-manager
22+
run: |
23+
./dev/build-assets.sh $(git describe --always 2>/dev/null)
24+
25+
test:
26+
runs-on: ubuntu-latest
27+
28+
steps:
29+
- uses: actions/checkout@v4
30+
31+
- name: Install bazelisk
32+
run: |
33+
curl -LO "https://github.com/bazelbuild/bazelisk/releases/download/v1.20.0/bazelisk-linux-amd64"
34+
mkdir -p "${GITHUB_WORKSPACE}/bin/"
35+
mv bazelisk-linux-amd64 "${GITHUB_WORKSPACE}/bin/bazel"
36+
chmod +x "${GITHUB_WORKSPACE}/bin/bazel"
37+
38+
- name: Test etcd-manager
39+
run: |
40+
"${GITHUB_WORKSPACE}/bin/bazel" test --test_output=streamed -- //... -//test/integration/upgradedowngrade:all -//test/integration/backuprestore:all
41+
42+
test-upgradedowngrade:
43+
runs-on: ubuntu-latest
44+
45+
steps:
46+
- uses: actions/checkout@v4
47+
48+
- name: Install bazelisk
49+
run: |
50+
curl -LO "https://github.com/bazelbuild/bazelisk/releases/download/v1.20.0/bazelisk-linux-amd64"
51+
mkdir -p "${GITHUB_WORKSPACE}/bin/"
52+
mv bazelisk-linux-amd64 "${GITHUB_WORKSPACE}/bin/bazel"
53+
chmod +x "${GITHUB_WORKSPACE}/bin/bazel"
54+
55+
- name: Test etcd-manager
56+
run: |
57+
"${GITHUB_WORKSPACE}/bin/bazel" test --test_output=streamed -- //test/integration/upgradedowngrade:all
58+
59+
test-backuprestore:
60+
runs-on: ubuntu-latest
61+
62+
steps:
63+
- uses: actions/checkout@v4
64+
65+
- name: Install bazelisk
66+
run: |
67+
curl -LO "https://github.com/bazelbuild/bazelisk/releases/download/v1.20.0/bazelisk-linux-amd64"
68+
mkdir -p "${GITHUB_WORKSPACE}/bin/"
69+
mv bazelisk-linux-amd64 "${GITHUB_WORKSPACE}/bin/bazel"
70+
chmod +x "${GITHUB_WORKSPACE}/bin/bazel"
71+
72+
- name: Test etcd-manager
73+
run: |
74+
"${GITHUB_WORKSPACE}/bin/bazel" test --test_output=streamed -- //test/integration/backuprestore:all

.github/workflows/ko.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.

.github/workflows/main.yml

Lines changed: 17 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Bazel
1+
name: CI
22

33
on:
44
- push
@@ -7,68 +7,42 @@ on:
77
jobs:
88
build:
99
runs-on: ubuntu-latest
10-
1110
steps:
1211
- uses: actions/checkout@v4
13-
14-
- name: Install bazelisk
12+
with:
13+
fetch-tags: 'true'
14+
- name: Build etcd-manager-slim
1515
run: |
16-
curl -LO "https://github.com/bazelbuild/bazelisk/releases/download/v1.20.0/bazelisk-linux-amd64"
17-
mkdir -p "${GITHUB_WORKSPACE}/bin/"
18-
mv bazelisk-linux-amd64 "${GITHUB_WORKSPACE}/bin/bazel"
19-
chmod +x "${GITHUB_WORKSPACE}/bin/bazel"
20-
21-
- name: Build etcd-manager
22-
run: |
23-
./dev/build-assets.sh $(git describe --always 2>/dev/null)
16+
make ko-dist
2417
2518
test:
2619
runs-on: ubuntu-latest
27-
2820
steps:
2921
- uses: actions/checkout@v4
30-
31-
- name: Install bazelisk
32-
run: |
33-
curl -LO "https://github.com/bazelbuild/bazelisk/releases/download/v1.20.0/bazelisk-linux-amd64"
34-
mkdir -p "${GITHUB_WORKSPACE}/bin/"
35-
mv bazelisk-linux-amd64 "${GITHUB_WORKSPACE}/bin/bazel"
36-
chmod +x "${GITHUB_WORKSPACE}/bin/bazel"
37-
38-
- name: Test etcd-manager
22+
- name: Run tests
3923
run: |
40-
"${GITHUB_WORKSPACE}/bin/bazel" test --test_output=streamed -- //... -//test/integration/upgradedowngrade:all -//test/integration/backuprestore:all
24+
make test-short
4125
4226
test-upgradedowngrade:
4327
runs-on: ubuntu-latest
44-
4528
steps:
4629
- uses: actions/checkout@v4
47-
48-
- name: Install bazelisk
49-
run: |
50-
curl -LO "https://github.com/bazelbuild/bazelisk/releases/download/v1.20.0/bazelisk-linux-amd64"
51-
mkdir -p "${GITHUB_WORKSPACE}/bin/"
52-
mv bazelisk-linux-amd64 "${GITHUB_WORKSPACE}/bin/bazel"
53-
chmod +x "${GITHUB_WORKSPACE}/bin/bazel"
54-
55-
- name: Test etcd-manager
30+
- name: Run upgradedowngrade tests
5631
run: |
57-
"${GITHUB_WORKSPACE}/bin/bazel" test --test_output=streamed -- //test/integration/upgradedowngrade:all
32+
make test-upgradedowngrade
5833
5934
test-backuprestore:
6035
runs-on: ubuntu-latest
61-
6236
steps:
6337
- uses: actions/checkout@v4
64-
65-
- name: Install bazelisk
38+
- name: Run backuprestore tests
6639
run: |
67-
curl -LO "https://github.com/bazelbuild/bazelisk/releases/download/v1.20.0/bazelisk-linux-amd64"
68-
mkdir -p "${GITHUB_WORKSPACE}/bin/"
69-
mv bazelisk-linux-amd64 "${GITHUB_WORKSPACE}/bin/bazel"
70-
chmod +x "${GITHUB_WORKSPACE}/bin/bazel"
40+
make test-backuprestore
7141
72-
- name: Test etcd-manager
42+
test-integration:
43+
runs-on: ubuntu-latest
44+
steps:
45+
- uses: actions/checkout@v4
46+
- name: Run integration tests
7347
run: |
74-
"${GITHUB_WORKSPACE}/bin/bazel" test --test_output=streamed -- //test/integration/backuprestore:all
48+
make test-integration

Makefile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,3 +176,32 @@ ko-export-etcd-manager-slim-amd64 ko-export-etcd-manager-slim-arm64: ko-export-e
176176
.PHONY: ko-push-etcd-manager-slim
177177
ko-push-etcd-manager-slim:
178178
KO_DEFAULTBASEIMAGE="debian:12-slim" KO_DOCKER_REPO="${IMAGE_BASE}etcd-manager-slim" ${KO} build --tags ${STABLE_DOCKER_TAG} --platform=linux/amd64,linux/arm64 --bare ./cmd/etcd-manager/
179+
180+
# Must match AllEtcdVersions in pkg/etcdversions/mappings.go
181+
.PHONY: download-etcd-versions
182+
download-etcd-versions:
183+
dev/download-etcd.sh 3.1.12
184+
dev/download-etcd.sh 3.2.18
185+
dev/download-etcd.sh 3.2.24
186+
dev/download-etcd.sh 3.3.10
187+
dev/download-etcd.sh 3.3.13
188+
dev/download-etcd.sh 3.3.17
189+
dev/download-etcd.sh 3.4.3
190+
dev/download-etcd.sh 3.4.13
191+
dev/download-etcd.sh 3.5.7
192+
193+
.PHONY: test-short
194+
test-short:
195+
go test -v -short ./...
196+
197+
.PHONY: test-integration
198+
test-integration: download-etcd-versions
199+
go test -v ./test/integration/backuprestore
200+
201+
.PHONY: test-backuprestore
202+
test-backuprestore: download-etcd-versions
203+
go test -v ./test/integration/backuprestore
204+
205+
.PHONY: test-upgradedowngrade
206+
test-upgradedowngrade: download-etcd-versions
207+
go test -v ./test/integration/upgradedowngrade

dev/download-etcd.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2025 The Kubernetes Authors.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
set -o errexit
17+
set -o nounset
18+
set -o pipefail
19+
20+
ETCD_VER="v$1"
21+
ETCD_DIR="/tmp/etcd-${ETCD_VER}"
22+
ETCD_URL="https://github.com/etcd-io/etcd/releases/download/${ETCD_VER}/etcd-${ETCD_VER}-linux-amd64.tar.gz"
23+
ETCD_TMP="/tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz"
24+
25+
if [ ! -f "${ETCD_DIR:-}/etcd" ]; then
26+
echo "Downloading etcd from ${ETCD_URL} to ${ETCD_DIR}"
27+
curl -Ls -o "${ETCD_TMP}" "${ETCD_URL}"
28+
mkdir -p "${ETCD_DIR}"
29+
tar xzf "${ETCD_TMP}" -C "${ETCD_DIR}" --strip-components=1 --exclude=Documentation
30+
rm -f "${ETCD_TMP}"
31+
fi

pkg/etcd/etcdprocess.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package etcd
1919
import (
2020
"crypto/tls"
2121
"crypto/x509"
22-
"flag"
2322
"fmt"
2423
"net"
2524
"net/url"
@@ -41,16 +40,10 @@ import (
4140
"sigs.k8s.io/etcd-manager/pkg/pki"
4241
)
4342

44-
var baseDirs = []string{"/opt"}
43+
var baseDirs = []string{"/opt", "/tmp"}
4544
var isTest = false
4645

4746
func init() {
48-
// For bazel
49-
// TODO: Use a flag?
50-
51-
// used to fix glog parse error.
52-
_ = flag.CommandLine.Parse([]string{})
53-
5447
if os.Getenv("TEST_SRCDIR") != "" && os.Getenv("TEST_WORKSPACE") != "" {
5548
d := filepath.Join(os.Getenv("TEST_SRCDIR"), os.Getenv("TEST_WORKSPACE"))
5649
klog.Infof("found bazel binary location: %s", d)

pkg/etcdversions/mappings.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ const (
3535
Version_3_3_17 = "3.3.17"
3636
Version_3_4_3 = "3.4.3"
3737
Version_3_4_13 = "3.4.13"
38-
Version_3_5_0 = "3.5.0"
39-
Version_3_5_1 = "3.5.1"
40-
Version_3_5_3 = "3.5.3"
41-
Version_3_5_4 = "3.5.4"
42-
Version_3_5_6 = "3.5.6"
4338
Version_3_5_7 = "3.5.7"
4439
)
4540

@@ -52,11 +47,7 @@ var AllEtcdVersions = []string{
5247
Version_3_3_17,
5348
Version_3_4_3,
5449
Version_3_4_13,
55-
Version_3_5_0,
56-
Version_3_5_1,
57-
Version_3_5_3,
58-
Version_3_5_4,
59-
Version_3_5_6,
50+
Version_3_5_7,
6051
}
6152

6253
var LatestEtcdVersions = []string{

0 commit comments

Comments
 (0)