Skip to content

Commit

Permalink
perf-test-process.sh: fixed working with BRANCH vs GIT_BRANCH
Browse files Browse the repository at this point in the history
  • Loading branch information
virgo47 committed Jan 11, 2021
1 parent 832cf93 commit e7f43ab
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions tools/perf-test/perf-test-process.sh
Expand Up @@ -12,23 +12,28 @@

set -eu

: "${PSQL:="psql"}" # can be overridden to psql.exe on Windows to avoid tty problems
: "${BUILD_NUMBER:="dev"}" # normally set by Jenkins
: "${GIT_BRANCH:=$(git rev-parse --abbrev-ref HEAD)}" # normally set by Jenkins
: "${GIT_COMMIT:=$(git show -s --format=%H)}" # normally set by Jenkins
# can be overridden to psql.exe on Windows to avoid tty problems
: "${PSQL:="psql"}"
# the rest is normally set by Jenkins, BRANCH is used instead of GIT_BRANCH that contains slashes
: "${BUILD_NUMBER:="dev"}"
: "${BRANCH:=$(git rev-parse --abbrev-ref HEAD)}"
: "${GIT_COMMIT:=$(git show -s --format=%H)}"

# backup
mkdir -p "${HOME}/perf-out/"
if [ -z "${TGZFILE:-}" ]; then
TARFILE="${HOME}/perf-out/mp-perf-${GIT_BRANCH}-${BUILD_NUMBER}-${GIT_COMMIT}.tar"
# if branch contains / we replace it with _ which we generally don't use in branch names
TARFILE="${HOME}/perf-out/mp-perf-${BRANCH/\//_}-${BUILD_NUMBER}-${GIT_COMMIT}.tar"
rm -f "${TARFILE}" "${TARFILE}.gz"
find -wholename '*target/PERF-*' -exec tar --transform 's/.*\///g' -rvf "${TARFILE}" {} \;
gzip "${TARFILE}"
TGZFILE="${TARFILE}.gz"
echo "Performance reports backed up to ${TGZFILE}"
else
echo "Importing ${TGZFILE} to DB"
GIT_BRANCH=$(basename $TGZFILE | cut -d- -f3)
BRANCH=$(basename $TGZFILE | cut -d- -f3)
# _ was likely / originally, see above
BRANCH="${BRANCH/_/\/}"
BUILD_NUMBER=$(basename $TGZFILE | cut -d- -f4)
GIT_COMMIT=$(basename $TGZFILE | cut -d- -f5 | cut -d. -f1)
fi
Expand All @@ -44,7 +49,7 @@ fi

# create new build entry
BUILD_ID=$(
"${PSQL}" -qtAX -c "insert into mst_build (build, branch, commit_hash, date) values ('${BUILD_NUMBER}', '${GIT_BRANCH}', '${GIT_COMMIT}', '${COMMIT_DATE}') returning id"
"${PSQL}" -qtAX -c "insert into mst_build (build, branch, commit_hash, date) values ('${BUILD_NUMBER}', '${BRANCH}', '${GIT_COMMIT}', '${COMMIT_DATE}') returning id"
)

echo "BUILD_ID = $BUILD_ID"
Expand Down

0 comments on commit e7f43ab

Please sign in to comment.