From adc05e40245fb24333816ed8672c7f9130d9d7c1 Mon Sep 17 00:00:00 2001 From: Philippe Martin Date: Mon, 18 Oct 2021 09:29:45 +0200 Subject: [PATCH] Set pipelines on git --- .ibm/pipelines/functions.sh | 61 ++++++++++++++++++++++++++++++ .ibm/pipelines/kubernetes-tests.sh | 25 ++++++++++++ .ibm/pipelines/openshift-tests.sh | 27 +++++++++++++ .ibm/pipelines/unit-tests.sh | 19 ++++++++++ 4 files changed, 132 insertions(+) create mode 100644 .ibm/pipelines/functions.sh create mode 100644 .ibm/pipelines/kubernetes-tests.sh create mode 100644 .ibm/pipelines/openshift-tests.sh create mode 100644 .ibm/pipelines/unit-tests.sh diff --git a/.ibm/pipelines/functions.sh b/.ibm/pipelines/functions.sh new file mode 100644 index 00000000000..d246cb71d0c --- /dev/null +++ b/.ibm/pipelines/functions.sh @@ -0,0 +1,61 @@ +# Install the ibmcloud cli, +# install the plugins passed as parameters +# and connect to the Cloud +# Env vars: +# API_KEY: IBM Cloud API Key +# IBM_REGION: IBM Cloud region +install_ibmcloud() { + curl -fsSL https://clis.cloud.ibm.com/install/linux | sh + for plugin in "$@" + do + ibmcloud plugin install -f "${plugin}" + done + ibmcloud login --apikey "${API_KEY}" -r "${IBM_REGION}" +} + +install_kubectl() { + curl -sLO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl + chmod +x kubectl + mv kubectl /usr/local/bin/ +} + +install_oc() { + curl -sLO https://raw.githubusercontent.com/cptmorgan-rh/install-oc-tools/master/install-oc-tools.sh > /dev/null + chmod +x install-oc-tools.sh + ./install-oc-tools.sh --latest 4.7 +} + +install_gh() { + curl -sLO https://github.com/cli/cli/releases/download/v2.1.0/gh_2.1.0_linux_amd64.deb + apt install ./gh_2.1.0_linux_amd64.deb +} + +# Save the logs from the file passed as parameter #1 +# and send a message to GitHub PR using parameter #2 as name of test +# Env vars: +# IBM_RESOURCE_GROUP: Resource group of the Cloud ObjectStorage +# IBM_COS: Cloud Object Storage containing the bucket on which to save logs +# IBM_BUCKET: Bucket name on which to save logs +save_logs() { + LOGFILE="$1" + NAME="$2" + apt update + apt install jq colorized-logs --yes + + ansi2html < "/tmp/${LOGFILE}" > "/tmp/${LOGFILE}.html" + ansi2txt < "/tmp/${LOGFILE}" > "/tmp/${LOGFILE}.txt" + + ibmcloud target -g "${IBM_RESOURCE_GROUP}" + CRN=$(ibmcloud resource service-instance ${IBM_COS} --output json | jq -r .[0].guid) + ibmcloud cos config crn --crn "${CRN}" + + ibmcloud cos upload --bucket "${IBM_BUCKET}" --key "${LOGFILE}.html" --file "/tmp/${LOGFILE}.html" + ibmcloud cos upload --bucket "${IBM_BUCKET}" --key "${LOGFILE}.txt" --file "/tmp/${LOGFILE}.txt" + + echo -n ${GITHUB_TOKEN} | gh auth login --with-token + BASE_URL="https://s3.${IBM_REGION}.cloud-object-storage.appdomain.cloud/${IBM_BUCKET}" + cat <