diff --git a/.ci/oci-nightly-update.sh b/.ci/oci-nightly-update.sh new file mode 100755 index 000000000..96298eaa7 --- /dev/null +++ b/.ci/oci-nightly-update.sh @@ -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 diff --git a/.github/bin/common.sh b/.github/bin/common.sh index e8eb1585d..ef3c2dac2 100755 --- a/.github/bin/common.sh +++ b/.github/bin/common.sh @@ -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 <