Skip to content

Commit

Permalink
test: Try to use build from PR in e2e tests (stolostron#1410)
Browse files Browse the repository at this point in the history
* test: Try to use build from PR in e2e tests

Signed-off-by: Philip Gough <[email protected]>

* ci: Try to read env from bash script if kind test

Signed-off-by: Philip Gough <[email protected]>

* test: Split PR functionality from snapshot

Signed-off-by: Philip Gough <[email protected]>

---------

Signed-off-by: Philip Gough <[email protected]>
  • Loading branch information
philipgough authored Apr 24, 2024
1 parent 7ed3670 commit b7578a6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
4 changes: 4 additions & 0 deletions cicd-scripts/customize-mco.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ SED_COMMAND=${SED}' -i-e -e'
source ./scripts/test-utils.sh
LATEST_SNAPSHOT=${LATEST_SNAPSHOT:-$(get_latest_snapshot)}

if [[ -n ${IS_KIND_ENV} ]]; then
source ./tests/run-in-kind/env.sh
fi

# list all components need to do test.
CHANGED_COMPONENTS=""
GINKGO_FOCUS=""
Expand Down
21 changes: 19 additions & 2 deletions scripts/test-utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,33 @@
# Copyright (c) 2024 Red Hat, Inc.
# Copyright Contributors to the Open Cluster Management project

VERSION="2.11.0"

# Use the PR mirror image for PRs against main branch.
get_pr_image() {
BRANCH=""
LATEST_SNAPSHOT=""

if [[ ${PULL_BASE_REF} == "main" ]]; then
LATEST_SNAPSHOT="${VERSION}-PR${PULL_NUMBER}-${PULL_PULL_SHA}"
fi

# trim the leading and tailing quotes
LATEST_SNAPSHOT="${LATEST_SNAPSHOT#\"}"
LATEST_SNAPSHOT="${LATEST_SNAPSHOT%\"}"
echo ${LATEST_SNAPSHOT}
}

# Use snapshot for target release.
# Use latest if no branch info detected, or not a release branch.
get_latest_snapshot() {
BRANCH=""
LATEST_SNAPSHOT=""
SNAPSHOT_RELEASE=${SNAPSHOT_RELEASE:=2.10}
SNAPSHOT_RELEASE=${SNAPSHOT_RELEASE:=$VERSION}
MATCH=$SNAPSHOT_RELEASE".*-SNAPSHOT"
if [[ ${PULL_BASE_REF} == "release-"* ]]; then
BRANCH=${PULL_BASE_REF#"release-"}
LATEST_SNAPSHOT=$(curl https://quay.io//api/v1/repository/open-cluster-management/multicluster-observability-operator | jq '.tags|with_entries(select(.key|test("'${BRANCH}'.*-SNAPSHOT-*")))|keys[length-1]')
LATEST_SNAPSHOT=$(curl https://quay.io/api/v1/repository/open-cluster-management/multicluster-observability-operator | jq '.tags|with_entries(select(.key|test("'${BRANCH}'.*-SNAPSHOT-*")))|keys[length-1]')
fi
if [[ ${LATEST_SNAPSHOT} == "null" ]] || [[ ${LATEST_SNAPSHOT} == "" ]]; then
LATEST_SNAPSHOT=$(curl https://quay.io/api/v1/repository/stolostron/multicluster-observability-operator/tag/ | jq --arg MATCH "$MATCH" '.tags[] | select(.name | match($MATCH; "i") ).name' | sort -r --version-sort | head -n 1)
Expand Down

0 comments on commit b7578a6

Please sign in to comment.