Skip to content

Commit

Permalink
fix: use a single source of truth for the go version (#15583) (#15605)
Browse files Browse the repository at this point in the history
go version is defined in two places: go.mod and .go-version
they often get out of sync and it's not clear which is used where.
CI is using the version defined in go.mod which might be outdated compared
to .go-version.

bump go version in go.mod and ensure scripts are using it consistently

remove old jenkins scripts

(cherry picked from commit c24a1cb)

Co-authored-by: kruskall <[email protected]>
  • Loading branch information
mergify[bot] and kruskall authored Feb 7, 2025
1 parent 9732b86 commit 82d44aa
Show file tree
Hide file tree
Showing 15 changed files with 12 additions and 86 deletions.
2 changes: 1 addition & 1 deletion .buildkite/hooks/pre-command
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ GH_TOKEN="${VAULT_GITHUB_TOKEN}"
export GH_TOKEN

echo "--- Setting up the :golang: environment..."
GO_VERSION=$(cat .go-version)
GO_VERSION=$(grep '^go' go.mod | cut -d' ' -f2)
WORKSPACE=$(git rev-parse --show-toplevel)
export GO_VERSION WORKSPACE
get_os_details
Expand Down
2 changes: 1 addition & 1 deletion .ci/scripts/bench.sh
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ if [ "${CI}" == "true" ] ; then
export BUILDKITE_TOKEN="${BUILDKITE_TOKEN_SECRET}"

echo "--- Setting up the :golang: environment..."
GO_VERSION=$(cat .go-version)
GO_VERSION=$(grep '^go' go.mod | cut -d' ' -f2)
OS_NAME=linux
OS_ARCH=amd64
retry 5 curl -sL -o "${BASE_PROJECT}"/gvm "https://github.com/andrewkroh/gvm/releases/download/v0.5.2/gvm-${OS_NAME}-${OS_ARCH}"
Expand Down
24 changes: 0 additions & 24 deletions .ci/scripts/unit-test.sh

This file was deleted.

3 changes: 0 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ jobs:
go.sum
tools/go.sum
- run: make check-full
- name: Ensure .go-version is up to date
run: make update-go-version
if: ${{ github.ref == 'main' }}

test:
strategy:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ get-version:
get-version-only:
@echo $(APM_SERVER_ONLY_VERSION)

# update-go-version updates .go-version, documentation, and build files
# update-go-version updates documentation, and build files
# to use the most recent patch version for the major.minor Go version
# defined in go.mod.
.PHONY: update-go-version
Expand Down
2 changes: 1 addition & 1 deletion cmd/intake-receiver/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/elastic/apm-server/cmd/intake-receiver

go 1.23.0
go 1.23.6

require (
github.com/stretchr/testify v1.6.1
Expand Down
2 changes: 1 addition & 1 deletion functionaltests/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/elastic/apm-server/functionaltests

go 1.23.2
go 1.23.6

require (
github.com/elastic/apm-perf v0.0.0-20241230130730-2ad47482b731
Expand Down
2 changes: 1 addition & 1 deletion go.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ GITCOMMITTIMESTAMPUNIX ?= $(shell git log -1 --pretty=%ct)
GITREFFILE ?= $(GITDIR)/$(shell git rev-parse --symbolic-full-name HEAD)
GITROOT ?= $(shell git rev-parse --show-toplevel)

GOLANG_VERSION=$(shell cat $(GITROOT)/.go-version)
GOLANG_VERSION=$(shell grep '^go' go.mod | cut -d' ' -f2)
GOARCH:=$(shell go env GOARCH)

APM_SERVER_ONLY_VERSION=$(shell grep "const Version" $(GITROOT)/internal/version/version.go | cut -d'=' -f2 | tr -d '" ')
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 github.com/elastic/apm-server

go 1.23.0
go 1.23.6

require (
github.com/KimMachineGun/automemlimit v0.7.0
Expand Down
2 changes: 1 addition & 1 deletion packaging/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ARG GOLANG_VERSION
################################################################################
FROM golang:${GOLANG_VERSION} AS builder
WORKDIR /src
COPY go.mod go.sum .go-version /src/
COPY go.mod go.sum /src/
RUN --mount=type=cache,target=/go/pkg/mod go mod download
COPY Makefile *.mk /src/
COPY cmd /src/cmd
Expand Down
2 changes: 1 addition & 1 deletion packaging/docker/Dockerfile.wolfi
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ARG GOLANG_VERSION
################################################################################
FROM docker.elastic.co/wolfi/go:${GOLANG_VERSION} as builder
WORKDIR /src
COPY go.mod go.sum .go-version /src/
COPY go.mod go.sum /src/
RUN --mount=type=cache,target=/go/pkg/mod go mod download
COPY Makefile *.mk /src/
COPY cmd /src/cmd
Expand Down
44 changes: 0 additions & 44 deletions script/common.bash

This file was deleted.

5 changes: 1 addition & 4 deletions script/update_go_version.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
#
# This script updates .go-version, documentation, and build files to use the
# This script updates go.mod files to use the
# most recent patch version for the major.minor Go version defined in go.mod.
set -e

Expand All @@ -11,6 +11,3 @@ cd $SDIR/..
MAJOR_MINOR_VERSION=$(grep '^go' go.mod | cut -d' ' -f2 | cut -d. -f1-2)

find ./ -type f -name "go.mod" -execdir go get go@$MAJOR_MINOR_VERSION \; -execdir go get toolchain@none \;

GO_VERSION=$(grep '^go' go.mod | cut -d' ' -f2)
echo $GO_VERSION > .go-version
2 changes: 1 addition & 1 deletion systemtest/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/elastic/apm-server/systemtest

go 1.23.0
go 1.23.6

require (
github.com/docker/docker v27.5.1+incompatible
Expand Down
2 changes: 1 addition & 1 deletion tools/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/elastic/apm-server/tools

go 1.23.0
go 1.23.6

require (
github.com/elastic/apm-perf v0.0.0-20240925232339-499ba2a27fd4
Expand Down

0 comments on commit 82d44aa

Please sign in to comment.