mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
chore: enable strict mode for test CI
Signed-off-by: Wei Fu <fuweid89@gmail.com>
This commit is contained in:
parent
7230b943d0
commit
55bce22e97
8
.github/workflows/e2e.yaml
vendored
8
.github/workflows/e2e.yaml
vendored
@ -18,15 +18,15 @@ jobs:
|
|||||||
- env:
|
- env:
|
||||||
TARGET: ${{ matrix.target }}
|
TARGET: ${{ matrix.target }}
|
||||||
run: |
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
echo "${TARGET}"
|
echo "${TARGET}"
|
||||||
case "${TARGET}" in
|
case "${TARGET}" in
|
||||||
linux-amd64-e2e)
|
linux-amd64-e2e)
|
||||||
PASSES='build release e2e' MANUAL_VER=v3.4.7 CPU='4' EXPECT_DEBUG='true' COVER='false' RACE='true' ./test.sh 2>&1 | tee test.log
|
PASSES='build release e2e' MANUAL_VER=v3.4.7 CPU='4' EXPECT_DEBUG='true' COVER='false' RACE='true' ./test.sh
|
||||||
! egrep "(--- FAIL:|DATA RACE|panic: test timed out|appears to have leaked)" -B50 -A10 test.log
|
|
||||||
;;
|
;;
|
||||||
linux-386-e2e)
|
linux-386-e2e)
|
||||||
GOARCH=386 PASSES='build e2e' CPU='4' EXPECT_DEBUG='true' COVER='false' RACE='true' ./test.sh 2>&1 | tee test.log
|
GOARCH=386 PASSES='build e2e' CPU='4' EXPECT_DEBUG='true' COVER='false' RACE='true' ./test.sh
|
||||||
! egrep "(--- FAIL:|DATA RACE|panic: test timed out|appears to have leaked)" -B50 -A10 test.log
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Failed to find target"
|
echo "Failed to find target"
|
||||||
|
2
.github/workflows/functional.yaml
vendored
2
.github/workflows/functional.yaml
vendored
@ -17,6 +17,8 @@ jobs:
|
|||||||
- env:
|
- env:
|
||||||
TARGET: ${{ matrix.target }}
|
TARGET: ${{ matrix.target }}
|
||||||
run: |
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
echo "${TARGET}"
|
echo "${TARGET}"
|
||||||
case "${TARGET}" in
|
case "${TARGET}" in
|
||||||
linux-amd64-functional)
|
linux-amd64-functional)
|
||||||
|
5
.github/workflows/grpcproxy.yaml
vendored
5
.github/workflows/grpcproxy.yaml
vendored
@ -17,11 +17,12 @@ jobs:
|
|||||||
- env:
|
- env:
|
||||||
TARGET: ${{ matrix.target }}
|
TARGET: ${{ matrix.target }}
|
||||||
run: |
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
echo "${TARGET}"
|
echo "${TARGET}"
|
||||||
case "${TARGET}" in
|
case "${TARGET}" in
|
||||||
linux-amd64-grpcproxy)
|
linux-amd64-grpcproxy)
|
||||||
PASSES='build grpcproxy' CPU='4' COVER='false' RACE='true' ./test.sh 2>&1 | tee test.log
|
PASSES='build grpcproxy' CPU='4' COVER='false' RACE='true' ./test.sh
|
||||||
! egrep "(--- FAIL:|DATA RACE|panic: test timed out|appears to have leaked)" -B50 -A10 test.log
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Failed to find target"
|
echo "Failed to find target"
|
||||||
|
2
.github/workflows/tests.yaml
vendored
2
.github/workflows/tests.yaml
vendored
@ -23,6 +23,8 @@ jobs:
|
|||||||
- env:
|
- env:
|
||||||
TARGET: ${{ matrix.target }}
|
TARGET: ${{ matrix.target }}
|
||||||
run: |
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
echo "${TARGET}"
|
echo "${TARGET}"
|
||||||
case "${TARGET}" in
|
case "${TARGET}" in
|
||||||
linux-amd64-fmt)
|
linux-amd64-fmt)
|
||||||
|
2
build
2
build
@ -1,5 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
echo -e "\\e[91mDEPRECATED!!! Use build.sh script instead.\\e[0m\\n"
|
echo -e "\\e[91mDEPRECATED!!! Use build.sh script instead.\\e[0m\\n"
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
|
30
build.sh
30
build.sh
@ -1,18 +1,24 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
source ./scripts/test_lib.sh
|
source ./scripts/test_lib.sh
|
||||||
|
|
||||||
GIT_SHA=$(git rev-parse --short HEAD || echo "GitNotFound")
|
GIT_SHA=$(git rev-parse --short HEAD || echo "GitNotFound")
|
||||||
if [[ -n "$FAILPOINTS" ]]; then
|
if [[ -n "${FAILPOINTS:-}" ]]; then
|
||||||
GIT_SHA="$GIT_SHA"-FAILPOINTS
|
GIT_SHA="$GIT_SHA"-FAILPOINTS
|
||||||
fi
|
fi
|
||||||
|
|
||||||
VERSION_SYMBOL="${ROOT_MODULE}/api/v3/version.GitSHA"
|
VERSION_SYMBOL="${ROOT_MODULE}/api/v3/version.GitSHA"
|
||||||
|
|
||||||
|
# use go env if noset
|
||||||
|
GOOS=${GOOS:-$(go env GOOS)}
|
||||||
|
GOARCH=${GOARCH:-$(go env GOARCH)}
|
||||||
|
|
||||||
# Set GO_LDFLAGS="-s" for building without symbols for debugging.
|
# Set GO_LDFLAGS="-s" for building without symbols for debugging.
|
||||||
# shellcheck disable=SC2206
|
# shellcheck disable=SC2206
|
||||||
GO_LDFLAGS=(${GO_LDFLAGS} "-X=${VERSION_SYMBOL}=${GIT_SHA}")
|
GO_LDFLAGS=(${GO_LDFLAGS:-} "-X=${VERSION_SYMBOL}=${GIT_SHA}")
|
||||||
GO_BUILD_ENV=("CGO_ENABLED=0" "GO_BUILD_FLAGS=${GO_BUILD_FLAGS}" "GOOS=${GOOS}" "GOARCH=${GOARCH}")
|
GO_BUILD_ENV=("CGO_ENABLED=0" "GO_BUILD_FLAGS=${GO_BUILD_FLAGS:-}" "GOOS=${GOOS}" "GOARCH=${GOARCH}")
|
||||||
|
|
||||||
# enable/disable failpoints
|
# enable/disable failpoints
|
||||||
toggle_failpoints() {
|
toggle_failpoints() {
|
||||||
@ -27,13 +33,13 @@ toggle_failpoints() {
|
|||||||
|
|
||||||
toggle_failpoints_default() {
|
toggle_failpoints_default() {
|
||||||
mode="disable"
|
mode="disable"
|
||||||
if [[ -n "$FAILPOINTS" ]]; then mode="enable"; fi
|
if [[ -n "${FAILPOINTS:-}" ]]; then mode="enable"; fi
|
||||||
toggle_failpoints "$mode"
|
toggle_failpoints "$mode"
|
||||||
}
|
}
|
||||||
|
|
||||||
etcd_build() {
|
etcd_build() {
|
||||||
out="bin"
|
out="bin"
|
||||||
if [[ -n "${BINDIR}" ]]; then out="${BINDIR}"; fi
|
if [[ -n "${BINDIR:-}" ]]; then out="${BINDIR}"; fi
|
||||||
toggle_failpoints_default
|
toggle_failpoints_default
|
||||||
|
|
||||||
run rm -f "${out}/etcd"
|
run rm -f "${out}/etcd"
|
||||||
@ -41,7 +47,7 @@ etcd_build() {
|
|||||||
cd ./server
|
cd ./server
|
||||||
# Static compilation is useful when etcd is run in a container. $GO_BUILD_FLAGS is OK
|
# Static compilation is useful when etcd is run in a container. $GO_BUILD_FLAGS is OK
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
run env "${GO_BUILD_ENV[@]}" go build $GO_BUILD_FLAGS \
|
run env "${GO_BUILD_ENV[@]}" go build ${GO_BUILD_FLAGS:-} \
|
||||||
-trimpath \
|
-trimpath \
|
||||||
-installsuffix=cgo \
|
-installsuffix=cgo \
|
||||||
"-ldflags=${GO_LDFLAGS[*]}" \
|
"-ldflags=${GO_LDFLAGS[*]}" \
|
||||||
@ -52,7 +58,7 @@ etcd_build() {
|
|||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
(
|
(
|
||||||
cd ./etcdutl
|
cd ./etcdutl
|
||||||
run env GO_BUILD_FLAGS="${GO_BUILD_FLAGS}" "${GO_BUILD_ENV[@]}" go build $GO_BUILD_FLAGS \
|
run env GO_BUILD_FLAGS="${GO_BUILD_FLAGS:-}" "${GO_BUILD_ENV[@]}" go build ${GO_BUILD_FLAGS:-} \
|
||||||
-trimpath \
|
-trimpath \
|
||||||
-installsuffix=cgo \
|
-installsuffix=cgo \
|
||||||
"-ldflags=${GO_LDFLAGS[*]}" \
|
"-ldflags=${GO_LDFLAGS[*]}" \
|
||||||
@ -63,7 +69,7 @@ etcd_build() {
|
|||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
(
|
(
|
||||||
cd ./etcdctl
|
cd ./etcdctl
|
||||||
run env GO_BUILD_FLAGS="${GO_BUILD_FLAGS}" "${GO_BUILD_ENV[@]}" go build $GO_BUILD_FLAGS \
|
run env GO_BUILD_FLAGS="${GO_BUILD_FLAGS:-}" "${GO_BUILD_ENV[@]}" go build ${GO_BUILD_FLAGS:-} \
|
||||||
-trimpath \
|
-trimpath \
|
||||||
-installsuffix=cgo \
|
-installsuffix=cgo \
|
||||||
"-ldflags=${GO_LDFLAGS[*]}" \
|
"-ldflags=${GO_LDFLAGS[*]}" \
|
||||||
@ -84,7 +90,7 @@ etcd_build() {
|
|||||||
|
|
||||||
tools_build() {
|
tools_build() {
|
||||||
out="bin"
|
out="bin"
|
||||||
if [[ -n "${BINDIR}" ]]; then out="${BINDIR}"; fi
|
if [[ -n "${BINDIR:-}" ]]; then out="${BINDIR}"; fi
|
||||||
tools_path="tools/benchmark
|
tools_path="tools/benchmark
|
||||||
tools/etcd-dump-db
|
tools/etcd-dump-db
|
||||||
tools/etcd-dump-logs
|
tools/etcd-dump-logs
|
||||||
@ -94,7 +100,7 @@ tools_build() {
|
|||||||
echo "Building" "'${tool}'"...
|
echo "Building" "'${tool}'"...
|
||||||
run rm -f "${out}/${tool}"
|
run rm -f "${out}/${tool}"
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
run env GO_BUILD_FLAGS="${GO_BUILD_FLAGS}" CGO_ENABLED=0 go build ${GO_BUILD_FLAGS} \
|
run env GO_BUILD_FLAGS="${GO_BUILD_FLAGS:-}" CGO_ENABLED=0 go build ${GO_BUILD_FLAGS:-} \
|
||||||
-trimpath \
|
-trimpath \
|
||||||
-installsuffix=cgo \
|
-installsuffix=cgo \
|
||||||
"-ldflags=${GO_LDFLAGS[*]}" \
|
"-ldflags=${GO_LDFLAGS[*]}" \
|
||||||
@ -105,7 +111,7 @@ tools_build() {
|
|||||||
|
|
||||||
tests_build() {
|
tests_build() {
|
||||||
out="bin"
|
out="bin"
|
||||||
if [[ -n "${BINDIR}" ]]; then out="${BINDIR}"; fi
|
if [[ -n "${BINDIR:-}" ]]; then out="${BINDIR}"; fi
|
||||||
tools_path="
|
tools_path="
|
||||||
functional/cmd/etcd-agent
|
functional/cmd/etcd-agent
|
||||||
functional/cmd/etcd-proxy
|
functional/cmd/etcd-proxy
|
||||||
@ -118,7 +124,7 @@ tests_build() {
|
|||||||
run rm -f "../${out}/${tool}"
|
run rm -f "../${out}/${tool}"
|
||||||
|
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
run env CGO_ENABLED=0 GO_BUILD_FLAGS="${GO_BUILD_FLAGS}" go build ${GO_BUILD_FLAGS} \
|
run env CGO_ENABLED=0 GO_BUILD_FLAGS="${GO_BUILD_FLAGS:-}" go build ${GO_BUILD_FLAGS:-} \
|
||||||
-installsuffix=cgo \
|
-installsuffix=cgo \
|
||||||
"-ldflags=${GO_LDFLAGS[*]}" \
|
"-ldflags=${GO_LDFLAGS[*]}" \
|
||||||
-o="../${out}/${tool}" "./${tool}" || return 2
|
-o="../${out}/${tool}" "./${tool}" || return 2
|
||||||
|
@ -1,18 +1,17 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
set -e
|
set -euo pipefail
|
||||||
|
|
||||||
source ./scripts/test_lib.sh
|
source ./scripts/test_lib.sh
|
||||||
|
|
||||||
VER=$1
|
VER=${1:-}
|
||||||
REPOSITORY="${REPOSITORY:-git@github.com:etcd-io/etcd.git}"
|
REPOSITORY="${REPOSITORY:-git@github.com:etcd-io/etcd.git}"
|
||||||
|
|
||||||
if [ -z "$1" ]; then
|
if [ -z "${VER}" ]; then
|
||||||
echo "Usage: ${0} VERSION" >> /dev/stderr
|
echo "Usage: ${0} VERSION" >> /dev/stderr
|
||||||
exit 255
|
exit 255
|
||||||
fi
|
fi
|
||||||
|
|
||||||
set -u
|
|
||||||
|
|
||||||
function setup_env {
|
function setup_env {
|
||||||
local ver=${1}
|
local ver=${1}
|
||||||
@ -38,7 +37,7 @@ function package {
|
|||||||
srcdir="${ccdir}"
|
srcdir="${ccdir}"
|
||||||
fi
|
fi
|
||||||
local ext=""
|
local ext=""
|
||||||
if [ "${GOOS}" == "windows" ]; then
|
if [ "${GOOS:-}" == "windows" ]; then
|
||||||
ext=".exe"
|
ext=".exe"
|
||||||
fi
|
fi
|
||||||
for bin in etcd etcdctl etcdutl; do
|
for bin in etcd etcdctl etcdutl; do
|
||||||
@ -60,7 +59,7 @@ function main {
|
|||||||
cd release
|
cd release
|
||||||
setup_env "${VER}" "${proj}"
|
setup_env "${VER}" "${proj}"
|
||||||
|
|
||||||
tarcmd=tar
|
local tarcmd=tar
|
||||||
if [[ $(go env GOOS) == "darwin" ]]; then
|
if [[ $(go env GOOS) == "darwin" ]]; then
|
||||||
echo "Please use linux machine for release builds."
|
echo "Please use linux machine for release builds."
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
set -e
|
set -euo pipefail
|
||||||
|
|
||||||
if [ "$#" -ne 1 ]; then
|
if [ "$#" -ne 1 ]; then
|
||||||
echo "Usage: $0 VERSION" >&2
|
echo "Usage: $0 VERSION" >&2
|
||||||
@ -11,7 +11,7 @@ ARCH=$(go env GOARCH)
|
|||||||
VERSION="${1}-${ARCH}"
|
VERSION="${1}-${ARCH}"
|
||||||
DOCKERFILE="Dockerfile-release.${ARCH}"
|
DOCKERFILE="Dockerfile-release.${ARCH}"
|
||||||
|
|
||||||
if [ -z "${BINARYDIR}" ]; then
|
if [ -z "${BINARYDIR:-}" ]; then
|
||||||
RELEASE="etcd-${1}"-$(go env GOOS)-$(go env GOARCH)
|
RELEASE="etcd-${1}"-$(go env GOOS)-$(go env GOARCH)
|
||||||
BINARYDIR="${RELEASE}"
|
BINARYDIR="${RELEASE}"
|
||||||
TARFILE="${RELEASE}.tar.gz"
|
TARFILE="${RELEASE}.tar.gz"
|
||||||
@ -34,7 +34,7 @@ cp "${BINARYDIR}"/etcd "${BINARYDIR}"/etcdctl "${BINARYDIR}"/etcdutl "${IMAGEDIR
|
|||||||
|
|
||||||
cat ./"${DOCKERFILE}" > "${IMAGEDIR}"/Dockerfile
|
cat ./"${DOCKERFILE}" > "${IMAGEDIR}"/Dockerfile
|
||||||
|
|
||||||
if [ -z "$TAG" ]; then
|
if [ -z "${TAG:-}" ]; then
|
||||||
# Fix incorrect image "Architecture" using buildkit
|
# Fix incorrect image "Architecture" using buildkit
|
||||||
# From https://stackoverflow.com/q/72144329/
|
# From https://stackoverflow.com/q/72144329/
|
||||||
DOCKER_BUILDKIT=1 docker build -t "gcr.io/etcd-development/etcd:${VERSION}" "${IMAGEDIR}"
|
DOCKER_BUILDKIT=1 docker build -t "gcr.io/etcd-development/etcd:${VERSION}" "${IMAGEDIR}"
|
||||||
|
@ -3,11 +3,11 @@
|
|||||||
# Build all release binaries and images to directory ./release.
|
# Build all release binaries and images to directory ./release.
|
||||||
# Run from repository root.
|
# Run from repository root.
|
||||||
#
|
#
|
||||||
set -e
|
set -euo pipefail
|
||||||
|
|
||||||
source ./scripts/test_lib.sh
|
source ./scripts/test_lib.sh
|
||||||
|
|
||||||
VERSION=$1
|
VERSION=${1:-}
|
||||||
if [ -z "${VERSION}" ]; then
|
if [ -z "${VERSION}" ]; then
|
||||||
echo "Usage: ${0} VERSION" >> /dev/stderr
|
echo "Usage: ${0} VERSION" >> /dev/stderr
|
||||||
exit 255
|
exit 255
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
ROOT_MODULE="go.etcd.io/etcd"
|
ROOT_MODULE="go.etcd.io/etcd"
|
||||||
|
|
||||||
if [[ "$(go list)" != "${ROOT_MODULE}/v3" ]]; then
|
if [[ "$(go list)" != "${ROOT_MODULE}/v3" ]]; then
|
||||||
@ -107,7 +109,7 @@ function relativePath {
|
|||||||
|
|
||||||
#### Discovery of files/packages within a go module #####
|
#### Discovery of files/packages within a go module #####
|
||||||
|
|
||||||
# go_srcs_in_module [package]
|
# go_srcs_in_module
|
||||||
# returns list of all not-generated go sources in the current (dir) module.
|
# returns list of all not-generated go sources in the current (dir) module.
|
||||||
function go_srcs_in_module {
|
function go_srcs_in_module {
|
||||||
go list -f "{{with \$c:=.}}{{range \$f:=\$c.GoFiles }}{{\$c.Dir}}/{{\$f}}{{\"\n\"}}{{end}}{{range \$f:=\$c.TestGoFiles }}{{\$c.Dir}}/{{\$f}}{{\"\n\"}}{{end}}{{range \$f:=\$c.XTestGoFiles }}{{\$c.Dir}}/{{\$f}}{{\"\n\"}}{{end}}{{end}}" ./... | grep -vE "(\\.pb\\.go|\\.pb\\.gw.go)"
|
go list -f "{{with \$c:=.}}{{range \$f:=\$c.GoFiles }}{{\$c.Dir}}/{{\$f}}{{\"\n\"}}{{end}}{{range \$f:=\$c.TestGoFiles }}{{\$c.Dir}}/{{\$f}}{{\"\n\"}}{{end}}{{range \$f:=\$c.XTestGoFiles }}{{\$c.Dir}}/{{\$f}}{{\"\n\"}}{{end}}{{end}}" ./... | grep -vE "(\\.pb\\.go|\\.pb\\.gw.go)"
|
||||||
@ -171,7 +173,7 @@ function module_dirs() {
|
|||||||
|
|
||||||
# maybe_run [cmd...] runs given command depending on the DRY_RUN flag.
|
# maybe_run [cmd...] runs given command depending on the DRY_RUN flag.
|
||||||
function maybe_run() {
|
function maybe_run() {
|
||||||
if ${DRY_RUN}; then
|
if ${DRY_RUN:-}; then
|
||||||
log_warning -e "# DRY_RUN:\\n % ${*}"
|
log_warning -e "# DRY_RUN:\\n % ${*}"
|
||||||
else
|
else
|
||||||
run "${@}"
|
run "${@}"
|
||||||
@ -243,7 +245,7 @@ function go_test {
|
|||||||
|
|
||||||
local goTestFlags=""
|
local goTestFlags=""
|
||||||
local goTestEnv=""
|
local goTestEnv=""
|
||||||
if [ "${VERBOSE}" == "1" ]; then
|
if [ "${VERBOSE:-}" == "1" ]; then
|
||||||
goTestFlags="-v"
|
goTestFlags="-v"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
2
test
2
test
@ -1,5 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
echo -e "\\e[91mDEPRECATED!!! Use test.sh script instead.\\e[0m\\n"
|
echo -e "\\e[91mDEPRECATED!!! Use test.sh script instead.\\e[0m\\n"
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
|
47
test.sh
47
test.sh
@ -32,12 +32,12 @@
|
|||||||
# $ COVERDIR=coverage PASSES="build build_cov cov" ./test
|
# $ COVERDIR=coverage PASSES="build build_cov cov" ./test
|
||||||
# $ go tool cover -html ./coverage/cover.out
|
# $ go tool cover -html ./coverage/cover.out
|
||||||
set -e
|
set -e
|
||||||
set -o pipefail
|
|
||||||
|
|
||||||
|
|
||||||
# Consider command as failed when any component of the pipe fails:
|
# Consider command as failed when any component of the pipe fails:
|
||||||
# https://stackoverflow.com/questions/1221833/pipe-output-and-capture-exit-status-in-bash
|
# https://stackoverflow.com/questions/1221833/pipe-output-and-capture-exit-status-in-bash
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
set -o nounset
|
||||||
|
|
||||||
# The test script is not supposed to make any changes to the files
|
# The test script is not supposed to make any changes to the files
|
||||||
# e.g. add/update missing dependencies. Such divergences should be
|
# e.g. add/update missing dependencies. Such divergences should be
|
||||||
@ -51,12 +51,12 @@ source ./build.sh
|
|||||||
PASSES=${PASSES:-"fmt bom dep build unit"}
|
PASSES=${PASSES:-"fmt bom dep build unit"}
|
||||||
PKG=${PKG:-}
|
PKG=${PKG:-}
|
||||||
|
|
||||||
if [ -z "$GOARCH" ]; then
|
if [ -z "${GOARCH:-}" ]; then
|
||||||
GOARCH=$(go env GOARCH);
|
GOARCH=$(go env GOARCH);
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# determine whether target supports race detection
|
# determine whether target supports race detection
|
||||||
if [ -z "${RACE}" ] ; then
|
if [ -z "${RACE:-}" ] ; then
|
||||||
if [ "$GOARCH" == "amd64" ]; then
|
if [ "$GOARCH" == "amd64" ]; then
|
||||||
RACE="--race"
|
RACE="--race"
|
||||||
else
|
else
|
||||||
@ -68,21 +68,23 @@ fi
|
|||||||
|
|
||||||
# This options make sense for cases where SUT (System Under Test) is compiled by test.
|
# This options make sense for cases where SUT (System Under Test) is compiled by test.
|
||||||
COMMON_TEST_FLAGS=("${RACE}")
|
COMMON_TEST_FLAGS=("${RACE}")
|
||||||
if [[ -n "${CPU}" ]]; then
|
if [[ -n "${CPU:-}" ]]; then
|
||||||
COMMON_TEST_FLAGS+=("--cpu=${CPU}")
|
COMMON_TEST_FLAGS+=("--cpu=${CPU}")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log_callout "Running with ${COMMON_TEST_FLAGS[*]}"
|
log_callout "Running with ${COMMON_TEST_FLAGS[*]}"
|
||||||
|
|
||||||
RUN_ARG=()
|
RUN_ARG=()
|
||||||
if [ -n "${TESTCASE}" ]; then
|
if [ -n "${TESTCASE:-}" ]; then
|
||||||
RUN_ARG=("-run=${TESTCASE}")
|
RUN_ARG=("-run=${TESTCASE}")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function build_pass {
|
function build_pass {
|
||||||
log_callout "Building etcd"
|
log_callout "Building etcd"
|
||||||
run_for_modules run go build "${@}" || return 2
|
run_for_modules run go build "${@}" || return 2
|
||||||
GO_BUILD_FLAGS="-v" etcd_build "${@}"
|
# Previous command will cover etcd_build so that any error will fast-fail by
|
||||||
|
# return 2. Just in case that add return 2 for etcd_build as well.
|
||||||
|
GO_BUILD_FLAGS="-v" etcd_build "${@}" || return 2
|
||||||
GO_BUILD_FLAGS="-v" tools_build "${@}"
|
GO_BUILD_FLAGS="-v" tools_build "${@}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,12 +145,13 @@ function generic_checker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function functional_pass {
|
function functional_pass {
|
||||||
run ./tests/functional/build
|
run ./tests/functional/build || return $?
|
||||||
|
|
||||||
# Clean up any data and logs from previous runs
|
# Clean up any data and logs from previous runs
|
||||||
rm -rf /tmp/etcd-functional-* /tmp/etcd-functional-*.backup
|
rm -rf /tmp/etcd-functional-* /tmp/etcd-functional-*.backup
|
||||||
|
|
||||||
# TODO: These ports should be dynamically allocated instead of hard-coded.
|
# TODO: These ports should be dynamically allocated instead of hard-coded.
|
||||||
|
local agent_pids=""
|
||||||
for a in 1 2 3; do
|
for a in 1 2 3; do
|
||||||
./bin/etcd-agent --network tcp --address 127.0.0.1:${a}9027 < /dev/null &
|
./bin/etcd-agent --network tcp --address 127.0.0.1:${a}9027 < /dev/null &
|
||||||
pid="$!"
|
pid="$!"
|
||||||
@ -199,8 +202,8 @@ function grpcproxy_pass {
|
|||||||
|
|
||||||
# Builds artifacts used by tests/e2e in coverage mode.
|
# Builds artifacts used by tests/e2e in coverage mode.
|
||||||
function build_cov_pass {
|
function build_cov_pass {
|
||||||
run_for_module "server" run go test -tags cov -c -covermode=set -coverpkg="./..." -o "../bin/etcd_test"
|
run_for_module "server" run go test -tags cov -c -covermode=set -coverpkg="./..." -o "../bin/etcd_test" || return $?
|
||||||
run_for_module "etcdctl" run go test -tags cov -c -covermode=set -coverpkg="./..." -o "../bin/etcdctl_test"
|
run_for_module "etcdctl" run go test -tags cov -c -covermode=set -coverpkg="./..." -o "../bin/etcdctl_test" || return $?
|
||||||
run_for_module "etcdutl" run go test -tags cov -c -covermode=set -coverpkg="./..." -o "../bin/etcdutl_test"
|
run_for_module "etcdutl" run go test -tags cov -c -covermode=set -coverpkg="./..." -o "../bin/etcdutl_test"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,7 +288,7 @@ function merge_cov {
|
|||||||
|
|
||||||
function cov_pass {
|
function cov_pass {
|
||||||
# shellcheck disable=SC2153
|
# shellcheck disable=SC2153
|
||||||
if [ -z "$COVERDIR" ]; then
|
if [ -z "${COVERDIR:-}" ]; then
|
||||||
log_error "COVERDIR undeclared"
|
log_error "COVERDIR undeclared"
|
||||||
return 255
|
return 255
|
||||||
fi
|
fi
|
||||||
@ -436,9 +439,10 @@ function govet_pass {
|
|||||||
run_for_modules generic_checker run go vet
|
run_for_modules generic_checker run go vet
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# TODO: should skip *.pb.go
|
||||||
function govet_shadow_pass {
|
function govet_shadow_pass {
|
||||||
local shadow
|
local shadow
|
||||||
shadow=$(tool_get_bin "golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow")
|
shadow=$(tool_get_bin "golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow") || return $?
|
||||||
run_for_modules generic_checker run go vet -all -vettool="${shadow}"
|
run_for_modules generic_checker run go vet -all -vettool="${shadow}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -458,10 +462,11 @@ function unconvert_pass {
|
|||||||
run_for_modules generic_checker run_go_tool "github.com/mdempsky/unconvert" unconvert -v
|
run_for_modules generic_checker run_go_tool "github.com/mdempsky/unconvert" unconvert -v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# TODO: should run with package
|
||||||
function ineffassign_per_package {
|
function ineffassign_per_package {
|
||||||
# bash 3.x compatible replacement of: mapfile -t gofiles < <(go_srcs_in_module "$1")
|
# bash 3.x compatible replacement of: mapfile -t gofiles < <(go_srcs_in_module)
|
||||||
local gofiles=()
|
local gofiles=()
|
||||||
while IFS= read -r line; do gofiles+=("$line"); done < <(go_srcs_in_module "$1")
|
while IFS= read -r line; do gofiles+=("$line"); done < <(go_srcs_in_module)
|
||||||
run_go_tool github.com/gordonklaus/ineffassign "${gofiles[@]}"
|
run_go_tool github.com/gordonklaus/ineffassign "${gofiles[@]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -474,10 +479,11 @@ function nakedret_pass {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function license_header_pass {
|
function license_header_pass {
|
||||||
# bash 3.x compatible replacement of: mapfile -t gofiles < <(go_srcs_in_module "$1")
|
# bash 3.x compatible replacement of: mapfile -t gofiles < <(go_srcs_in_module)
|
||||||
local gofiles=()
|
local gofiles=()
|
||||||
while IFS= read -r line; do gofiles+=("$line"); done < <(go_srcs_in_module "$1")
|
while IFS= read -r line; do gofiles+=("$line"); done < <(go_srcs_in_module)
|
||||||
|
|
||||||
|
local licRes=""
|
||||||
for file in "${gofiles[@]}"; do
|
for file in "${gofiles[@]}"; do
|
||||||
if ! head -n3 "${file}" | grep -Eq "(Copyright|generated|GENERATED)" ; then
|
if ! head -n3 "${file}" | grep -Eq "(Copyright|generated|GENERATED)" ; then
|
||||||
licRes="${licRes}"$(echo -e " ${file}")
|
licRes="${licRes}"$(echo -e " ${file}")
|
||||||
@ -490,9 +496,9 @@ function license_header_pass {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function receiver_name_for_package {
|
function receiver_name_for_package {
|
||||||
# bash 3.x compatible replacement of: mapfile -t gofiles < <(go_srcs_in_module "$1")
|
# bash 3.x compatible replacement of: mapfile -t gofiles < <(go_srcs_in_module)
|
||||||
local gofiles=()
|
local gofiles=()
|
||||||
while IFS= read -r line; do gofiles+=("$line"); done < <(go_srcs_in_module "$1")
|
while IFS= read -r line; do gofiles+=("$line"); done < <(go_srcs_in_module)
|
||||||
|
|
||||||
recvs=$(grep 'func ([^*]' "${gofiles[@]}" | tr ':' ' ' | \
|
recvs=$(grep 'func ([^*]' "${gofiles[@]}" | tr ':' ' ' | \
|
||||||
awk ' { print $2" "$3" "$4" "$1 }' | sed "s/[a-zA-Z\\.]*go//g" | sort | uniq | \
|
awk ' { print $2" "$3" "$4" "$1 }' | sed "s/[a-zA-Z\\.]*go//g" | sort | uniq | \
|
||||||
@ -516,9 +522,9 @@ function receiver_name_pass {
|
|||||||
# checks spelling and comments in the 'package' in the current module
|
# checks spelling and comments in the 'package' in the current module
|
||||||
#
|
#
|
||||||
function goword_for_package {
|
function goword_for_package {
|
||||||
# bash 3.x compatible replacement of: mapfile -t gofiles < <(go_srcs_in_module "$1")
|
# bash 3.x compatible replacement of: mapfile -t gofiles < <(go_srcs_in_module)
|
||||||
local gofiles=()
|
local gofiles=()
|
||||||
while IFS= read -r line; do gofiles+=("$line"); done < <(go_srcs_in_module "$1")
|
while IFS= read -r line; do gofiles+=("$line"); done < <(go_srcs_in_module)
|
||||||
|
|
||||||
local gowordRes
|
local gowordRes
|
||||||
|
|
||||||
@ -631,7 +637,7 @@ function release_pass {
|
|||||||
rm -f ./bin/etcd-last-release
|
rm -f ./bin/etcd-last-release
|
||||||
# to grab latest patch release; bump this up for every minor release
|
# to grab latest patch release; bump this up for every minor release
|
||||||
UPGRADE_VER=$(git tag -l --sort=-version:refname "v3.4.*" | head -1)
|
UPGRADE_VER=$(git tag -l --sort=-version:refname "v3.4.*" | head -1)
|
||||||
if [ -n "$MANUAL_VER" ]; then
|
if [ -n "${MANUAL_VER:-}" ]; then
|
||||||
# in case, we need to test against different version
|
# in case, we need to test against different version
|
||||||
UPGRADE_VER=$MANUAL_VER
|
UPGRADE_VER=$MANUAL_VER
|
||||||
fi
|
fi
|
||||||
@ -675,6 +681,7 @@ function mod_tidy_for_module {
|
|||||||
local tmpFileGoModInSync
|
local tmpFileGoModInSync
|
||||||
diff -C 5 "${tmpModDir}/go.mod" "./go.mod"
|
diff -C 5 "${tmpModDir}/go.mod" "./go.mod"
|
||||||
tmpFileGoModInSync="$?"
|
tmpFileGoModInSync="$?"
|
||||||
|
set -e
|
||||||
|
|
||||||
# Bring back initial state
|
# Bring back initial state
|
||||||
mv "${tmpModDir}/go.mod" "./go.mod"
|
mv "${tmpModDir}/go.mod" "./go.mod"
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
if ! [[ "$0" =~ "tests/functional/build" ]]; then
|
if ! [[ "$0" =~ "tests/functional/build" ]]; then
|
||||||
echo "must be run from repository root"
|
echo "must be run from repository root"
|
||||||
exit 255
|
exit 255
|
||||||
|
Loading…
x
Reference in New Issue
Block a user