Pull request: all: imp go version setting and detection

Merge in DNS/adguard-home from imp-make to master

Squashed commit of the following:

commit 9ecb3422a55f5d010000bf4253a2766fefa67173
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Thu Apr 22 19:59:36 2021 +0300

    all: fix spelling

commit c136f6562af80a67e627b472621ac68763f85fde
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Thu Apr 22 19:50:07 2021 +0300

    all: imp go version setting and detection
This commit is contained in:
Ainar Garipov 2021-04-22 20:06:34 +03:00
parent 138dfaa85b
commit cb01eaa7f7
2 changed files with 38 additions and 13 deletions

View File

@ -7,13 +7,15 @@
CHANNEL = development
CLIENT_BETA_DIR = client2
CLIENT_DIR = client
COMMIT = $$(git rev-parse --short HEAD)
COMMIT = $$( git rev-parse --short HEAD )
DIST_DIR = dist
# TODO(a.garipov): Find out a way to make this work in GNU Make.
# Don't name this macro "GO", because GNU Make apparenly makes it an
# exported environment variable with the literal value of "${GO:-go}",
# which is not what we need. Use a dot in the name to make sure that
# users don't have an environment variable with the same name.
#
# GO = $${GO:-go}
#
GO = go
# See https://unix.stackexchange.com/q/646255/105635.
GO.MACRO = $${GO:-go}
GOPROXY = https://goproxy.cn|https://proxy.golang.org|direct
GPG_KEY = devteam@adguard.com
GPG_KEY_PASSPHRASE = not-a-real-password
@ -37,9 +39,9 @@ ENV = env\
GPG_KEY='$(GPG_KEY)'\
GPG_KEY_PASSPHRASE='$(GPG_KEY_PASSPHRASE)'\
DIST_DIR='$(DIST_DIR)'\
GO='$(GO)'\
GO="$(GO.MACRO)"\
GOPROXY='$(GOPROXY)'\
PATH="$${PWD}/bin:$$($(GO) env GOPATH)/bin:$${PATH}"\
PATH="$${PWD}/bin:$$( "$(GO.MACRO)" env GOPATH )/bin:$${PATH}"\
RACE='$(RACE)'\
SIGN='$(SIGN)'\
VERBOSE='$(VERBOSE)'\
@ -97,10 +99,10 @@ go-check: go-tools go-lint go-test
# A quick check to make sure that all supported operating systems can be
# typechecked and built successfully.
go-os-check:
env GOOS='darwin' $(GO) vet ./internal/...
env GOOS='freebsd' $(GO) vet ./internal/...
env GOOS='linux' $(GO) vet ./internal/...
env GOOS='windows' $(GO) vet ./internal/...
env GOOS='darwin' "$(GO.MACRO)" vet ./internal/...
env GOOS='freebsd' "$(GO.MACRO)" vet ./internal/...
env GOOS='linux' "$(GO.MACRO)" vet ./internal/...
env GOOS='windows' "$(GO.MACRO)" vet ./internal/...
openapi-lint: ; cd ./openapi/ && $(YARN) test
openapi-show: ; cd ./openapi/ && $(YARN) start

View File

@ -27,7 +27,7 @@ set -f -u
# Deferred Helpers
not_found_msg='
readonly not_found_msg='
looks like a binary not found error.
make sure you have installed the linter binaries using:
@ -49,6 +49,29 @@ trap not_found EXIT
# Warnings
readonly go_min_version='go1.15'
readonly go_min_version_prefix="go version ${go_min_version}"
readonly go_version_msg="
warning: your go version different from the recommended minimal one (${go_min_version}).
if you have the version installed, please set the GO environment variable.
for example:
export GO='${go_min_version}'
"
case "$( "$GO" version )"
in
("$go_min_version_prefix"*)
# Go on.
;;
(*)
echo "$go_version_msg" 1>&2
;;
esac
# Simple Analyzers
# blocklist_imports is a simple check against unwanted packages.
@ -99,7 +122,7 @@ exit_on_output() (
cmd="$1"
shift
output="$("$cmd" "$@" 2>&1)"
output="$( "$cmd" "$@" 2>&1 )"
exitcode="$?"
if [ "$exitcode" != '0' ]
then