Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,11 @@ fuzz:
verify: verify-gofmt verify-bom verify-lint verify-dep verify-shellcheck verify-goword \
verify-govet verify-license-header verify-mod-tidy \
verify-shellws verify-proto-annotations verify-genproto verify-yamllint \
verify-govet-shadow verify-markdown-marker verify-go-versions verify-gomodguard
verify-govet-shadow verify-markdown-marker verify-go-versions verify-gomodguard \
verify-go-workspace

.PHONY: fix
fix: fix-bom fix-lint fix-yamllint sync-toolchain-directive
fix: fix-bom fix-lint fix-yamllint sync-toolchain-directive update-go-workspace
./scripts/fix.sh

.PHONY: verify-gofmt
Expand Down Expand Up @@ -237,10 +238,18 @@ verify-go-versions:
verify-gomodguard:
PASSES="gomodguard" ./scripts/test.sh

.PHONY: verify-go-workspace
verify-go-workspace:
PASSES="go_workspace" ./scripts/test.sh

.PHONY: sync-toolchain-directive
sync-toolchain-directive:
./scripts/sync_go_toolchain_directive.sh

.PHONY: markdown-diff-lint
markdown-diff-lint:
./scripts/markdown_diff_lint.sh

.PHONY: update-go-workspace
update-go-workspace:
./scripts/update_go_workspace.sh
2 changes: 1 addition & 1 deletion api/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module go.etcd.io/etcd/api/v3

go 1.25
go 1.25.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why set to 1.25.0 while toolchain is on 1.25.1?

Copy link
Member Author

@ivanvc ivanvc Oct 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Human error due to rebasing 😅😆

Nevermind, this is the minimum Go version. We usually leave w/o the patch until a dependency forces us to set it to the "0" patch (1.25.0 in this case).


toolchain go1.25.1

Expand Down
2 changes: 1 addition & 1 deletion cache/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module go.etcd.io/etcd/cache/v3

go 1.25
go 1.25.0

toolchain go1.25.1

Expand Down
2 changes: 1 addition & 1 deletion client/pkg/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module go.etcd.io/etcd/client/pkg/v3

go 1.25
go 1.25.0

toolchain go1.25.1

Expand Down
2 changes: 1 addition & 1 deletion client/v3/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module go.etcd.io/etcd/client/v3

go 1.25
go 1.25.0

toolchain go1.25.1

Expand Down
2 changes: 1 addition & 1 deletion etcdctl/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module go.etcd.io/etcd/etcdctl/v3

go 1.25
go 1.25.0

toolchain go1.25.1

Expand Down
2 changes: 1 addition & 1 deletion etcdutl/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module go.etcd.io/etcd/etcdutl/v3

go 1.25
go 1.25.0

toolchain go1.25.1

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module go.etcd.io/etcd/v3

go 1.25
go 1.25.0

toolchain go1.25.1

Expand Down
21 changes: 21 additions & 0 deletions go.work
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// This is a generated file. Do not edit directly.

go 1.25.0

toolchain go1.25.1

use (
.
./api
./cache
./client/pkg
./client/v3
./etcdctl
./etcdutl
./pkg
./server
./tests
./tools/mod
./tools/rw-heatmaps
./tools/testgrid-analysis
)
1,393 changes: 1,393 additions & 0 deletions go.work.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module go.etcd.io/etcd/pkg/v3

go 1.25
go 1.25.0

toolchain go1.25.1

Expand Down
1 change: 1 addition & 0 deletions scripts/sync_go_toolchain_directive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ source ./scripts/test_lib.sh

TARGET_GO_VERSION="${TARGET_GO_VERSION:-"$(cat "${ETCD_ROOT_DIR}/.go-version")"}"
find . -name 'go.mod' -exec go mod edit -toolchain=go"${TARGET_GO_VERSION}" {} \;
go work edit -toolchain=go"${TARGET_GO_VERSION}"
20 changes: 18 additions & 2 deletions scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -516,10 +516,15 @@ function bom_pass {
run cp go.sum go.sum.tmp || return 2
run cp go.mod go.mod.tmp || return 2

# Intentionally run the command once first, so it fetches dependencies. The exit code on the first
# run in a just cloned repository is always dirty.
GOOS=linux run_go_tool github.com/appscodelabs/license-bill-of-materials \
--override-file ./bill-of-materials.override.json "${modules[@]}"

# BOM file should be generated for linux. Otherwise running this command on other operating systems such as OSX
# results in certain dependencies being excluded from the BOM file, such as procfs.
# results in certain dependencies being excluded from the BOM file, such as procfs.
# For more info, https://github.com/etcd-io/etcd/issues/19665
output=$(GOOS=linux GOFLAGS=-mod=mod run_go_tool github.com/appscodelabs/license-bill-of-materials \
output=$(GOOS=linux run_go_tool github.com/appscodelabs/license-bill-of-materials \
--override-file ./bill-of-materials.override.json \
"${modules[@]}")
code="$?"
Expand Down Expand Up @@ -698,6 +703,17 @@ function genproto_pass {
"${ETCD_ROOT_DIR}/scripts/verify_genproto.sh"
}

function go_workspace_pass {
log_callout "Ensuring go workspace is in sync."

run go mod download
if [ -n "$(git status --porcelain go.work.sum)" ]; then
log_error "Go workspace not in sync."
log_warning "Suggestion: run \"make fix\" to address the issue."
return 255
fi
}

########### MAIN ###############################################################

function run_pass {
Expand Down
43 changes: 43 additions & 0 deletions scripts/update_go_workspace.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env bash
#
# Copyright 2025 The etcd Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Based on k/k scripts/update-go-workspace.sh:
# https://github.com/kubernetes/kubernetes/blob/e2b96b25661849775dedf441b2f5c555392caa84/hack/update-go-workspace.sh

# This script generates go.work so that it includes all Go packages
# in this repo, with a few exceptions.

set -euo pipefail

source ./scripts/test_lib.sh

# Avoid issues and remove the workspace files.
rm -f go.work go.work.sum

# Generate the workspace.
go work init
sed -i -e '1i\// This is a generated file. Do not edit directly.\n' go.work

# Include all submodules from the repository.
git ls-files -z ':(glob)**/go.mod' \
| xargs -0 -n1 dirname -z \
| xargs -0 -n1 go work edit -use

go work edit -toolchain "go$(cat .go-version)"
go work edit -go "$(go mod edit -json | jq -r .Go)"

# generate go.work.sum
go mod download
2 changes: 1 addition & 1 deletion scripts/updatebom.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function bom_fixlet {
# BOM file should be generated for linux. Otherwise running this command on other operating systems such as OSX
# results in certain dependencies being excluded from the BOM file, such as procfs.
# For more info, https://github.com/etcd-io/etcd/issues/19665
if GOOS=linux GOFLAGS=-mod=mod run_go_tool "github.com/appscodelabs/license-bill-of-materials" \
if GOOS=linux run_go_tool "github.com/appscodelabs/license-bill-of-materials" \
--override-file ./bill-of-materials.override.json \
"${modules[@]}" > ./bill-of-materials.json.tmp; then
cp ./bill-of-materials.json.tmp ./bill-of-materials.json
Expand Down
16 changes: 16 additions & 0 deletions scripts/verify_go_versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,20 @@ function verify_go_versions() {
fi
}

# Workaround to get go.work's toolchain, as go work edit -json doesn't return
# the toolchain as of Go 1.24. When this is fixed, we can replace these two
# checks with verify_go_versions go.work
toolchain_version="$(grep toolchain go.work | cut -d' ' -f2)"
if [[ "go${target_go_version}" != "${toolchain_version}" ]]; then
log_error "go toolchain directive out of sync for go.work, got: ${toolchain_version}"
toolchain_out_of_sync="true"
fi
go_line_version="$(go work edit -json | jq -r .Go)"
if ! printf '%s\n' "${go_line_version}" "${target_go_version}" | sort --check=silent --version-sort; then
log_error "go directive in go.work is greater than maximum allowed: go${target_go_version}"
go_line_violation="true"
fi

while read -r mod; do
verify_go_versions "${mod}";
done < <(find . -name 'go.mod')
Expand All @@ -64,3 +78,5 @@ fi
if [[ "${go_line_violation}" == "true" ]] || [[ "${toolchain_out_of_sync}" == "true" ]]; then
exit 1
fi

log_success "SUCCESS: Go toolchain directive in sync"
2 changes: 1 addition & 1 deletion server/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module go.etcd.io/etcd/server/v3

go 1.25
go 1.25.0

toolchain go1.25.1

Expand Down
2 changes: 1 addition & 1 deletion tests/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module go.etcd.io/etcd/tests/v3

go 1.25
go 1.25.0

toolchain go1.25.1

Expand Down
2 changes: 1 addition & 1 deletion tools/rw-heatmaps/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module go.etcd.io/etcd/tools/rw-heatmaps/v3

go 1.25
go 1.25.0

toolchain go1.25.1

Expand Down
2 changes: 1 addition & 1 deletion tools/testgrid-analysis/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module go.etcd.io/etcd/tools/testgrid-analysis/v3

go 1.25
go 1.25.0

toolchain go1.25.1

Expand Down