From 4fb5941c56ed9e68050bbac848da0a2c4c8070f1 Mon Sep 17 00:00:00 2001 From: Rainer Killinger Date: Tue, 22 Aug 2023 13:27:29 +0200 Subject: [PATCH] ci: prepare e2e jobs for non nonexistent cache --- .gitlab/schedules.gitlab-ci.yml | 4 +- frontend/app/.gitlab-ci.yml | 4 +- images/app-cypress/Dockerfile | 103 ++++++++++++++++++++++++++++++++ images/app-cypress/package.json | 14 +++++ 4 files changed, 121 insertions(+), 4 deletions(-) create mode 100644 images/app-cypress/Dockerfile create mode 100644 images/app-cypress/package.json diff --git a/.gitlab/schedules.gitlab-ci.yml b/.gitlab/schedules.gitlab-ci.yml index 669c5c5a..66b869e0 100644 --- a/.gitlab/schedules.gitlab-ci.yml +++ b/.gitlab/schedules.gitlab-ci.yml @@ -18,7 +18,7 @@ base image: docker build -t "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:$(grep -o '"version": "[^"]*' "${DEPLOY_DIR}/package.json" | cut -d'"' -f4)" -t "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:latest" "${CI_PROJECT_DIR}/${DEPLOY_DIR}" && - docker push "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}" + docker push "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}" --all-tags cache: {} # disable irrelevant cache for this job before_script: [] # do not run irrelevant before script for this job parallel: @@ -29,5 +29,7 @@ base image: DEPLOY_DIR: images/node-builder - IMAGE_NAME: app-builder DEPLOY_DIR: images/app-builder + - IMAGE_NAME: app-cypress + DEPLOY_DIR: images/app-cypress rules: - !reference [.limit_scheduled_pipelines, rules] \ No newline at end of file diff --git a/frontend/app/.gitlab-ci.yml b/frontend/app/.gitlab-ci.yml index cae2485a..d35e8f7e 100644 --- a/frontend/app/.gitlab-ci.yml +++ b/frontend/app/.gitlab-ci.yml @@ -1,9 +1,7 @@ e2e: - image: cypress/browsers:latest # https://hub.docker.com/r/cypress/browsers/tags/ + image: registry.gitlab.com/openstapps/openstapps/app-cypress:node-18 stage: test script: - - apt-get update && apt-get install -y musl-dev - - ln -s /usr/lib/x86_64-linux-musl/libc.so /lib/libc.musl-x86_64.so.1 - pnpm --filter=@openstapps/app install - pnpm --filter=@openstapps/app exec cypress install - cd node_modules/.pnpm/re2*/node_modules/re2 diff --git a/images/app-cypress/Dockerfile b/images/app-cypress/Dockerfile new file mode 100644 index 00000000..6646ad28 --- /dev/null +++ b/images/app-cypress/Dockerfile @@ -0,0 +1,103 @@ +### Set base image +FROM cypress/base:18.16.1 + +USER root + +RUN node --version + +# Install dependencies +RUN apt-get update && \ + apt-get install -y \ + fonts-liberation \ + git \ + libcurl4 \ + libcurl3-gnutls \ + libcurl3-nss \ + xdg-utils \ + wget \ + curl \ + # firefox dependencies + bzip2 \ + firefox-esr \ + # add codecs needed for video playback in firefox + # https://github.com/cypress-io/cypress-docker-images/issues/150 + mplayer \ + # edge dependencies + gnupg \ + dirmngr \ + # ci dependencies + build-essential \ + jq \ + musl-dev \ + # clean up + && rm -rf /var/lib/apt/lists/* \ + && apt-get clean + +#funky alpine linux compatibility +RUN ln -s /usr/lib/x86_64-linux-musl/libc.so /lib/libc.musl-x86_64.so.1 + +# install libappindicator3-1 - not included with Debian 11 +RUN wget --no-verbose -O /usr/src/libappindicator3-1_0.4.92-7_amd64.deb "http://ftp.us.debian.org/debian/pool/main/liba/libappindicator/libappindicator3-1_0.4.92-7_amd64.deb" && \ + dpkg -i /usr/src/libappindicator3-1_0.4.92-7_amd64.deb ; \ + apt update && \ + apt --fix-broken install -y && \ + rm -rf /var/lib/apt/lists/* && \ + apt-get clean && \ + rm -f /usr/src/libappindicator3-1_0.4.92-7_amd64.deb + +# install Chrome browser +RUN export CHROME_VERSION=$(curl -fsSL https://versionhistory.googleapis.com/v1/chrome/platforms/linux/channels/stable/versions | jq -r '.versions[0].version') && \ + wget --no-verbose -O /usr/src/google-chrome-stable_current_amd64.deb "http://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_${CHROME_VERSION}-1_amd64.deb" && \ + dpkg -i /usr/src/google-chrome-stable_current_amd64.deb ; \ + apt update && \ + apt --fix-broken install -y && \ + rm -rf /var/lib/apt/lists/* && \ + apt-get clean && \ + rm -f /usr/src/google-chrome-stable_current_amd64.deb + +# "fake" dbus address to prevent errors +# https://github.com/SeleniumHQ/docker-selenium/issues/87 +ENV DBUS_SESSION_BUS_ADDRESS=/dev/null + +# install Firefox browser +RUN export FIREFOX_VERSION=$(curl -fsSL https://product-details.mozilla.org/1.0/firefox_versions.json | jq -r '.LATEST_FIREFOX_VERSION') && \ + wget --no-verbose -O /tmp/firefox.tar.bz2 "https://download-installer.cdn.mozilla.net/pub/firefox/releases/${FIREFOX_VERSION}/linux-x86_64/en-US/firefox-${FIREFOX_VERSION}.tar.bz2" && \ + tar -C /opt -xjf /tmp/firefox.tar.bz2 && \ + rm /tmp/firefox.tar.bz2 && \ + ln -fs /opt/firefox/firefox /usr/bin/firefox + +RUN echo "Downloading Latest Edge version..." + +## Setup Edge +RUN curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg +RUN install -o root -g root -m 644 microsoft.gpg /etc/apt/trusted.gpg.d/ +RUN sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/edge stable main" > /etc/apt/sources.list.d/microsoft-edge-dev.list' +RUN rm microsoft.gpg + +## Install Edge +RUN apt-get update && \ + apt-get install -y microsoft-edge-dev \ + && rm -rf /var/lib/apt/lists/* \ + && apt-get clean + +# Add a link to the browser that allows Cypress to find it +RUN ln -s /usr/bin/microsoft-edge /usr/bin/edge + +# versions of local tools +RUN echo " node version: $(node -v) \n" \ + "npm version: $(npm -v) \n" \ + "yarn version: $(yarn -v) \n" \ + "debian version: $(cat /etc/debian_version) \n" \ + "Chrome version: $(google-chrome --version) \n" \ + "Firefox version: $(firefox --version) \n" \ + "Edge version: $(edge --version) \n" \ + "git version: $(git --version) \n" \ + "whoami: $(whoami) \n" + +# a few environment variables to make NPM installs easier +# good colors for most applications +ENV TERM=xterm +# avoid million NPM install messages +ENV npm_config_loglevel=warn +# allow installing when the main user is root +ENV npm_config_unsafe_perm=true diff --git a/images/app-cypress/package.json b/images/app-cypress/package.json new file mode 100644 index 00000000..2fe83fc2 --- /dev/null +++ b/images/app-cypress/package.json @@ -0,0 +1,14 @@ +{ + "name": "@openstapps/app-cypress", + "version": "node-18", + "private": true, + "type": "module", + "license": "GPL-3.0-only", + "author": "Rainer Killinger ", + "contributors": [ + ], + "files": [ + "Dockerfile", + "CHANGELOG.md" + ] +}