chore: enable strict mode for test CI

Signed-off-by: Wei Fu <fuweid89@gmail.com>
This commit is contained in:
Wei Fu
2023-03-25 16:48:33 +08:00
parent 7230b943d0
commit 55bce22e97
13 changed files with 77 additions and 52 deletions

View File

@@ -1,18 +1,17 @@
#!/usr/bin/env bash
set -e
set -euo pipefail
source ./scripts/test_lib.sh
VER=$1
VER=${1:-}
REPOSITORY="${REPOSITORY:-git@github.com:etcd-io/etcd.git}"
if [ -z "$1" ]; then
if [ -z "${VER}" ]; then
echo "Usage: ${0} VERSION" >> /dev/stderr
exit 255
fi
set -u
function setup_env {
local ver=${1}
@@ -38,7 +37,7 @@ function package {
srcdir="${ccdir}"
fi
local ext=""
if [ "${GOOS}" == "windows" ]; then
if [ "${GOOS:-}" == "windows" ]; then
ext=".exe"
fi
for bin in etcd etcdctl etcdutl; do
@@ -60,7 +59,7 @@ function main {
cd release
setup_env "${VER}" "${proj}"
tarcmd=tar
local tarcmd=tar
if [[ $(go env GOOS) == "darwin" ]]; then
echo "Please use linux machine for release builds."
exit 1

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash
set -e
set -euo pipefail
if [ "$#" -ne 1 ]; then
echo "Usage: $0 VERSION" >&2
@@ -11,7 +11,7 @@ ARCH=$(go env GOARCH)
VERSION="${1}-${ARCH}"
DOCKERFILE="Dockerfile-release.${ARCH}"
if [ -z "${BINARYDIR}" ]; then
if [ -z "${BINARYDIR:-}" ]; then
RELEASE="etcd-${1}"-$(go env GOOS)-$(go env GOARCH)
BINARYDIR="${RELEASE}"
TARFILE="${RELEASE}.tar.gz"
@@ -34,7 +34,7 @@ cp "${BINARYDIR}"/etcd "${BINARYDIR}"/etcdctl "${BINARYDIR}"/etcdutl "${IMAGEDIR
cat ./"${DOCKERFILE}" > "${IMAGEDIR}"/Dockerfile
if [ -z "$TAG" ]; then
if [ -z "${TAG:-}" ]; then
# Fix incorrect image "Architecture" using buildkit
# From https://stackoverflow.com/q/72144329/
DOCKER_BUILDKIT=1 docker build -t "gcr.io/etcd-development/etcd:${VERSION}" "${IMAGEDIR}"

View File

@@ -3,11 +3,11 @@
# Build all release binaries and images to directory ./release.
# Run from repository root.
#
set -e
set -euo pipefail
source ./scripts/test_lib.sh
VERSION=$1
VERSION=${1:-}
if [ -z "${VERSION}" ]; then
echo "Usage: ${0} VERSION" >> /dev/stderr
exit 255

View File

@@ -1,5 +1,7 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT_MODULE="go.etcd.io/etcd"
if [[ "$(go list)" != "${ROOT_MODULE}/v3" ]]; then
@@ -107,7 +109,7 @@ function relativePath {
#### 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.
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)"
@@ -171,7 +173,7 @@ function module_dirs() {
# maybe_run [cmd...] runs given command depending on the DRY_RUN flag.
function maybe_run() {
if ${DRY_RUN}; then
if ${DRY_RUN:-}; then
log_warning -e "# DRY_RUN:\\n % ${*}"
else
run "${@}"
@@ -243,7 +245,7 @@ function go_test {
local goTestFlags=""
local goTestEnv=""
if [ "${VERBOSE}" == "1" ]; then
if [ "${VERBOSE:-}" == "1" ]; then
goTestFlags="-v"
fi