From da61df0a2aefaf60ba49de204ead8d3bcc404cba Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 4 Oct 2024 12:08:47 +0200 Subject: [PATCH] feat: refs #6695 jenkins run e2e --- Jenkinsfile | 22 +++++++++++++----- cypress.config.js | 4 ++-- dind.sh | 12 ++++++++++ docker-compose.e2e.yml | 30 +++++++++++++----------- e2e.sh | 11 +++++++++ test/cypress/db/Dockerfile | 39 ++++++++------------------------ test/cypress/support/commands.js | 2 +- 7 files changed, 69 insertions(+), 51 deletions(-) create mode 100644 dind.sh create mode 100644 e2e.sh diff --git a/Jenkinsfile b/Jenkinsfile index 516574519..bd9fb2bd1 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -92,12 +92,22 @@ pipeline { IMAGE = "$REGISTRY/salix-back" } steps { - sh 'docker pull $IMAGE:dev' - sh 'docker ps -a' - sh 'docker network create salix_default' - sh 'docker-compose -f docker-compose.yml build db' - sh 'docker-compose -f docker-compose.yml up db' - sh 'docker run --name back $IMAGE:dev' + // // sh 'docker pull $IMAGE:dev' + // sh 'git clone https://gitea.verdnatura.es/verdnatura/salix.git' + // // sh 'docker ps -a' + // sh 'docker network create salix_default' + // sh 'docker-compose -f docker-compose.yml build db' + // sh 'docker-compose -f docker-compose.yml up db' + // sh 'docker run --name back $IMAGE:dev' + sh 'git clone --branch dev https://gitea.verdnatura.es/verdnatura/salix.git' + sh 'cd front' + // sh '# export VERSION=e2e-try' + sh 'docker buildx build -f salix/back/Dockerfile -t back ./salix' + sh 'docker-compose -f docker-compose.e2e.yml up db' + sh 'docker run --net=host -v ./test/cypress/storage:/salix/storage -d back' + sh 'docker-compose -f docker-compose.e2e.yml -d up front' + sh 'docker-compose -f docker-compose.e2e.yml up e2e --build' + } post { always { diff --git a/cypress.config.js b/cypress.config.js index 42ceceac1..08c361029 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -2,14 +2,14 @@ const { defineConfig } = require('cypress'); module.exports = defineConfig({ e2e: { - baseUrl: 'http://front:9000/', + baseUrl: 'http://localhost:9000/', experimentalStudio: true, fixturesFolder: 'test/cypress/fixtures', screenshotsFolder: 'test/cypress/screenshots', supportFile: 'test/cypress/support/index.js', videosFolder: 'test/cypress/videos', video: false, - specPattern: 'test/cypress/integration/**/*.spec.js', + specPattern: 'test/cypress/integration/claim/*.spec.js', experimentalRunAllSpecs: true, component: { componentFolder: 'src', diff --git a/dind.sh b/dind.sh new file mode 100644 index 000000000..7d9ae525f --- /dev/null +++ b/dind.sh @@ -0,0 +1,12 @@ +docker stop dind-container || true && docker rm dind-container || true +docker run --privileged -d \ + -p 2376:2376 \ + -e DOCKER_TLS_CERTDIR="" \ + --name dind-container \ + -v /home/alexm/Projects/salix-front:/front \ + docker:dind \ + dockerd -H tcp://0.0.0.0:2376 -H unix:///var/run/docker.sock + +docker exec -it dind-container sh + + diff --git a/docker-compose.e2e.yml b/docker-compose.e2e.yml index 31c48033c..3f38a8c10 100644 --- a/docker-compose.e2e.yml +++ b/docker-compose.e2e.yml @@ -6,33 +6,37 @@ services: dockerfile: ./Dockerfile.e2e ports: - 9000:9000 - back: - image: registry.verdnatura.es/salix-back:${VERSION:?} - build: - context: . - dockerfile: back/Dockerfile - depends_on: - - db - ports: - - 3000:3000 - - 5000:5000 - volumes: - - ./test/cypress/storage:/salix/storage + network_mode: host db: image: db - command: npx myt run -t --ci -n salix-front_default + command: npx myt run -t -d build: context: . dockerfile: test/cypress/db/Dockerfile target: db volumes: - /var/run/docker.sock:/var/run/docker.sock + network_mode: host e2e: image: registry.verdnatura.es/salix-frontend:${VERSION:?} command: npx cypress run build: context: . dockerfile: ./Dockerfile.e2e + network_mode: host + # back: + # image: back + # build: + # context: ./salix + # dockerfile: salix/back/Dockerfile + # # depends_on: + # # - db + # ports: + # - 3000:3000 + # - 5000:5000 + # volumes: + # - ./test/cypress/storage:/salix/storage + # e2e-2: # image: registry.verdnatura.es/salix-frontend:${VERSION:?} # command: npx cypress run --config-file test/cypress/configs/cypress.config.2.js diff --git a/e2e.sh b/e2e.sh new file mode 100644 index 000000000..1ca5fcf38 --- /dev/null +++ b/e2e.sh @@ -0,0 +1,11 @@ +git clone --branch dev https://gitea.verdnatura.es/verdnatura/salix.git +cd front +# export VERSION=e2e-try +docker buildx build -f salix/back/Dockerfile -t back ./salix +docker-compose -f docker-compose.e2e.yml up db +docker run --net=host -v ./test/cypress/storage:/salix/storage -d back +docker-compose -f docker-compose.e2e.yml -d up front +docker-compose -f docker-compose.e2e.yml up e2e --build + + + diff --git a/test/cypress/db/Dockerfile b/test/cypress/db/Dockerfile index 634c8cfe3..67d299b8e 100644 --- a/test/cypress/db/Dockerfile +++ b/test/cypress/db/Dockerfile @@ -1,37 +1,18 @@ -FROM registry.verdnatura.es/salix-back:e2e-try AS back -FROM docker:dind AS base - -ENV TZ Europe/Madrid -ARG DEBIAN_FRONTEND=noninteractive - -RUN apk update \ - && apk add --update nodejs npm python3 \ - krb5-dev libressl-dev - -RUN apk update \ - && apk add --virtual build-dependencies \ - build-base gcc wget git - - +FROM node:lts-bookworm +ENV SHELL bash +ENV PNPM_HOME="/pnpm" +ENV PATH="$PNPM_HOME:$PATH" +RUN npm install -g pnpm@8.15.1 +RUN pnpm setup +RUN apt install libkrb5-dev libssl-dev RUN npm i -g pnpm WORKDIR /salix -# COPY --from=back /.git /test/cypress/.git -# COPY --from=back myt.config.yml /test/cypress -# COPY db db -# COPY node_modules node_modules -# COPY .git .git -# COPY myt.config.yml . - -COPY --from=back salix/db db -COPY --from=back salix/myt.config.yml . -COPY --from=back salix/.git .git +COPY salix/db db +COPY salix/myt.config.yml . +COPY salix/.git .git COPY node_modules node_modules # RUN pnpm i @verdnatura/myt USAR NODE_MODULES HASTA QUE ESTE LA RAMA DE MYT FUSIONADA (MIENTRAS INSTALAR EN LILIUM, MYT Y MODIFICAR EL CODIGO DE myt-run.js) - -FROM base AS db - -WORKDIR /salix diff --git a/test/cypress/support/commands.js b/test/cypress/support/commands.js index 83f45b721..285520913 100755 --- a/test/cypress/support/commands.js +++ b/test/cypress/support/commands.js @@ -83,7 +83,7 @@ Cypress.Commands.add('getValue', (selector) => { Cypress.Commands.add('selectOption', (selector, option) => { cy.waitForElement(selector); cy.get(selector).find('.q-select__dropdown-icon').click(); - cy.get('.q-menu .q-item').contains(option).click(); + cy.get('.q-menu .q-item').contains(option).should('be.visible').click(); }); Cypress.Commands.add('fillInForm', (obj, form = '.q-form > .q-card') => {