Skip to content

Commit

Permalink
Cleanup various code smells withing Makefile ands supporting scripts (#…
Browse files Browse the repository at this point in the history
…4326)

Remove arch 386 targets
Rename docker build image to avoid confusion
group docker vars
fix gvm install on non linux/amd64 hosts
remove unused common.sh funcs
  • Loading branch information
michel-laterman authored Jan 16, 2025
1 parent 3f298bc commit 2f2f429
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 47 deletions.
3 changes: 0 additions & 3 deletions .buildkite/scripts/release-manager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
# - VAULT_ROLE_ID
# - VAULT_SECRET_ID
#
# It uses env variables to help to run this script with a simpler jenkins
# pipeline call.
#

source .buildkite/scripts/common.sh

Expand Down
2 changes: 1 addition & 1 deletion .buildkite/scripts/test-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -euo pipefail

FLEET_SERVER_VERSION=${1:?"Fleet Server version is needed"}

PLATFORM_FILES=(darwin-aarch64.tar.gz darwin-x86_64.tar.gz linux-arm64.tar.gz linux-x86_64.tar.gz linux-x86.tar.gz windows-x86_64.zip windows-x86.zip)
PLATFORM_FILES=(darwin-aarch64.tar.gz darwin-x86_64.tar.gz linux-arm64.tar.gz linux-x86_64.tar.gz windows-x86_64.zip)

#make release

Expand Down
8 changes: 3 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
SHELL=/usr/bin/env bash
GO_VERSION=$(shell cat '.go-version')
DEFAULT_VERSION=$(shell awk '/const DefaultVersion/{print $$NF}' version/version.go | tr -d '"')
TARGET_ARCH_386=x86
TARGET_ARCH_amd64=x86_64
TARGET_ARCH_arm64=arm64
PLATFORMS ?= darwin/amd64 darwin/arm64 linux/386 linux/amd64 linux/arm64 windows/386 windows/amd64
DOCKER_PLATFORMS ?= linux/amd64 linux/arm64
PLATFORMS ?= darwin/amd64 darwin/arm64 linux/amd64 linux/arm64 windows/amd64
BUILDMODE_linux_amd64=-buildmode=pie
BUILDMODE_linux_arm64=-buildmode=pie
BUILDMODE_windows_386=-buildmode=pie
BUILDMODE_windows_amd64=-buildmode=pie
BUILDMODE_darwin_amd64=-buildmode=pie
BUILDMODE_darwin_arm64=-buildmode=pie

CROSSBUILD_SUFFIX=main-debian11
BUILDER_IMAGE=docker.elastic.co/beats-dev/golang-crossbuild:${GO_VERSION}-${CROSSBUILD_SUFFIX}
BUILDER_IMAGE=fleet-server-builder:${GO_VERSION}

#Benchmark related targets
BENCH_BASE ?= benchmark-$(COMMIT).out
Expand All @@ -41,6 +38,7 @@ else
VERSION=${DEFAULT_VERSION}
endif

DOCKER_PLATFORMS ?= linux/amd64 linux/arm64
DOCKER_IMAGE_TAG?=${VERSION}
DOCKER_IMAGE?=docker.elastic.co/fleet-server/fleet-server

Expand Down
42 changes: 4 additions & 38 deletions dev-tools/common.bash
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,15 @@ get_go_version() {
}

# install_gvm
# Install gvm to /usr/local/bin.
# Install gvm to GOPATH
# To read more about installing gvm in other platforms: https://github.com/andrewkroh/gvm#installation
install_gvm() {
# Install gvm
if [ ! -f "/usr/local/bin/gvm" ]; then
curl -sL -o ~/bin/gvm https://github.com/andrewkroh/gvm/releases/download/v0.3.0/gvm-linux-amd64
chmod +x /usr/local/bin/gvm
if [ ! -f "$(go env GOPATH)/bin/gvm" ]; then
go install github.com/andrewkroh/gvm/cmd/[email protected]
fi

GVM="/usr/local/bin/gvm"
GVM="$(go env GOPATH)/bin/gvm"
debug "Gvm version $(${GVM} --version)"
}

Expand Down Expand Up @@ -77,36 +76,3 @@ setup_go_path() {

debug "GOPATH=${GOPATH}"
}

jenkins_setup() {
: "${HOME:?Need to set HOME to a non-empty value.}"
: "${WORKSPACE:?Need to set WORKSPACE to a non-empty value.}"

if [ -z ${GO_VERSION:-} ]; then
get_go_version
fi

# Setup Go.
export GOPATH=${WORKSPACE}
export PATH=${GOPATH}/bin:${PATH}
eval "$(gvm ${GO_VERSION})"

# Workaround for Python virtualenv path being too long.
export TEMP_PYTHON_ENV=$(mktemp -d)
export PYTHON_ENV="${TEMP_PYTHON_ENV}/python-env"

# Write cached magefile binaries to workspace to ensure
# each run starts from a clean slate.
export MAGEFILE_CACHE="${WORKSPACE}/.magefile"
}

docker_setup() {
OS="$(uname)"
case $OS in
'Darwin')
# Start the docker machine VM (ignore error if it's already running).
docker-machine start default || true
eval $(docker-machine env default)
;;
esac
}

0 comments on commit 2f2f429

Please sign in to comment.