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

Migrate jobs from ci.centos to GH actions #451

Merged
merged 14 commits into from
Sep 24, 2020
93 changes: 48 additions & 45 deletions .ci/cico_minishift_nightly.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,74 +12,78 @@

set -ex

init() {
#Stop execution on any error
trap "catchFinish" EXIT SIGINT

# Catch_Finish is executed after finish script.
catchFinish() {
result=$?

if [ "$result" != "0" ]; then
echo "[ERROR] Please check the artifacts in github actions"
getOCCheClusterLogs
exit 1
fi

echo "[INFO] Job finished Successfully.Please check the artifacts in github actions"
getOCCheClusterLogs

exit $result
}

# Define global environments
function init() {
export SCRIPT=$(readlink -f "$0")
export SCRIPT_DIR=$(dirname "$SCRIPT")
export RAM_MEMORY=8192
export NAMESPACE="che"
export OPERATOR_IMAGE="quay.io/eclipse/che-operator:test"
export PLATFORM="openshift"

# Set operator root directory
if [[ ${WORKSPACE} ]] && [[ -d ${WORKSPACE} ]]; then
OPERATOR_REPO=${WORKSPACE};
else
OPERATOR_REPO=$(dirname "$SCRIPT_DIR");
fi

}

installDependencies() {
install_VirtPackages
installStartDocker
start_libvirt
setup_kvm_machine_driver
minishift_installation
installChectl
installJQ
load_jenkins_vars
}

self_signed_minishift() {
export DOMAIN=*.$(minishift ip).nip.io

source ${OPERATOR_REPO}/.ci/util/che-cert-generation.sh

#Configure Router with generated certificate:
oc login -u system:admin --insecure-skip-tls-verify=true
oc project default
oc delete secret router-certs

cat domain.crt domain.key > minishift.crt
oc create secret tls router-certs --key=domain.key --cert=minishift.crt
oc rollout latest router

oc create namespace che

cp rootCA.crt ca.crt
oc create secret generic self-signed-certificate --from-file=ca.crt -n=che
# Utility to get che events and pod logs from openshift cluster
function getOCCheClusterLogs() {
mkdir -p /tmp/artifacts-che
cd /tmp/artifacts-che

for POD in $(oc get pods -o name -n ${NAMESPACE}); do
for CONTAINER in $(oc get -n ${NAMESPACE} ${POD} -o jsonpath="{.spec.containers[*].name}"); do
echo ""
echo "[INFO] Getting logs from $POD"
echo ""
oc logs ${POD} -c ${CONTAINER} -n ${NAMESPACE} |tee $(echo ${POD}-${CONTAINER}.log | sed 's|pod/||g')
done
done
echo "[INFO] Get events"
oc get events -n ${NAMESPACE}| tee get_events.log
oc get all | tee get_all.log
}

run() {
# Deploy Eclipse Che
function run() {
cat >/tmp/che-cr-patch.yaml <<EOL
spec:
auth:
updateAdminPassword: false
openShiftoAuth: false
EOL
echo "======= Che cr patch ======="
cat /tmp/che-cr-patch.yaml

self_signed_minishift

# Build operator image
buildCheOperatorImage "minishift" ${OPERATOR_IMAGE}
# OPERATOR_IMAGE In CI is defined in .github/workflows/che-nightly.yaml
export OPERATOR_IMAGE="quay.io/eclipse/che-operator:test"

# Use custom changes, don't pull image from quay.io
cat ${OPERATOR_REPO}/deploy/operator.yaml | \
sed 's|imagePullPolicy: Always|imagePullPolicy: IfNotPresent|' | \
sed 's|quay.io/eclipse/che-operator:nightly|'${OPERATOR_IMAGE}'|' | \
oc apply -n ${NAMESPACE} -f -
cat deploy/operator.yaml | \
sed 's|imagePullPolicy: Always|imagePullPolicy: IfNotPresent|' | \
sed 's|quay.io/eclipse/che-operator:nightly|'${OPERATOR_IMAGE}'|' | \
oc apply -n ${NAMESPACE} -f -

echo "======= Che cr patch ======="
cat /tmp/che-cr-patch.yaml
chectl server:start --platform=minishift --skip-kubernetes-health-check --installer=operator --chenamespace=${NAMESPACE} --che-operator-cr-patch-yaml=/tmp/che-cr-patch.yaml --che-operator-image ${OPERATOR_IMAGE}

# Create and start a workspace
Expand All @@ -93,5 +97,4 @@ EOL

init
source "${OPERATOR_REPO}"/.ci/util/ci_common.sh
installDependencies
run
47 changes: 30 additions & 17 deletions .ci/cico_olm_minikube.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@
# SPDX-License-Identifier: EPL-2.0
#

set -e
set -ex
# Detect the base directory where che-operator is cloned
SCRIPT=$(readlink -f "$0")
export SCRIPT

OPERATOR_REPO=$(dirname "$(dirname "$SCRIPT")");
export OPERATOR_REPO

# Import operator bash utilities
source "${OPERATOR_REPO}"/.ci/util/ci_common.sh

# Container image name of Catalog source
CATALOG_SOURCE_IMAGE=my_image
export CATALOG_SOURCE_IMAGE
Expand Down Expand Up @@ -43,44 +46,54 @@ export OPERATOR_IMAGE
IMAGE_REGISTRY_HOST="0.0.0.0:5000"
export IMAGE_REGISTRY_HOST

#Stop execution on any error
trap "catchFinish" EXIT SIGINT

# Catch_Finish is executed after finish script.
catchFinish() {
result=$?

if [ "$result" != "0" ]; then
echo "[ERROR] Please check the artifacts in github actions"
getCheClusterLogs
exit 1
fi

echo "[INFO] Job finished Successfully.Please check the artifacts in github actions"
getCheClusterLogs

exit $result
}

# run function run the tests in ci of custom catalog source.
function run() {
# Execute test catalog source script
source "${OPERATOR_REPO}"/olm/testCatalogSource.sh ${PLATFORM} ${CHANNEL} ${NAMESPACE} ${INSTALLATION_TYPE} ${CATALOG_SOURCE_IMAGE}

source "${OPERATOR_REPO}"/.ci/util/ci_common.sh

# Create and start a workspace
getCheAcessToken
chectl workspace:create --start --devfile=$OPERATOR_REPO/.ci/util/devfile-test.yaml
chectl workspace:create --devfile=$OPERATOR_REPO/.ci/util/devfile-test.yaml

getCheAcessToken
chectl workspace:list
workspaceList=$(chectl workspace:list)
workspaceID=$(echo "$workspaceList" | grep -oP '\bworkspace.*?\b')
chectl workspace:start $workspaceID
waitWorkspaceStart
}

function setPrivateRegistryForDocker {
dockerDaemonConfig="/etc/docker/daemon.json"
mkdir -p "/etc/docker"
touch "${dockerDaemonConfig}"
sudo mkdir -p "/etc/docker"
sudo touch "${dockerDaemonConfig}"

config="{\"insecure-registries\" : [\"${IMAGE_REGISTRY_HOST}\"]}"
echo "${config}" | sudo tee "${dockerDaemonConfig}"

if [ -x "$(command -v docker)" ]; then
echo "[INFO] Restart docker daemon to set up private registry info."
systemctl restart docker
sudo service docker restart
fi
}

source "${OPERATOR_REPO}"/.ci/util/ci_common.sh
installYQ
installJQ
install_VirtPackages
# Docker should trust minikube private registry provided by "registry" addon
setPrivateRegistryForDocker
installStartDocker

source ${OPERATOR_REPO}/.ci/start-minikube.sh
installChectl
run
2 changes: 1 addition & 1 deletion .ci/cico_olm_openshift.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export CATALOG_SOURCE_IMAGE_NAME

# This image is builded by Openshift CI and exposed to be consumed for olm tests.
#OPENSHIFT_BUILD_NAMESPACE env var exposed by Openshift CI. More info about how images are builded in Openshift CI: https://github.com/openshift/ci-tools/blob/master/TEMPLATES.md#parameters-available-to-templates
CATALOG_SOURCE_IMAGE=registry.svc.ci.openshift.org/${OPENSHIFT_BUILD_NAMESPACE}/${CATALOG_SOURCE_IMAGE_NAME}
CATALOG_SOURCE_IMAGE="che-catalog"
export CATALOG_SOURCE_IMAGE

# Choose if install Eclipse Che using an operatorsource or Custom Catalog Source
Expand Down
73 changes: 0 additions & 73 deletions .ci/cico_operator_prcheck.sh

This file was deleted.

35 changes: 14 additions & 21 deletions .ci/cico_updates_minikube.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,22 @@ set -ex
trap "catchFinish" EXIT SIGINT

# Catch_Finish is executed after finish script.
catchFinish() {
function catchFinish() {
result=$?

if [ "$result" != "0" ]; then
printInfo "Failed on running tests. Please check logs or contact QE team (e-mail:codereadyqe-workspaces-qe@redhat.com, Slack: #che-qe-internal, Eclipse mattermost: 'Eclipse Che QE'"
printInfo "Logs should be availabe on http://artifacts.ci.centos.org/devtools/che/che-eclipse-minikube-updates/${ghprbPullId}/"
exit 1
echo "[ERROR] Please check the artifacts in github actions"
getCheClusterLogs
archiveArtifacts "che-operator-minikube-updates"
exit 1
fi
rm -rf ~/.kube ~/.minikube

echo "[INFO] Job finished Successfully.Please check the artifacts in github actions"
getCheClusterLogs

exit $result
}

init() {
function init() {
SCRIPT=$(readlink -f "$0")
SCRIPT_DIR=$(dirname "$SCRIPT")

Expand All @@ -45,16 +47,7 @@ init() {
CHANNEL="stable"
}

installDependencies() {
installYQ
installJQ
install_VirtPackages
installStartDocker
source ${OPERATOR_REPO}/.ci/start-minikube.sh
installChectl
}

waitCheUpdateInstall() {
function waitCheUpdateInstall() {
export packageName=eclipse-che-preview-${PLATFORM}
export platformPath=${OPERATOR_REPO}/olm/${packageName}
export packageFolderPath="${platformPath}/deploy/olm-catalog/${packageName}"
Expand All @@ -81,14 +74,14 @@ waitCheUpdateInstall() {

if [ $n -gt 360 ]
then
echo "Latest version install for Eclipse che failed."
echo "[ERROR] Latest version install for Eclipse che failed."
exit 1
fi
}

testUpdates() {
function testUpdates() {
"${OPERATOR_REPO}"/olm/testUpdate.sh ${PLATFORM} ${CHANNEL} ${NAMESPACE}
printInfo "Successfully installed Eclipse Che previous version."
echo "[INFO] Successfully installed Eclipse Che previous version."

getCheAcessToken
chectl workspace:create --devfile=$OPERATOR_REPO/.ci/util/devfile-test.yaml
Expand All @@ -98,12 +91,12 @@ testUpdates() {

workspaceList=$(chectl workspace:list)
workspaceID=$(echo "$workspaceList" | grep -oP '\bworkspace.*?\b')
echo "[INFO] Workspace id of created workspace is: ${workspaceID}"
chectl workspace:start $workspaceID

waitWorkspaceStart
}

init
source "${OPERATOR_REPO}"/.ci/util/ci_common.sh
installDependencies
testUpdates
Loading