From ba276cf4c56854e123c6c644acfa6bb8f38d2f7e Mon Sep 17 00:00:00 2001 From: Subhash Khileri Date: Fri, 5 Apr 2024 23:09:46 +0530 Subject: [PATCH] Update and Deploy Custom Playwright Image for OpenShift CI Integration (#1163) --- .ibm/images/Dockerfile | 46 +++++++++++++--------------- .ibm/pipelines/openshift-ci-tests.sh | 6 ++++ 2 files changed, 27 insertions(+), 25 deletions(-) create mode 100755 .ibm/pipelines/openshift-ci-tests.sh diff --git a/.ibm/images/Dockerfile b/.ibm/images/Dockerfile index 8f6a26023..a47110ce9 100644 --- a/.ibm/images/Dockerfile +++ b/.ibm/images/Dockerfile @@ -1,31 +1,24 @@ -FROM cypress/browsers:node16.16.0-chrome107-ff107-edge +FROM mcr.microsoft.com/playwright:v1.40.0-jammy ENV CI=1 \ QT_X11_NO_MITSHM=1 \ _X11_NO_MITSHM=1 \ _MITSHM=0 \ - CYPRESS_CACHE_FOLDER=/root/.cache/Cypress \ NODE_PATH=/usr/local/lib/node_modules +# Define Helm and OpenShift CLI (oc) versions +ENV HELM_VERSION="v3.12.3" +ENV OC_VERSION="4.14.3" + ARG CI_XBUILD # should be root user RUN echo "whoami: $(whoami)" \ - && npm config -g set user $(whoami) \ # command "id" should print: # uid=0(root) gid=0(root) groups=0(root) # which means the current user is root && id \ && npm install -g typescript \ - && npm install -g "cypress@12.3.0" \ - && (node -p "process.env.CI_XBUILD && process.arch === 'arm64' ? 'Skipping cypress verify on arm64 due to SIGSEGV.' : process.exit(1)" \ - || (cypress verify \ - # Cypress cache and installed version - # should be in the root user's home folder - && cypress cache path \ - && cypress cache list \ - && cypress info \ - && cypress version)) \ # give every user read access to the "/root" folder where the binary is cached # we really only need to worry about the top folder, fortunately && ls -la /root \ @@ -35,28 +28,20 @@ RUN echo "whoami: $(whoami)" \ # NPM does not need to be installed as it is already included with Node. && npm i -g yarn@latest \ # Show where Node loads required modules from - && node -p 'module.paths' \ - # should print Cypress version + && node -p 'module.paths' # plus Electron and bundled Node versions - && cypress version \ - && echo " node version: $(node -v) \n" \ + +RUN echo " node version: $(node -v) \n" \ "npm version: $(npm -v) \n" \ "yarn version: $(yarn -v) \n" \ "typescript version: $(tsc -v) \n" \ "debian version: $(cat /etc/debian_version) \n" \ - "user: $(whoami) \n" \ - "chrome: $(google-chrome --version || true) \n" \ - "firefox: $(firefox --version || true) \n" + "user: $(whoami) \n" RUN curl -fsSL https://clis.cloud.ibm.com/install/linux | sh && \ - 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 && \ 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/ && \ - 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.11 && \ apt-get update -y && \ apt-get install -y sshpass jq colorized-logs && \ rm -rf /var/lib/apt/lists/* @@ -75,6 +60,17 @@ RUN apt-get update && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* +# Install Helm +RUN curl -fsSL -o /tmp/helm.tar.gz "https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz" \ + && tar -xzvf /tmp/helm.tar.gz -C /tmp \ + && mv /tmp/linux-amd64/helm /usr/local/bin/helm \ + && rm -rf /tmp/* + +# Install OpenShift CLI (oc) +RUN curl -fsSL -o /tmp/openshift-client-linux.tar.gz "https://mirror.openshift.com/pub/openshift-v4/clients/ocp/${OC_VERSION}/openshift-client-linux-${OC_VERSION}.tar.gz" \ + && tar -xzvf /tmp/openshift-client-linux.tar.gz -C /usr/local/bin oc kubectl \ + && rm -rf /tmp/* + # Set environment variables to make Go work correctly ENV GOPATH /go ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH @@ -83,4 +79,4 @@ RUN go install github.com/kadel/pr-commenter@latest && \ ibmcloud plugin install -f cloud-object-storage && \ ibmcloud plugin install -f kubernetes-service -ENTRYPOINT ["cypress", "run"] +WORKDIR /tmp/ \ No newline at end of file diff --git a/.ibm/pipelines/openshift-ci-tests.sh b/.ibm/pipelines/openshift-ci-tests.sh new file mode 100755 index 000000000..a9025db85 --- /dev/null +++ b/.ibm/pipelines/openshift-ci-tests.sh @@ -0,0 +1,6 @@ +#!/bin/sh +# fail if some commands fails +set -e +# show commands +set -x +echo "Place holder to run openshift-ci-tests" \ No newline at end of file