Skip to content

Commit

Permalink
refactor: let go.mod manage mage version (#5414)
Browse files Browse the repository at this point in the history
* refactor: let go.mod manage mage version

drop hardcoded version and use whatever version is specified in go.mod
When calling go install without an explicit version the one in go.mod
is used.

* lint: remove unused variables

* lint: remove unused variables
  • Loading branch information
kruskall authored Sep 5, 2024
1 parent 1242e71 commit 52f6a85
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
4 changes: 0 additions & 4 deletions .buildkite/scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ if [[ -z "${WORKSPACE-""}" ]]; then
WORKSPACE=$(git rev-parse --show-toplevel)
export WORKSPACE
fi
if [[ -z "${SETUP_MAGE_VERSION-""}" ]]; then
SETUP_MAGE_VERSION="1.15.0"
fi
if [[ -z "${SETUP_GVM_VERSION-""}" ]]; then
SETUP_GVM_VERSION="v0.5.2" # https://github.com/andrewkroh/gvm/issues/44#issuecomment-1013231151
fi
Expand Down Expand Up @@ -54,7 +51,6 @@ mage() {
go version
if ! [ -x "$(type -P mage | sed 's/mage is //g')" ];
then
echo "installing mage ${SETUP_MAGE_VERSION}"
make mage
fi
pushd "$WORKSPACE"
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.skaffold
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ ARG AGENT_IMAGE="docker.elastic.co/beats/elastic-agent"
FROM ${crossbuild_image}:${GO_VERSION}-main-debian8 as build
ARG DEV="true"
ARG SNAPSHOT="true"
RUN go install github.com/magefile/[email protected]
WORKDIR /elastic-agent/
COPY go.mod go.sum /elastic-agent/
RUN go mod download
COPY . /elastic-agent/
RUN go install github.com/magefile/mage
RUN mage golangcrossBuild
RUN git rev-parse HEAD | cut -c 1-6 > .build_hash.txt

Expand Down
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ COVERAGE_DIR=$(BUILD_DIR)/coverage
BEATS?=elastic-agent
PROJECTS= $(BEATS)
PYTHON_ENV?=$(BUILD_DIR)/python-env
MAGE_VERSION ?= v1.15.0
MAGE_PRESENT := $(shell mage --version 2> /dev/null | grep $(MAGE_VERSION))
MAGE_IMPORT_PATH ?= github.com/magefile/mage
export MAGE_IMPORT_PATH
Expand All @@ -12,11 +11,11 @@ export MAGE_IMPORT_PATH
.PHONY: mage
mage:
ifndef MAGE_PRESENT
@echo Installing mage $(MAGE_VERSION).
@go install ${MAGE_IMPORT_PATH}@$(MAGE_VERSION)
@echo Installing mage.
@go install ${MAGE_IMPORT_PATH}
@-mage -clean
else
@echo Mage $(MAGE_VERSION) already installed.
@echo Mage already installed.
endif

## help : Show this help.
Expand Down

0 comments on commit 52f6a85

Please sign in to comment.