From 7193d08e214c11b81623328aac7009bc8006e549 Mon Sep 17 00:00:00 2001 From: Francesco Ilario Date: Fri, 5 Apr 2024 08:32:41 +0200 Subject: [PATCH 1/4] add toolchain build/push and install scripts Signed-off-by: Francesco Ilario --- hack/demo.sh | 12 +++++- hack/install_toolchain.sh | 26 ------------ hack/toolchain_build_push.sh | 31 ++++++++++++++ hack/toolchain_install.sh | 42 +++++++++++++++++++ ...ll_workspaces.sh => workspaces_install.sh} | 0 5 files changed, 83 insertions(+), 28 deletions(-) delete mode 100755 hack/install_toolchain.sh create mode 100755 hack/toolchain_build_push.sh create mode 100755 hack/toolchain_install.sh rename hack/{install_workspaces.sh => workspaces_install.sh} (100%) diff --git a/hack/demo.sh b/hack/demo.sh index 05c8f65f..74a32851 100755 --- a/hack/demo.sh +++ b/hack/demo.sh @@ -2,10 +2,18 @@ set -e -o pipefail +# parse input export QUAY_NAMESPACE=${QUAY_NAMESPACE:-workspaces} CURRENT_DIR="$(readlink -f "$0")" SCRIPT_DIR="$(dirname "${CURRENT_DIR}")" -( "${SCRIPT_DIR}/install_toolchain.sh" ) -( "${SCRIPT_DIR}/install_workspaces.sh" && make -C e2e test ) +SUFFIX="e2e$(date +'%d%H%M%S')" +echo "using suffix: $SUFFIX" + +# build and install toolchain +( "$SCRIPT_DIR/toolchain_build_push.sh" "$SUFFIX" ) +( "$SCRIPT_DIR/toolchain_install.sh" "$SUFFIX" ) + +# build and install workspaces +( "$SCRIPT_DIR/workspaces_install.sh" && make -C e2e test ) diff --git a/hack/install_toolchain.sh b/hack/install_toolchain.sh deleted file mode 100755 index 8f62d18b..00000000 --- a/hack/install_toolchain.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -set -e - -export QUAY_NAMESPACE=${QUAY_NAMESPACE:-workspaces} - -f=$(mktemp --directory /tmp/toolchain.XXXX) - -cd "${f}" - -git clone --depth 2 https://github.com/codeready-toolchain/member-operator.git -git clone --depth 2 --branch public-viewer https://github.com/filariow/toolchain-e2e.git -git clone --depth 2 --branch public-viewer https://github.com/filariow/host-operator.git -git clone --depth 2 --branch public-viewer https://github.com/filariow/toolchain-common.git -git clone --depth 2 --branch public-viewer https://github.com/filariow/toolchain-api.git api -git clone --depth 2 --branch public-viewer https://github.com/filariow/registration-service - -make -C toolchain-e2e dev-deploy-e2e-local - -oc patch \ - toolchainconfigs.toolchain.dev.openshift.com config \ - -n toolchain-host-operator \ - --patch='{"spec":{"global":{"publicViewer":{"enabled":true,"username":"public-viewer"}}}}' \ - --type=merge - -oc delete pods --all -n toolchain-host-operator diff --git a/hack/toolchain_build_push.sh b/hack/toolchain_build_push.sh new file mode 100755 index 00000000..c9ae776f --- /dev/null +++ b/hack/toolchain_build_push.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +set -e + +# parse input +BRANCH=${BRANCH:-pubviewer-mvp} +BUILDER=${BUILDER:-docker} +TAG=${1:-e2etest} + +export QUAY_NAMESPACE=${QUAY_NAMESPACE:-konflux-workspaces} + +# create a temporary direction +f=$(mktemp --directory /tmp/toolchain.XXXX) +cd "$f" + +# checkout +git clone --depth 2 https://github.com/codeready-toolchain/member-operator.git +git clone --depth 2 --branch "${BRANCH}" https://github.com/filariow/host-operator.git +git clone --depth 1 --branch "${BRANCH}" https://github.com/filariow/toolchain-common.git +git clone --depth 1 --branch "${BRANCH}" https://github.com/filariow/toolchain-api.git api +git clone --depth 1 --branch "${BRANCH}" https://github.com/filariow/registration-service +git clone --depth 1 --branch "${BRANCH}" https://github.com/filariow/toolchain-e2e + +# build and publish images +make -C member-operator run-cicd-script \ + SCRIPT_PATH=scripts/ci/manage-member-operator.sh \ + SCRIPT_PARAMS="-po true -io false -mn toolchain-member-operator -qn $QUAY_NAMESPACE -ds $TAG -dl false -mr ./" + +make -C host-operator run-cicd-script \ + SCRIPT_PATH=scripts/ci/manage-host-operator.sh \ + SCRIPT_PARAMS="-po true -io false -hn toolchain-host-operator -qn $QUAY_NAMESPACE -ds $TAG -dl false -hr ./ -rr ../registration-service" diff --git a/hack/toolchain_install.sh b/hack/toolchain_install.sh new file mode 100755 index 00000000..6ecd4665 --- /dev/null +++ b/hack/toolchain_install.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +set -e + +# parse input +BRANCH=${BRANCH:-pubviewer-mvp} +export QUAY_NAMESPACE=${QUAY_NAMESPACE:-workspaces} +TAG=${1:-e2etest} + +# create a temporary direction +f=$(mktemp --directory /tmp/toolchain.XXXX) +cd "$f" + +# checkout +git clone --depth 2 https://github.com/codeready-toolchain/member-operator.git +git clone --depth 2 --branch "${BRANCH}" https://github.com/filariow/toolchain-e2e.git +git clone --depth 2 --branch "${BRANCH}" https://github.com/filariow/host-operator.git +git clone --depth 2 --branch "${BRANCH}" https://github.com/filariow/toolchain-common.git +git clone --depth 2 --branch "${BRANCH}" https://github.com/filariow/toolchain-api.git api +git clone --depth 2 --branch "${BRANCH}" https://github.com/filariow/registration-service + +# deploy +( + kubectl create namespace toolchain-host-operator --dry-run=client --output=yaml | \ + kubectl apply -f - + kubectl create namespace toolchain-member-operator --dry-run=client --output=yaml | \ + kubectl apply -f - + + cd "$f/toolchain-e2e" + + make dev-deploy-e2e-local PUBLISH_OPERATOR=false DATE_SUFFIX="$TAG" DEPLOY_LATEST=false +) + +# patch configuration +oc patch \ + toolchainconfigs.toolchain.dev.openshift.com config \ + -n toolchain-host-operator \ + --patch='{"spec":{"global":{"publicViewer":{"enabled":true,"username":"public-viewer"}}}}' \ + --type=merge + +# restart operator +oc delete pods --all -n toolchain-host-operator diff --git a/hack/install_workspaces.sh b/hack/workspaces_install.sh similarity index 100% rename from hack/install_workspaces.sh rename to hack/workspaces_install.sh From 8c8b8a2b227de133ba90c73b187086903c9d72b1 Mon Sep 17 00:00:00 2001 From: Francesco Ilario Date: Tue, 9 Apr 2024 10:14:58 +0200 Subject: [PATCH 2/4] fix shellcheck optional checks Signed-off-by: Francesco Ilario --- hack/demo.sh | 8 ++++---- hack/toolchain_build_push.sh | 6 +++--- hack/toolchain_install.sh | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/hack/demo.sh b/hack/demo.sh index 74a32851..6edc2573 100755 --- a/hack/demo.sh +++ b/hack/demo.sh @@ -9,11 +9,11 @@ CURRENT_DIR="$(readlink -f "$0")" SCRIPT_DIR="$(dirname "${CURRENT_DIR}")" SUFFIX="e2e$(date +'%d%H%M%S')" -echo "using suffix: $SUFFIX" +echo "using suffix: ${SUFFIX}" # build and install toolchain -( "$SCRIPT_DIR/toolchain_build_push.sh" "$SUFFIX" ) -( "$SCRIPT_DIR/toolchain_install.sh" "$SUFFIX" ) +( "${SCRIPT_DIR}/toolchain_build_push.sh" "${SUFFIX}" ) +( "${SCRIPT_DIR}/toolchain_install.sh" "${SUFFIX}" ) # build and install workspaces -( "$SCRIPT_DIR/workspaces_install.sh" && make -C e2e test ) +( "${SCRIPT_DIR}/workspaces_install.sh" && make -C e2e test ) diff --git a/hack/toolchain_build_push.sh b/hack/toolchain_build_push.sh index c9ae776f..b7d92c46 100755 --- a/hack/toolchain_build_push.sh +++ b/hack/toolchain_build_push.sh @@ -11,7 +11,7 @@ export QUAY_NAMESPACE=${QUAY_NAMESPACE:-konflux-workspaces} # create a temporary direction f=$(mktemp --directory /tmp/toolchain.XXXX) -cd "$f" +cd "${f}" # checkout git clone --depth 2 https://github.com/codeready-toolchain/member-operator.git @@ -24,8 +24,8 @@ git clone --depth 1 --branch "${BRANCH}" https://github.com/filariow/toolchain-e # build and publish images make -C member-operator run-cicd-script \ SCRIPT_PATH=scripts/ci/manage-member-operator.sh \ - SCRIPT_PARAMS="-po true -io false -mn toolchain-member-operator -qn $QUAY_NAMESPACE -ds $TAG -dl false -mr ./" + SCRIPT_PARAMS="-po true -io false -mn toolchain-member-operator -qn ${QUAY_NAMESPACE} -ds ${TAG} -dl false -mr ./" make -C host-operator run-cicd-script \ SCRIPT_PATH=scripts/ci/manage-host-operator.sh \ - SCRIPT_PARAMS="-po true -io false -hn toolchain-host-operator -qn $QUAY_NAMESPACE -ds $TAG -dl false -hr ./ -rr ../registration-service" + SCRIPT_PARAMS="-po true -io false -hn toolchain-host-operator -qn ${QUAY_NAMESPACE} -ds ${TAG} -dl false -hr ./ -rr ../registration-service" diff --git a/hack/toolchain_install.sh b/hack/toolchain_install.sh index 6ecd4665..d2a5c1ca 100755 --- a/hack/toolchain_install.sh +++ b/hack/toolchain_install.sh @@ -9,7 +9,7 @@ TAG=${1:-e2etest} # create a temporary direction f=$(mktemp --directory /tmp/toolchain.XXXX) -cd "$f" +cd "${f}" # checkout git clone --depth 2 https://github.com/codeready-toolchain/member-operator.git @@ -26,9 +26,9 @@ git clone --depth 2 --branch "${BRANCH}" https://github.com/filariow/registratio kubectl create namespace toolchain-member-operator --dry-run=client --output=yaml | \ kubectl apply -f - - cd "$f/toolchain-e2e" + cd "${f}/toolchain-e2e" - make dev-deploy-e2e-local PUBLISH_OPERATOR=false DATE_SUFFIX="$TAG" DEPLOY_LATEST=false + make dev-deploy-e2e-local PUBLISH_OPERATOR=false DATE_SUFFIX="${TAG}" DEPLOY_LATEST=false ) # patch configuration From c2ce386173885fe103d2c5674f23cba29681a7ba Mon Sep 17 00:00:00 2001 From: Francesco Ilario Date: Tue, 9 Apr 2024 10:19:20 +0200 Subject: [PATCH 3/4] replace kubectl/oc with variable Signed-off-by: Francesco Ilario --- hack/toolchain_install.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/hack/toolchain_install.sh b/hack/toolchain_install.sh index d2a5c1ca..fb184919 100755 --- a/hack/toolchain_install.sh +++ b/hack/toolchain_install.sh @@ -6,6 +6,7 @@ set -e BRANCH=${BRANCH:-pubviewer-mvp} export QUAY_NAMESPACE=${QUAY_NAMESPACE:-workspaces} TAG=${1:-e2etest} +KUBECLI=${KUBECLI:-kubectl} # create a temporary direction f=$(mktemp --directory /tmp/toolchain.XXXX) @@ -21,10 +22,10 @@ git clone --depth 2 --branch "${BRANCH}" https://github.com/filariow/registratio # deploy ( - kubectl create namespace toolchain-host-operator --dry-run=client --output=yaml | \ - kubectl apply -f - - kubectl create namespace toolchain-member-operator --dry-run=client --output=yaml | \ - kubectl apply -f - + ${KUBECLI} create namespace toolchain-host-operator --dry-run=client --output=yaml | \ + ${KUBECLI} apply -f - + ${KUBECLI} create namespace toolchain-member-operator --dry-run=client --output=yaml | \ + ${KUBECLI} apply -f - cd "${f}/toolchain-e2e" @@ -32,11 +33,11 @@ git clone --depth 2 --branch "${BRANCH}" https://github.com/filariow/registratio ) # patch configuration -oc patch \ +${KUBECLI} patch \ toolchainconfigs.toolchain.dev.openshift.com config \ -n toolchain-host-operator \ --patch='{"spec":{"global":{"publicViewer":{"enabled":true,"username":"public-viewer"}}}}' \ --type=merge # restart operator -oc delete pods --all -n toolchain-host-operator +${KUBECLI} delete pods --all -n toolchain-host-operator From ac06d98cb9353c134972c52aea80c7c75e5c0fce Mon Sep 17 00:00:00 2001 From: Francesco Ilario Date: Tue, 9 Apr 2024 10:21:55 +0200 Subject: [PATCH 4/4] fix sc2312 Signed-off-by: Francesco Ilario --- hack/toolchain_install.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hack/toolchain_install.sh b/hack/toolchain_install.sh index fb184919..bb410bfc 100755 --- a/hack/toolchain_install.sh +++ b/hack/toolchain_install.sh @@ -21,7 +21,9 @@ git clone --depth 2 --branch "${BRANCH}" https://github.com/filariow/toolchain-a git clone --depth 2 --branch "${BRANCH}" https://github.com/filariow/registration-service # deploy -( +( + set -e -o pipefail + ${KUBECLI} create namespace toolchain-host-operator --dry-run=client --output=yaml | \ ${KUBECLI} apply -f - ${KUBECLI} create namespace toolchain-member-operator --dry-run=client --output=yaml | \