Add script to deploy eclipse stable and update to nightly in openshift ci

Signed-off-by: Flavius Lacatusu <flacatus@redhat.com>
pull/836/head
Flavius Lacatusu 2021-05-17 14:03:19 +02:00
parent f5bbf11ae9
commit 4298133d34
No known key found for this signature in database
GPG Key ID: 3C0A7685C14681A8
2 changed files with 68 additions and 1 deletions

53
.ci/oci-nightly-update.sh Executable file
View File

@ -0,0 +1,53 @@
#!/bin/bash
#
# Copyright (c) 2012-2021 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
################################ !!! IMPORTANT !!! ################################
########### THIS JOB USE openshift ci operators workflows to run #####################
########## More info about how it is configured can be found here: https://docs.ci.openshift.org/docs/how-tos/testing-operator-sdk-operators #############
#######################################################################################################################################################
# exit immediately when a command fails
set -e
# only exit with zero if all commands of the pipeline exit successfully
set -o pipefail
# error on unset variables
set -u
export OPERATOR_REPO=$(dirname $(dirname $(readlink -f "$0")));
source "${OPERATOR_REPO}"/.github/bin/common.sh
source "${OPERATOR_REPO}"/.github/bin/oauth-provision.sh
#Stop execution on any error
trap "catchFinish" EXIT SIGINT
overrideDefaults() {
# CI_CHE_OPERATOR_IMAGE it is che operator image builded in openshift CI job workflow. More info about how works image dependencies in ci:https://github.com/openshift/ci-tools/blob/master/TEMPLATES.md#parameters-available-to-templates
export OPERATOR_IMAGE=${CI_CHE_OPERATOR_IMAGE:-"quay.io/eclipse/che-operator:nightly"}
}
runTests() {
deployEclipseCheStableWithChectl ${LAST_PACKAGE_VERSION}
provisionOAuth
createWorkspace
# Update Eclipse Che to nightly and start workspace
initLatestTemplates
chectl server:update --yes --templates="${TEMPLATES}"
patchEclipseCheOperatorSubscription
waitEclipseCheDeployed "nightly"
startExistedWorkspace
waitWorkspaceStart
}
initDefaults
overrideDefaults
provisionOpenShiftOAuthUser
getLatestsStableVersions
runTests

16
.github/bin/common.sh vendored
View File

@ -55,7 +55,7 @@ curl -L https://api.github.com/repos/devfile/devworkspace-operator/zipball/${DEV
cp -rf ${OPERATOR_REPO}/deploy/* "${TEMPLATES}/che-operator"
}
initStableTemplates() {
getLatestsStableVersions() {
# Get Stable and new release versions from olm files openshift.
versions=$(curl \
-H "Authorization: bearer ${GITHUB_TOKEN}" \
@ -69,6 +69,10 @@ initStableTemplates() {
export LAST_PACKAGE_VERSION
PREVIOUS_PACKAGE_VERSION=$(echo "${versions[@]}" | jq '.data.repository.refs.edges[0].node.name | sub("\""; "")' | tr -d '"')
export PREVIOUS_PACKAGE_VERSION
}
initStableTemplates() {
getLatestsStableVersions
export lastOperatorPath=${OPERATOR_REPO}/tmp/${LAST_PACKAGE_VERSION}
export previousOperatorPath=${OPERATOR_REPO}/tmp/${PREVIOUS_PACKAGE_VERSION}
@ -406,3 +410,13 @@ waitWorkspaceStartedDevWorkspaceController() {
createWorkspaceDevWorkspaceCheOperator() {
oc apply -f https://raw.githubusercontent.com/che-incubator/devworkspace-che-operator/main/samples/flattened_theia-nodejs.yaml -n ${NAMESPACE}
}
deployEclipseCheStableWithChectl() {
local CHE_VERSION=$1
cat >/tmp/che-cr-patch.yaml <<EOL
spec:
server:
updateAdminPassword: false
EOL
chectl server:deploy --installer=operator --platform=openshift --batch --che-operator-cr-patch-yaml=/tmp/che-cr-patch.yaml --version="${CHE_VERSION}"
}