Pull request 1747: chlog-and-proj-skel

Merge in DNS/adguard-home from chlog-and-proj-skel to master

Squashed commit of the following:

commit 8e7c3e2eb50c559bdcd5862e72c16511dd8272da
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Tue Feb 21 16:52:10 2023 +0300

    all: upd proj skel
This commit is contained in:
Ainar Garipov
2023-02-21 17:07:12 +03:00
parent 20531de760
commit ff9b24ad69
10 changed files with 130 additions and 48 deletions

View File

@@ -6,6 +6,11 @@
# only has superficial knowledge of the POSIX shell language and alike.
# Experienced readers may find it overly verbose.
# This comment is used to simplify checking local copies of the script. Bump
# this number every time a significant change is made to this script.
#
# AdGuard-Project-Version: 1
# The default verbosity level is 0. Show every command that is run and every
# package that is processed if the caller requested verbosity level greater than
# 0. Also show subcommands if the requested verbosity level is greater than 1.
@@ -111,17 +116,17 @@ readonly o_flags
# must be enabled.
if [ "${RACE:-0}" -eq '0' ]
then
cgo_enabled='0'
CGO_ENABLED='0'
race_flags='--race=0'
else
cgo_enabled='1'
CGO_ENABLED='1'
race_flags='--race=1'
fi
readonly cgo_enabled race_flags
readonly CGO_ENABLED race_flags
export CGO_ENABLED
CGO_ENABLED="$cgo_enabled"
GO111MODULE='on'
export CGO_ENABLED GO111MODULE
export GO111MODULE
# Build the new binary if requested.
if [ "${NEXTAPI:-0}" -eq '0' ]
@@ -132,5 +137,16 @@ else
fi
readonly tags_flags
"$go" build --ldflags "$ldflags" "$race_flags" "$tags_flags" --trimpath "$o_flags" "$v_flags"\
if [ "$verbose" -gt '0' ]
then
"$go" env
fi
"$go" build\
--ldflags "$ldflags"\
"$race_flags"\
"$tags_flags"\
--trimpath\
"$o_flags"\
"$v_flags"\
"$x_flags"

View File

@@ -1,5 +1,10 @@
#!/bin/sh
# This comment is used to simplify checking local copies of the script. Bump
# this number every time a significant change is made to this script.
#
# AdGuard-Project-Version: 1
verbose="${VERBOSE:-0}"
readonly verbose
@@ -7,14 +12,14 @@ if [ "$verbose" -gt '1' ]
then
env
set -x
x_flags='-x'
x_flags='-x=1'
elif [ "$verbose" -gt '0' ]
then
set -x
x_flags=''
x_flags='-x=0'
else
set +x
x_flags=''
x_flags='-x=0'
fi
readonly x_flags
@@ -23,6 +28,4 @@ set -e -f -u
go="${GO:-go}"
readonly go
# Don't use quotes with flag variables because we want an empty space if those
# aren't set.
"$go" mod download $x_flags
"$go" mod download "$x_flags"

View File

@@ -1,5 +1,10 @@
#!/bin/sh
# This comment is used to simplify checking local copies of the script. Bump
# this number every time a significant change is made to this script.
#
# AdGuard-Project-Version: 1
verbose="${VERBOSE:-0}"
readonly verbose
@@ -43,5 +48,12 @@ shuffle_flags='--shuffle=on'
timeout_flags="${TIMEOUT_FLAGS:---timeout=90s}"
readonly count_flags cover_flags shuffle_flags timeout_flags
"$go" test "$count_flags" "$cover_flags" "$race_flags" "$shuffle_flags" "$timeout_flags"\
"$x_flags" "$v_flags" ./...
"$go" test\
"$count_flags"\
"$cover_flags"\
"$shuffle_flags"\
"$race_flags"\
"$timeout_flags"\
"$x_flags"\
"$v_flags"\
./...

View File

@@ -1,22 +1,27 @@
#!/bin/sh
# This comment is used to simplify checking local copies of the script. Bump
# this number every time a significant change is made to this script.
#
# AdGuard-Project-Version: 2
verbose="${VERBOSE:-0}"
readonly verbose
if [ "$verbose" -gt '1' ]
then
set -x
v_flags='-v'
x_flags='-x'
v_flags='-v=1'
x_flags='-x=1'
elif [ "$verbose" -gt '0' ]
then
set -x
v_flags='-v'
x_flags=''
v_flags='-v=1'
x_flags='-x=0'
else
set +x
v_flags=''
x_flags=''
v_flags='-v=0'
x_flags='-x=0'
fi
readonly v_flags x_flags
@@ -27,6 +32,25 @@ readonly go
# TODO(a.garipov): Add goconst?
# Remove only the actual binaries in the bin/ directory, as developers may add
# their own scripts there. Most commonly, a script named “go” for tools that
# call the go binary and need a particular version.
rm -f\
bin/errcheck\
bin/fieldalignment\
bin/gocyclo\
bin/gofumpt\
bin/gosec\
bin/govulncheck\
bin/ineffassign\
bin/looppointer\
bin/misspell\
bin/nilness\
bin/shadow\
bin/staticcheck\
bin/unparam\
;
# Reset GOARCH and GOOS to make sure we install the tools for the native
# architecture even when we're cross-compiling the main binary, and also to
# prevent the "cannot install cross-compiled binaries when GOBIN is set" error.
@@ -37,14 +61,15 @@ env\
GOWORK='off'\
"$go" install\
--modfile=./internal/tools/go.mod\
$v_flags\
$x_flags\
"$v_flags"\
"$x_flags"\
github.com/fzipp/gocyclo/cmd/gocyclo\
github.com/golangci/misspell/cmd/misspell\
github.com/gordonklaus/ineffassign\
github.com/kisielk/errcheck\
github.com/kyoh86/looppointer/cmd/looppointer\
github.com/securego/gosec/v2/cmd/gosec\
golang.org/x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignment\
golang.org/x/tools/go/analysis/passes/nilness/cmd/nilness\
golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow\
golang.org/x/vuln/cmd/govulncheck\