Skip to content

Commit

Permalink
Check minimum required go version when build (#1760)
Browse files Browse the repository at this point in the history
  • Loading branch information
gmgigi96 authored Jun 4, 2021
1 parent 6b27cef commit 6ace58c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ GIT_BRANCH=`git rev-parse --symbolic-full-name --abbrev-ref HEAD`
GIT_DIRTY=`git diff-index --quiet HEAD -- || echo "dirty-"`
VERSION=`git describe --always`
GO_VERSION=`go version | awk '{print $$3}'`
MINIMUM_GO_VERSION=1.16.2
BUILD_FLAGS="-X main.gitCommit=${GIT_COMMIT} -X main.version=${VERSION} -X main.goVersion=${GO_VERSION} -X main.buildDate=${BUILD_DATE}"
CI_BUILD_FLAGS="-w -extldflags "-static" -X main.gitCommit=${GIT_COMMIT} -X main.version=${VERSION} -X main.goVersion=${GO_VERSION} -X main.buildDate=${BUILD_DATE}"
LITMUS_URL_OLD="http://localhost:20080/remote.php/webdav"
Expand All @@ -29,7 +30,7 @@ off:
imports: off
`go env GOPATH`/bin/goimports -w tools pkg internal cmd

build: imports
build: imports test-go-version
go build -ldflags ${BUILD_FLAGS} -o ./cmd/revad/revad ./cmd/revad
go build -ldflags ${BUILD_FLAGS} -o ./cmd/reva/reva ./cmd/reva

Expand Down Expand Up @@ -71,6 +72,9 @@ lint:
contrib:
git shortlog -se | cut -c8- | sort -u | awk '{print "-", $$0}' | grep -v 'users.noreply.github.com' > CONTRIBUTORS.md

test-go-version:
@echo -e "$(MINIMUM_GO_VERSION)\n$(shell echo $(GO_VERSION) | sed 's/go//')" | sort -Vc &> /dev/null || echo -e "\n\033[33;5m[WARNING]\033[0m You are not using a supported go version. Please use $(MINIMUM_GO_VERSION) or above.\n"

# for manual building only
deps:
cd /tmp && rm -rf golangci-lint && git clone --quiet -b 'v1.38.0' --single-branch --depth 1 https://github.com/golangci/golangci-lint &> /dev/null && cd golangci-lint/cmd/golangci-lint && go install
Expand Down
7 changes: 7 additions & 0 deletions changelog/unreleased/test-go-version.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Enhancement: Warn user for not recommended go version

This PR adds a warning while an user is building the source code,
if he is using a go version not recommended.

https://github.com/cs3org/reva/issues/1758
https://github.com/cs3org/reva/pull/1760

0 comments on commit 6ace58c

Please sign in to comment.