Skip to content

Commit

Permalink
fix pipeline failure for release test
Browse files Browse the repository at this point in the history
Signed-off-by: Benjamin Wang <[email protected]>
  • Loading branch information
ahrtr committed Jul 11, 2022
1 parent d3dfc9b commit d5a4ad7
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 6 deletions.
9 changes: 5 additions & 4 deletions scripts/build-binary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

set -e

source ./scripts/test_lib.sh

VER=$1
PROJ="etcd"
REPOSITORY="${REPOSITORY:-https://github.com/etcd-io/etcd.git}"

if [ -z "$1" ]; then
echo "Usage: ${0} VERSION" >> /dev/stderr
Expand All @@ -17,13 +20,11 @@ function setup_env {
local ver=${2}

if [ ! -d "${proj}" ]; then
git clone https://github.com/etcd-io/"${proj}"
run git clone "${REPOSITORY}"
fi

pushd "${proj}" >/dev/null
git checkout main
git fetch --all
git reset --hard origin/main
git checkout "${ver}"
popd >/dev/null
}
Expand Down Expand Up @@ -53,7 +54,7 @@ function package {
}

function main {
mkdir release
mkdir -p release
cd release
setup_env "${PROJ}" "${VER}"

Expand Down
5 changes: 3 additions & 2 deletions scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@ main() {
if [[ -n $(git status -s) ]]; then
log_callout "Committing version/version.go update."
git add version/version.go
git diff --staged | cat
git commit --signoff -m "version: bump up to ${VERSION}"
git diff --staged
git diff --staged | cat
fi

# Push the version change if it's not already been pushed.
Expand Down Expand Up @@ -163,7 +164,7 @@ main() {
log_callout "Building release..."
# Check for old and new names of the release build script.
# TODO: Move the release script into this on as a function?
./scripts/build-release.sh "${RELEASE_VERSION}"
REPOSITORY=$(pwd) ./scripts/build-release.sh "${RELEASE_VERSION}"
fi

# Sanity checks.
Expand Down
29 changes: 29 additions & 0 deletions scripts/test_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ COLOR_ORANGE='\033[0;33m'
COLOR_GREEN='\033[0;32m'
COLOR_LIGHTCYAN='\033[0;36m'
COLOR_BLUE='\033[0;94m'
COLOR_MAGENTA='\033[95m'
COLOR_BOLD='\033[1m'
COLOR_NONE='\033[0m' # No Color

Expand Down Expand Up @@ -52,3 +53,31 @@ function log_info {
>&2 echo "$@"
>&2 echo -n -e "${COLOR_NONE}"
}

#### Running actions against multiple modules ####

# run [command...] - runs given command, printing it first and
# again if it failed (in RED). Use to wrap important test commands
# that user might want to re-execute to shorten the feedback loop when fixing
# the test.
function run {
local rpath
local command
rpath=$(module_subdir)
# Quoting all components as the commands are fully copy-parsable:
command=("${@}")
command=("${command[@]@Q}")
if [[ "${rpath}" != "." && "${rpath}" != "" ]]; then
repro="(cd ${rpath} && ${command[*]})"
else
repro="${command[*]}"
fi

log_cmd "% ${repro}"
"${@}" 2> >(while read -r line; do echo -e "${COLOR_NONE}stderr: ${COLOR_MAGENTA}${line}${COLOR_NONE}">&2; done)
local error_code=$?
if [ ${error_code} -ne 0 ]; then
log_error -e "FAIL: (code:${error_code}):\\n % ${repro}"
return ${error_code}
fi
}

0 comments on commit d5a4ad7

Please sign in to comment.