Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-4.17] NO-ISSUE: Performance CI job: get BRANCH and JOB_TYPE from CI #3845

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ AWSCLI="${OUTPUTDIR}/bin/aws"
export AWS_PROFILE=microshift-ci
export AWS_BUCKET_NAME=microshift-footprint-and-performance

JOB_TYPE=${JOB_TYPE:-}
if [[ "${JOB_TYPE}" != "periodic" ]]; then
: Non periodic job was detected - skipping pushing results to S3
exit 0
fi

if [ ! -e "${AWSCLI}" ] ; then
"${ROOTDIR}/scripts/fetch_tools.sh" awscli
fi
Expand All @@ -19,30 +25,5 @@ if ! "${AWSCLI}" s3 ls "${AWS_BUCKET_NAME}" &>/dev/null ; then
exit 1
fi

get_build_branch() {
local -r ocp_ver="$(grep ^OCP_VERSION "${ROOTDIR}/Makefile.version.$(uname -m).var" | awk '{print $NF}' | awk -F. '{print $1"."$2}')"
local -r cur_branch="$(git branch --show-current 2>/dev/null)"

# Check if the current branch is derived from "main"
local -r main_top=$(git rev-parse main 2>/dev/null)
local -r main_base="$(git merge-base "${cur_branch}" main 2>/dev/null)"
if [ "${main_top}" = "${main_base}" ] ; then
echo "main"
return
fi

# Check if the current branch is derived from "release-${ocp-ver}"
local -r rel_top=$(git rev-parse "release-${ocp_ver}" 2>/dev/null)
local -r rel_base="$(git merge-base "${cur_branch}" "release-${ocp_ver}" 2>/dev/null)"
if [ "${rel_top}" = "${rel_base}" ] ; then
echo "release-${ocp_ver}"
return
fi

# Fallback to main if none of the above works
echo "main"
}

SCENARIO_BUILD_BRANCH="$(get_build_branch)"

"${AWSCLI}" s3 sync "${ARTIFACTS_DIR}" "s3://${AWS_BUCKET_NAME}/${SCENARIO_BUILD_BRANCH}/"
BRANCH=${BRANCH:-main}
"${AWSCLI}" s3 sync "${ARTIFACTS_DIR}" "s3://${AWS_BUCKET_NAME}/${BRANCH}/"