From d6d017de1409f7319684f1c98d2c017d35631e83 Mon Sep 17 00:00:00 2001 From: valentinab25 Date: Mon, 31 Jul 2023 07:33:10 +0300 Subject: [PATCH 01/21] docs: Cleanup Makefile, update DEVELOP documentation, i18n - refs #254894 --- .i18n.babel.config.js | 1 - DEVELOP.md | 56 +++++++++++++++ Dockerfile | 14 ++++ Jenkinsfile | 25 +++++++ Makefile | 156 +++++++++++++++++++++++++----------------- README.md | 40 +++++++---- docker-compose.yml | 28 ++++++++ 7 files changed, 243 insertions(+), 77 deletions(-) delete mode 100644 .i18n.babel.config.js create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.i18n.babel.config.js b/.i18n.babel.config.js deleted file mode 100644 index a900a755..00000000 --- a/.i18n.babel.config.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('@plone/volto/babel'); diff --git a/DEVELOP.md b/DEVELOP.md index 173a2d5f..62e46ff9 100644 --- a/DEVELOP.md +++ b/DEVELOP.md @@ -2,6 +2,28 @@ ## Develop +1. Make sure you have `docker` and `docker compose` installed and running on your machine: + + ```Bash + git clone https://github.com/eea/volto-n2k.git + cd volto-n2k + git checkout -b bugfix-123456 develop + make + make start + ``` + +1. Wait for `Volto started at 0.0.0.0:3000` meesage + +1. Go to http://localhost:3000 + +1. Happy hacking! + + ```Bash + cd src/addons/volto-n2k/ + ``` + +### Or add @eeacms/volto-n2k to your Volto project + Before starting make sure your development environment is properly set. See [Volto Developer Documentation](https://docs.voltocms.com/getting-started/install/) 1. Make sure you have installed `yo`, `@plone/generator-volto` and `mrs-developer` @@ -51,3 +73,37 @@ Before starting make sure your development environment is properly set. See [Vol 1. Happy hacking! $ cd src/addons/volto-n2k/ + +## Cypress + +To run cypress locally, first make sure you don't have any Volto/Plone running on ports `8080` and `3000`. + +You don't have to be in a `clean-volto-project`, you can be in any Volto Frontend +project where you added `volto-n2k` to `mrs.developer.json` + +Go to: + + ```BASH + cd src/addons/volto-n2k/ + ``` + +Start: + + ```Bash + make + make start + ``` + +This will build and start with Docker a clean `Plone backend` and `Volto Frontend` with `volto-n2k` block installed. + +Open Cypress Interface: + + ```Bash + make cypress-open + ``` + +Or run it: + + ```Bash + make cypress-run + ``` diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..bd8e10dc --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +# syntax=docker/dockerfile:1 +ARG VOLTO_VERSION +FROM plone/frontend-builder:${VOLTO_VERSION} + +ARG ADDON_NAME +ARG ADDON_PATH + +COPY --chown=node:node ./ /app/src/addons/${ADDON_PATH}/ + +RUN /setupAddon +RUN yarn install + +ENTRYPOINT ["yarn"] +CMD ["start"] diff --git a/Jenkinsfile b/Jenkinsfile index affa31e7..c1608991 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -197,6 +197,31 @@ pipeline { } } + stage('SonarQube compare to master') { + when { + allOf { + environment name: 'CHANGE_ID', value: '' + branch 'develop' + not { changelog '.*^Automated release [0-9\\.]+$' } + } + } + steps { + node(label: 'docker') { + script { + sh '''docker pull eeacms/gitflow''' + sh '''echo "Error" > checkresult.txt''' + catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { + sh '''set -o pipefail; docker run -i --rm --name="$BUILD_TAG-gitflow-sn" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_NAME="$GIT_NAME" eeacms/gitflow /checkSonarqubemaster.sh | grep -v "Found script" | tee checkresult.txt''' + } + + publishChecks name: 'SonarQube', title: 'Sonarqube Code Quality Check', summary: "Quality check on the SonarQube metrics from branch develop, comparing it with the ones from master branch. No bugs are allowed", + text: readFile(file: 'checkresult.txt'), conclusion: "${currentBuild.currentResult}", + detailsURL: "${env.BUILD_URL}display/redirect" + } + } + } + } + stage('Pull Request') { when { not { diff --git a/Makefile b/Makefile index fa4f6eac..13481d35 100644 --- a/Makefile +++ b/Makefile @@ -1,62 +1,93 @@ -SHELL=/bin/bash +############################################################################## +# Run: +# make +# make start +# +# Go to: +# +# http://localhost:3000 +# +# Cypress: +# +# make cypress-open +# +############################################################################## +# SETUP MAKE +# +## Defensive settings for make: https://tech.davis-hansson.com/p/make/ +SHELL:=bash +.ONESHELL: +# for Makefile debugging purposes add -x to the .SHELLFLAGS +.SHELLFLAGS:=-eu -o pipefail -O inherit_errexit -c +.SILENT: +.DELETE_ON_ERROR: +MAKEFLAGS+=--warn-undefined-variables +MAKEFLAGS+=--no-builtin-rules + +# Colors +# OK=Green, warn=yellow, error=red +ifeq ($(TERM),) +# no colors if not in terminal + MARK_COLOR= + OK_COLOR= + WARN_COLOR= + ERROR_COLOR= + NO_COLOR= +else + MARK_COLOR=`tput setaf 6` + OK_COLOR=`tput setaf 2` + WARN_COLOR=`tput setaf 3` + ERROR_COLOR=`tput setaf 1` + NO_COLOR=`tput sgr0` +endif +############################################################################## +# SETTINGS AND VARIABLE DIR=$(shell basename $$(pwd)) -ADDON ?= "@eeacms/volto-n2k" - -# We like colors -# From: https://coderwall.com/p/izxssa/colored-makefile-for-golang-projects -RED=`tput setaf 1` -GREEN=`tput setaf 2` -RESET=`tput sgr0` -YELLOW=`tput setaf 3` - -project: - npm install -g yo - npm install -g @plone/generator-volto - npm install -g mrs-developer - yo @plone/volto project --addon ${ADDON} --workspace "src/addons/${DIR}" --no-interactive - ln -sf $$(pwd) project/src/addons/ - cp .project.eslintrc.js .eslintrc.js - cd project && yarn - @echo "-------------------" - @echo "$(GREEN)Volto project is ready!$(RESET)" - @echo "$(RED)Now run: cd project && yarn start$(RESET)" - -all: project - -.PHONY: start-test-backend -start-test-backend: ## Start Test Plone Backend - @echo "$(GREEN)==> Start Test Plone Backend$(RESET)" - docker run -i --rm -e ZSERVER_HOST=0.0.0.0 -e ZSERVER_PORT=55001 -p 55001:55001 -e SITE=plone -e APPLY_PROFILES=plone.app.contenttypes:plone-content,plone.restapi:default,kitconcept.volto:default-homepage -e CONFIGURE_PACKAGES=plone.app.contenttypes,plone.restapi,kitconcept.volto,kitconcept.volto.cors -e ADDONS='plone.app.robotframework plone.app.contenttypes plone.restapi kitconcept.volto' plone ./bin/robot-server plone.app.robotframework.testing.PLONE_ROBOT_TESTING - -.PHONY: start-backend-docker -start-backend-docker: ## Starts a Docker-based backend - @echo "$(GREEN)==> Start Docker-based Plone Backend$(RESET)" - docker run -it --rm --name=plone -p 8080:8080 -e SITE=Plone -e ADDONS="kitconcept.volto" -e ZCML="kitconcept.volto.cors" plone +NODE_MODULES?="../../../node_modules" +PLONE_VERSION?=6 +VOLTO_VERSION?=16 +ADDON_PATH="${DIR}" +ADDON_NAME="@eeacms/${ADDON_PATH}" +DOCKER_COMPOSE=PLONE_VERSION=${PLONE_VERSION} VOLTO_VERSION=${VOLTO_VERSION} ADDON_NAME=${ADDON_NAME} ADDON_PATH=${ADDON_PATH} docker compose + +# Top-level targets +.PHONY: all +all: clean install + +.PHONY: clean +clean: ## Cleanup development environment + ${DOCKER_COMPOSE} down --volumes --remove-orphans + +.PHONY: install +install: ## Build and install development environment + echo "Running: ${DOCKER_COMPOSE} build" + ${DOCKER_COMPOSE} pull + ${DOCKER_COMPOSE} build + +.PHONY: start +start: ## Start development environment + echo "Running: ${DOCKER_COMPOSE} up" + ${DOCKER_COMPOSE} up -.PHONY: test -test: - docker pull plone/volto-addon-ci:alpha - docker run -it --rm -e NAMESPACE="@eeacms" -e GIT_NAME="${DIR}" -e RAZZLE_JEST_CONFIG=jest-addon.config.js -v "$$(pwd):/opt/frontend/my-volto-project/src/addons/${DIR}" -e CI="true" plone/volto-addon-ci:alpha - -.PHONY: test-update -test-update: - docker pull plone/volto-addon-ci:alpha - docker run -it --rm -e NAMESPACE="@eeacms" -e GIT_NAME="${DIR}" -e RAZZLE_JEST_CONFIG=jest-addon.config.js -v "$$(pwd):/opt/frontend/my-volto-project/src/addons/${DIR}" -e CI="true" plone/volto-addon-ci:alpha yarn test src/addons/${DIR}/src --watchAll=false -u +.PHONY: cypress-open +cypress-open: ## Open cypress integration tests + NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress open -.PHONY: help -help: ## Show this help. - @echo -e "$$(grep -hE '^\S+:.*##' $(MAKEFILE_LIST) | sed -e 's/:.*##\s*/:/' -e 's/^\(.\+\):\(.*\)/\\x1b[36m\1\\x1b[m:\2/' | column -c2 -t -s :)" +.PHONY: cypress-run +cypress-run: ## Run cypress integration tests + NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress run +.PHONY: test +test: ## Run jest tests + ${DOCKER_COMPOSE} run -e CI=1 frontend test -ifeq ($(wildcard ./project),) - NODE_MODULES = "../../../node_modules" -else - NODE_MODULES = "./project/node_modules" -endif +.PHONY: test-update +test-update: ## Update jest tests snapshots + ${DOCKER_COMPOSE} run -e CI=1 frontend test -u .PHONY: stylelint -stylelint: +stylelint: ## Stylelint $(NODE_MODULES)/stylelint/bin/stylelint.js --allow-empty-input 'src/**/*.{css,less}' .PHONY: stylelint-overrides @@ -64,35 +95,32 @@ stylelint-overrides: $(NODE_MODULES)/.bin/stylelint --syntax less --allow-empty-input 'theme/**/*.overrides' 'src/**/*.overrides' .PHONY: stylelint-fix -stylelint-fix: +stylelint-fix: ## Fix stylelint $(NODE_MODULES)/stylelint/bin/stylelint.js --allow-empty-input 'src/**/*.{css,less}' --fix $(NODE_MODULES)/.bin/stylelint --syntax less --allow-empty-input 'theme/**/*.overrides' 'src/**/*.overrides' --fix .PHONY: prettier -prettier: +prettier: ## Prettier $(NODE_MODULES)/.bin/prettier --single-quote --check 'src/**/*.{js,jsx,json,css,less,md}' .PHONY: prettier-fix -prettier-fix: +prettier-fix: ## Fix prettier $(NODE_MODULES)/.bin/prettier --single-quote --write 'src/**/*.{js,jsx,json,css,less,md}' .PHONY: lint -lint: +lint: ## ES Lint $(NODE_MODULES)/eslint/bin/eslint.js --max-warnings=0 'src/**/*.{js,jsx}' .PHONY: lint-fix -lint-fix: +lint-fix: ## Fix ES Lint $(NODE_MODULES)/eslint/bin/eslint.js --fix 'src/**/*.{js,jsx}' .PHONY: i18n -i18n: +i18n: ## i18n rm -rf build/messages NODE_ENV=development $(NODE_MODULES)/.bin/i18n --addon -.PHONY: cypress-run -cypress-run: - NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress run - -.PHONY: cypress-open -cypress-open: - NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress open +.PHONY: help +help: ## Show this help. + @echo -e "$$(grep -hE '^\S+:.*##' $(MAKEFILE_LIST) | sed -e 's/:.*##\s*/:/' -e 's/^\(.\+\):\(.*\)/\\x1b[36m\1\\x1b[m:\2/' | column -c2 -t -s :)" + head -n 14 Makefile diff --git a/README.md b/README.md index 9780dc9b..bb87a924 100644 --- a/README.md +++ b/README.md @@ -14,27 +14,35 @@ [![Bugs](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=volto-n2k-develop&metric=bugs)](https://sonarqube.eea.europa.eu/dashboard?id=volto-n2k-develop) [![Duplicated Lines (%)](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=volto-n2k-develop&metric=duplicated_lines_density)](https://sonarqube.eea.europa.eu/dashboard?id=volto-n2k-develop) + [Volto](https://github.com/plone/volto) add-on ## Features -### - Demo GIF ## Getting started -1. Create new volto project if you don't already have one: +### Try volto-n2k with Docker - ``` - $ npm install -g yo @plone/generator-volto - $ yo @plone/volto my-volto-project --addon @eeacms/volto-n2k + git clone https://github.com/eea/volto-n2k.git + cd volto-n2k + make + make start + +Go to http://localhost:3000 + +### Add volto-n2k to your Volto project + +1. Make sure you have a [Plone backend](https://plone.org/download) up-and-running at http://localhost:8080/Plone - $ cd my-volto-project - $ yarn add -W @eeacms/volto-n2k + ```Bash + docker compose up backend ``` -1. If you already have a volto project, just update `package.json`: +1. Start Volto frontend + +* If you already have a volto project, just update `package.json`: ```JSON "addons": [ @@ -42,15 +50,23 @@ Demo GIF ], "dependencies": { - "@eeacms/volto-n2k": "^1.0.0" + "@eeacms/volto-n2k": "*" } ``` +* If not, create one: + + ``` + npm install -g yo @plone/generator-volto + yo @plone/volto my-volto-project --canary --addon @eeacms/volto-n2k + cd my-volto-project + ``` + 1. Install new add-ons and restart Volto: ``` - $ yarn - $ yarn start + yarn + yarn start ``` 1. Go to http://localhost:3000 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..c6f48624 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,28 @@ +version: "3" +services: + backend: + image: plone/plone-backend:${PLONE_VERSION:-6} + ports: + - "8080:8080" + environment: + SITE: "Plone" + + frontend: + build: + context: ./ + dockerfile: ./Dockerfile + args: + ADDON_NAME: "${ADDON_NAME}" + ADDON_PATH: "${ADDON_PATH}" + VOLTO_VERSION: ${VOLTO_VERSION:-16} + ports: + - "3000:3000" + - "3001:3001" + depends_on: + - backend + volumes: + - ./:/app/src/addons/${ADDON_PATH} + environment: + RAZZLE_INTERNAL_API_PATH: "http://backend:8080/Plone" + RAZZLE_DEV_PROXY_API_PATH: "http://backend:8080/Plone" + HOST: "0.0.0.0" From 2c9185688a2fe6b36e5eeb2963f6c8676e3c5628 Mon Sep 17 00:00:00 2001 From: valentinab25 Date: Wed, 23 Aug 2023 00:11:27 +0300 Subject: [PATCH 02/21] test: Update Makefile and docker-compose to align it with Jenkinsfile --- Makefile | 5 +++++ docker-compose.yml | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 13481d35..4a5cbedd 100644 --- a/Makefile +++ b/Makefile @@ -70,6 +70,11 @@ start: ## Start development environment echo "Running: ${DOCKER_COMPOSE} up" ${DOCKER_COMPOSE} up +.PHONY: shell +shell: ## Start a shell in the frontend container + echo "Running: ${DOCKER_COMPOSE} run frontend bash" + ${DOCKER_COMPOSE} run --entrypoint=bash frontend + .PHONY: cypress-open cypress-open: ## Open cypress integration tests NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress open diff --git a/docker-compose.yml b/docker-compose.yml index c6f48624..5d79f5cd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,11 +1,12 @@ version: "3" services: backend: - image: plone/plone-backend:${PLONE_VERSION:-6} + image: eeacms/plone-backend ports: - "8080:8080" environment: SITE: "Plone" + PROFILES: "eea.kitkat:testing" frontend: build: @@ -23,6 +24,9 @@ services: volumes: - ./:/app/src/addons/${ADDON_PATH} environment: + CI: "true" + NODE_ENV: "development" + RAZZLE_JEST_CONFIG: "src/addons/${ADDON_PATH}/jest-addon.config.js" RAZZLE_INTERNAL_API_PATH: "http://backend:8080/Plone" RAZZLE_DEV_PROXY_API_PATH: "http://backend:8080/Plone" HOST: "0.0.0.0" From 4850d6a65349fe49dbe9244c30592ae38c9aeaba Mon Sep 17 00:00:00 2001 From: valentinab25 Date: Wed, 6 Sep 2023 01:12:38 +0300 Subject: [PATCH 03/21] test: EN locales, pre-commit fix, feature PRs checks Refs #257193 --- .husky/pre-commit | 2 ++ Jenkinsfile | 74 +++++++++++++++++++++++++++++++---------------- cypress.config.js | 4 +-- package.json | 28 ++++++++++++++++-- 4 files changed, 79 insertions(+), 29 deletions(-) create mode 100755 .husky/pre-commit diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 00000000..9183f9d3 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,2 @@ +[ -n "$CI" ] && exit 0 +yarn lint-staged diff --git a/Jenkinsfile b/Jenkinsfile index c1608991..d9b286fe 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -62,11 +62,17 @@ pipeline { stage('Tests') { when { - allOf { - environment name: 'CHANGE_ID', value: '' - anyOf { - not { changelog '.*^Automated release [0-9\\.]+$' } - branch 'master' + anyOf { + allOf { + not { environment name: 'CHANGE_ID', value: '' } + environment name: 'CHANGE_TARGET', value: 'develop' + } + allOf { + environment name: 'CHANGE_ID', value: '' + anyOf { + not { changelog '.*^Automated release [0-9\\.]+$' } + branch 'master' + } } } } @@ -109,15 +115,21 @@ pipeline { } // stage('Integration tests') { - // when { - // allOf { - // environment name: 'CHANGE_ID', value: '' - // anyOf { - // not { changelog '.*^Automated release [0-9\\.]+$' } - // branch 'master' - // } - // } - // } + when { + anyOf { + allOf { + not { environment name: 'CHANGE_ID', value: '' } + environment name: 'CHANGE_TARGET', value: 'develop' + } + allOf { + environment name: 'CHANGE_ID', value: '' + anyOf { + not { changelog '.*^Automated release [0-9\\.]+$' } + branch 'master' + } + } + } + } // steps { // parallel( @@ -167,13 +179,19 @@ pipeline { stage('Report to SonarQube') { when { - allOf { - environment name: 'CHANGE_ID', value: '' - anyOf { - branch 'master' - allOf { - branch 'develop' - not { changelog '.*^Automated release [0-9\\.]+$' } + anyOf { + allOf { + not { environment name: 'CHANGE_ID', value: '' } + environment name: 'CHANGE_TARGET', value: 'develop' + } + allOf { + environment name: 'CHANGE_ID', value: '' + anyOf { + allOf { + branch 'develop' + not { changelog '.*^Automated release [0-9\\.]+$' } + } + branch 'master' } } } @@ -199,10 +217,16 @@ pipeline { stage('SonarQube compare to master') { when { - allOf { - environment name: 'CHANGE_ID', value: '' - branch 'develop' - not { changelog '.*^Automated release [0-9\\.]+$' } + anyOf { + allOf { + not { environment name: 'CHANGE_ID', value: '' } + environment name: 'CHANGE_TARGET', value: 'develop' + } + allOf { + environment name: 'CHANGE_ID', value: '' + branch 'develop' + not { changelog '.*^Automated release [0-9\\.]+$' } + } } } steps { diff --git a/cypress.config.js b/cypress.config.js index 30be8ac3..4846ce98 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -2,12 +2,12 @@ const { defineConfig } = require('cypress'); module.exports = defineConfig({ viewportWidth: 1280, - defaultCommandTimeout: 8888, + defaultCommandTimeout: 5000, chromeWebSecurity: false, reporter: 'junit', video: true, retries: { - runMode: 8, + runMode: 1, openMode: 0, }, reporterOptions: { diff --git a/package.json b/package.json index 4eabd238..e554baba 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,30 @@ "@cypress/code-coverage": "^3.10.0", "@plone/scripts": "*", "babel-plugin-transform-class-properties": "^6.24.1", - "md5": "^2.3.0" + "md5": "^2.3.0", + "husky": "*", + "lint-staged": "*" + }, + "lint-staged": { + "src/**/*.{js,jsx,ts,tsx,json}": [ + "make lint-fix", + "make prettier-fix" + ], + "src/**/*.{jsx}": [ + "make i18n" + ], + "theme/**/*.{css,less}": [ + "make stylelint-fix" + ], + "src/**/*.{css,less}": [ + "make stylelint-fix" + ], + "theme/**/*.overrides": [ + "make stylelint-fix" + ], + "src/**/*.overrides": [ + "make stylelint-fix" + ] }, "scripts": { "release": "release-it", @@ -59,6 +82,7 @@ "lint:fix": "make lint-fix", "i18n": "make i18n", "cypress:run": "make cypress-run", - "cypress:open": "make cypress-open" + "cypress:open": "make cypress-open", + "prepare": "husky install" } } From 60d94b61ff8826abc57af9616793a1a247f585b5 Mon Sep 17 00:00:00 2001 From: valentinab25 Date: Tue, 10 Oct 2023 07:13:54 +0300 Subject: [PATCH 04/21] chore:volto 16 in tests, update docs, fix stylelint overrides --- DEVELOP.md | 13 ++++++------- Jenkinsfile | 2 +- Makefile | 4 ++-- RELEASE.md | 28 ++++++++++++++-------------- 4 files changed, 23 insertions(+), 24 deletions(-) diff --git a/DEVELOP.md b/DEVELOP.md index 62e46ff9..fa30e0c9 100644 --- a/DEVELOP.md +++ b/DEVELOP.md @@ -16,12 +16,14 @@ 1. Go to http://localhost:3000 -1. Happy hacking! +1. Initialize git hooks ```Bash - cd src/addons/volto-n2k/ + yarn prepare ``` +1. Happy hacking! + ### Or add @eeacms/volto-n2k to your Volto project Before starting make sure your development environment is properly set. See [Volto Developer Documentation](https://docs.voltocms.com/getting-started/install/) @@ -50,18 +52,15 @@ Before starting make sure your development environment is properly set. See [Vol 1. Install - $ yarn develop + $ make develop $ yarn 1. Start backend - $ docker pull plone - $ docker run -d --name plone -p 8080:8080 -e SITE=Plone -e PROFILES="profile-plone.restapi:blocks" plone + docker run --pull always -it --rm --name plone -p 8080:8080 -e SITE=Plone plone/plone-backend ...wait for backend to setup and start - `Ready to handle requests`: - $ docker logs -f plone - ...you can also check http://localhost:8080/Plone 1. Start frontend diff --git a/Jenkinsfile b/Jenkinsfile index d9b286fe..b9073abb 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,7 +6,7 @@ pipeline { NAMESPACE = "@eeacms" SONARQUBE_TAGS = "volto.eea.europa.eu,biodiversity.europa.eu" DEPENDENCIES = "volto-slate @eeacms/volto-datablocks" - VOLTO = "" + VOLTO = "16" } stages { diff --git a/Makefile b/Makefile index 4a5cbedd..f3614a8d 100644 --- a/Makefile +++ b/Makefile @@ -97,12 +97,12 @@ stylelint: ## Stylelint .PHONY: stylelint-overrides stylelint-overrides: - $(NODE_MODULES)/.bin/stylelint --syntax less --allow-empty-input 'theme/**/*.overrides' 'src/**/*.overrides' + $(NODE_MODULES)/.bin/stylelint --custom-syntax less --allow-empty-input 'theme/**/*.overrides' 'src/**/*.overrides' .PHONY: stylelint-fix stylelint-fix: ## Fix stylelint $(NODE_MODULES)/stylelint/bin/stylelint.js --allow-empty-input 'src/**/*.{css,less}' --fix - $(NODE_MODULES)/.bin/stylelint --syntax less --allow-empty-input 'theme/**/*.overrides' 'src/**/*.overrides' --fix + $(NODE_MODULES)/.bin/stylelint --custom-syntax less --allow-empty-input 'theme/**/*.overrides' 'src/**/*.overrides' --fix .PHONY: prettier prettier: ## Prettier diff --git a/RELEASE.md b/RELEASE.md index 24f98ee5..4e311a0b 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -20,9 +20,9 @@ You need to first install the [release-it](https://github.com/release-it/release ``` npm install -g release-it ``` - + Release-it uses the configuration written in the [`.release-it.json`](./.release-it.json) file located in the root of the repository. - + Release-it is a tool that automates 4 important steps in the release process: 1. Version increase in `package.json` ( increased from the current version in `package.json`) @@ -30,45 +30,45 @@ Release-it is a tool that automates 4 important steps in the release process: 3. GitHub release on the commit with the changelog and package.json modification on the develop branch 4. NPM release ( by default it's disabled, but can be enabled in the configuration file ) -To configure the authentification, you need to export GITHUB_TOKEN for [GitHub](https://github.com/settings/tokens) +To configure the authentification, you need to export GITHUB_TOKEN for [GitHub](https://github.com/settings/tokens) ``` export GITHUB_TOKEN=XXX-XXXXXXXXXXXXXXXXXXXXXX ``` - + To configure npm, you can use the `npm login` command or use a configuration file with a TOKEN : - + ``` echo "//registry.npmjs.org/:_authToken=YYYYYYYYYYYYYYYYYYYYYYYYYYYYYY" > .npmrc ``` #### Using release-it tool - + There are 3 yarn scripts that can be run to do the release ##### yarn release-beta -Automatically calculates and presents 3 beta versions - patch, minor and major for you to choose ( or Other for manual input). +Automatically calculates and presents 3 beta versions - patch, minor and major for you to choose ( or Other for manual input). ``` -? Select increment (next version): -❯ prepatch (0.1.1-beta.0) - preminor (0.2.0-beta.0) - premajor (1.0.0-beta.0) - Other, please specify... +? Select increment (next version): +❯ prepatch (0.1.1-beta.0) + preminor (0.2.0-beta.0) + premajor (1.0.0-beta.0) + Other, please specify... ``` ##### yarn release-major-beta Same as `yarn release-beta`, but with premajor version pre-selected. - + ##### yarn release Generic command, does not automatically add the `beta` to version, but you can still manually write it if you choose Other. #### Important notes -> Do not use release-it tool on master branch, the commit on CHANGELOG.md file and the version increase in the package.json file can't be done without a PULL REQUEST. +> Do not use release-it tool on master branch, the commit on CHANGELOG.md file and the version increase in the package.json file can't be done without a PULL REQUEST. > Do not keep Pull Requests from develop to master branches open when you are doing beta releases from the develop branch. As long as a PR to master is open, an automatic script will run on every commit and will update both the version and the changelog to a production-ready state - ( MAJOR.MINOR.PATCH mandatory format for version). From 647d621d52400c50f5bc629b3ddc4f2121f14ffa Mon Sep 17 00:00:00 2001 From: valentinab25 Date: Tue, 17 Oct 2023 01:04:15 +0300 Subject: [PATCH 05/21] chore: husky, lint-staged use fixed versions --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e554baba..d1b5a46f 100644 --- a/package.json +++ b/package.json @@ -41,8 +41,8 @@ "@plone/scripts": "*", "babel-plugin-transform-class-properties": "^6.24.1", "md5": "^2.3.0", - "husky": "*", - "lint-staged": "*" + "husky": "^8.0.3", + "lint-staged": "^14.0.1" }, "lint-staged": { "src/**/*.{js,jsx,ts,tsx,json}": [ From e4f9fc800b753b97cca7c685bc47dd48804276f0 Mon Sep 17 00:00:00 2001 From: valentinab25 Date: Tue, 31 Oct 2023 03:00:10 +0200 Subject: [PATCH 06/21] chore: [JENKINS] Refactor automated testing --- Dockerfile | 2 +- Jenkinsfile | 310 +++++++++++++++++++++++++++------------------------- Makefile | 37 ++++++- 3 files changed, 200 insertions(+), 149 deletions(-) diff --git a/Dockerfile b/Dockerfile index bd8e10dc..b1ce6036 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1 ARG VOLTO_VERSION -FROM plone/frontend-builder:${VOLTO_VERSION} +FROM eeacms/frontend-builder:${VOLTO_VERSION} ARG ADDON_NAME ARG ADDON_PATH diff --git a/Jenkinsfile b/Jenkinsfile index b9073abb..145e0b81 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,16 +1,20 @@ pipeline { - agent any + agent { + node { label 'docker-host' } + } environment { - GIT_NAME = "volto-n2k" - NAMESPACE = "@eeacms" - SONARQUBE_TAGS = "volto.eea.europa.eu,biodiversity.europa.eu" - DEPENDENCIES = "volto-slate @eeacms/volto-datablocks" - VOLTO = "16" - } + GIT_NAME = "volto-n2k" + NAMESPACE = "@eeacms" + SONARQUBE_TAGS = "volto.eea.europa.eu,biodiversity.europa.eu" + DEPENDENCIES = "volto-slate @eeacms/volto-datablocks" + BACKEND_PROFILES = "eea.kitkat:testing" + BACKEND_ADDONS = "" + VOLTO = "16" + IMAGE_NAME = BUILD_TAG.toLowerCase() + } stages { - stage('Release') { when { allOf { @@ -20,52 +24,41 @@ pipeline { } steps { node(label: 'docker') { - withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN'),string(credentialsId: 'eea-jenkins-npm-token', variable: 'NPM_TOKEN')]) { - sh '''docker pull eeacms/gitflow''' - sh '''docker run -i --rm --name="$BUILD_TAG-gitflow-master" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_NAME="$GIT_NAME" -e GIT_TOKEN="$GITHUB_TOKEN" -e NPM_TOKEN="$NPM_TOKEN" -e LANGUAGE=javascript eeacms/gitflow''' + withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN'), string(credentialsId: 'eea-jenkins-npm-token', variable: 'NPM_TOKEN')]) { + sh '''docker run -i --rm --pull always --name="$IMAGE_NAME-gitflow-master" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_NAME="$GIT_NAME" -e GIT_TOKEN="$GITHUB_TOKEN" -e NPM_TOKEN="$NPM_TOKEN" -e LANGUAGE=javascript eeacms/gitflow''' } } } } - stage('Code') { + stage('Check if testing needed') { when { allOf { - environment name: 'CHANGE_ID', value: '' - not { changelog '.*^Automated release [0-9\\.]+$' } not { branch 'master' } + not { branch 'develop' } + environment name: 'CHANGE_ID', value: '' } } steps { - parallel( - - "ES lint": { - node(label: 'docker') { - sh '''docker run -i --rm --name="$BUILD_TAG-eslint" -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e VOLTO=$VOLTO plone/volto-addon-ci eslint''' - } - }, - - "Style lint": { - node(label: 'docker') { - sh '''docker run -i --rm --name="$BUILD_TAG-stylelint" -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e VOLTO=$VOLTO plone/volto-addon-ci stylelint''' - } - }, + script { + withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN')]) { + check_result = sh script: '''docker run --pull always -i --rm --name="$IMAGE_NAME-gitflow-check" -e GIT_TOKEN="$GITHUB_TOKEN" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_ORG="$GIT_ORG" -e GIT_NAME="$GIT_NAME" eeacms/gitflow /check_if_testing_needed.sh''', returnStatus: true - "Prettier": { - node(label: 'docker') { - sh '''docker run -i --rm --name="$BUILD_TAG-prettier" -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e VOLTO=$VOLTO plone/volto-addon-ci prettier''' + if (check_result == 0) { + env.SKIP_TESTS = 'yes' + } } - } - ) + } } } - stage('Tests') { + stage('Testing') { when { anyOf { allOf { not { environment name: 'CHANGE_ID', value: '' } environment name: 'CHANGE_TARGET', value: 'develop' + environment name: 'SKIP_TESTS', value: '' } allOf { environment name: 'CHANGE_ID', value: '' @@ -73,26 +66,76 @@ pipeline { not { changelog '.*^Automated release [0-9\\.]+$' } branch 'master' } + environment name: 'SKIP_TESTS', value: '' } } } - steps { - parallel( + stages { + stage('Build test image') { + steps { + checkout scm + sh '''docker build --build-arg="VOLTO_VERSION=$VOLTO" --build-arg="ADDON_NAME=$NAMESPACE/$GIT_NAME" --build-arg="ADDON_PATH=$GIT_NAME" . -t $IMAGE_NAME-frontend''' + } + } + + stage('Fix code') { + when { + environment name: 'CHANGE_ID', value: '' + not { branch 'master' } + } + steps { + script { + fix_result = sh(script: '''docker run --name="$IMAGE_NAME-fix" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend ci-fix''', returnStatus: true) + sh '''docker cp $IMAGE_NAME-fix:/app/src/addons/$GIT_NAME/src .''' + sh '''docker rm -v $IMAGE_NAME-fix''' + FOUND_FIX = sh(script: '''git diff | wc -l''', returnStdout: true).trim() - "Volto": { - node(label: 'docker') { - script { - try { - sh '''docker pull plone/volto-addon-ci''' - sh '''docker run -i --name="$BUILD_TAG-volto" -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e VOLTO=$VOLTO plone/volto-addon-ci''' - sh '''rm -rf xunit-reports''' - sh '''mkdir -p xunit-reports''' - sh '''docker cp $BUILD_TAG-volto:/opt/frontend/my-volto-project/coverage xunit-reports/''' - sh '''docker cp $BUILD_TAG-volto:/opt/frontend/my-volto-project/junit.xml xunit-reports/''' - sh '''docker cp $BUILD_TAG-volto:/opt/frontend/my-volto-project/unit_tests_log.txt xunit-reports/''' - stash name: "xunit-reports", includes: "xunit-reports/**" - archiveArtifacts artifacts: "xunit-reports/unit_tests_log.txt", fingerprint: true - publishHTML (target : [ + if (FOUND_FIX != '0') { + withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN')]) { + sh '''sed -i "s|url = .*|url = https://eea-jenkins:$GITHUB_TOKEN@github.com/eea/$GIT_NAME.git|" .git/config''' + } + sh '''git fetch origin $GIT_BRANCH:$GIT_BRANCH''' + sh '''git checkout $GIT_BRANCH''' + sh '''git add src/''' + sh '''git commit -m "style: Automated code fix" ''' + sh '''git push --set-upstream origin $GIT_BRANCH''' + sh '''exit 1''' + } + } + } + } + + stage('ES lint') { + steps { + sh '''docker run --rm --name="$IMAGE_NAME-eslint" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend lint''' + } + } + + stage('Style lint') { + steps { + sh '''docker run --rm --name="$IMAGE_NAME-stylelint" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend stylelint''' + } + } + + stage('Prettier') { + steps { + sh '''docker run --rm --name="$IMAGE_NAME-prettier" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend prettier''' + } + } + + stage('Coverage Tests') { + parallel { + + stage('Unit tests') { + steps { + script { + try { + sh '''docker run --name="$IMAGE_NAME-volto" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend test-ci''' + sh '''rm -rf xunit-reports''' + sh '''mkdir -p xunit-reports''' + sh '''docker cp $IMAGE_NAME-volto:/app/coverage xunit-reports/''' + sh '''docker cp $IMAGE_NAME-volto:/app/junit.xml xunit-reports/''' + publishHTML(target : [ allowMissing: false, alwaysLinkToLastBuild: true, keepAll: true, @@ -105,77 +148,62 @@ pipeline { catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') { junit testResults: 'xunit-reports/junit.xml', allowEmptyResults: true } - sh script: '''docker rm -v $BUILD_TAG-volto''', returnStatus: true + sh script: '''docker rm -v $IMAGE_NAME-volto''', returnStatus: true + } } } } - } - ) - } - } + + stage('Integration tests') { + steps { + script { + try { + sh '''docker run --pull always --rm -d --name="$IMAGE_NAME-plone" -e SITE="Plone" -e PROFILES="$BACKEND_PROFILES" -e ADDONS="$BACKEND_ADDONS" eeacms/plone-backend''' + sh '''docker run --link $IMAGE_NAME-plone:plone --entrypoint=make --name="$IMAGE_NAME-cypress" --workdir=/app/src/addons/${GIT_NAME} -e "RAZZLE_INTERNAL_API_PATH=http://plone:8080/Plone" $IMAGE_NAME-frontend cypress-ci''' + } finally { + try { + sh '''rm -rf cypress-videos cypress-results cypress-coverage cypress-screenshots''' + sh '''mkdir -p cypress-videos cypress-results cypress-coverage cypress-screenshots''' + sh '''docker cp $IMAGE_NAME-cypress:/app/src/addons/$GIT_NAME/cypress/videos cypress-videos/''' + sh '''docker cp $IMAGE_NAME-cypress:/app/src/addons/$GIT_NAME/cypress/reports cypress-results/''' + screenshots = sh script: '''docker cp $IMAGE_NAME-cypress:/app/src/addons/$GIT_NAME/cypress/screenshots cypress-screenshots''', returnStatus: true - // stage('Integration tests') { - when { - anyOf { - allOf { - not { environment name: 'CHANGE_ID', value: '' } - environment name: 'CHANGE_TARGET', value: 'develop' - } - allOf { - environment name: 'CHANGE_ID', value: '' - anyOf { - not { changelog '.*^Automated release [0-9\\.]+$' } - branch 'master' + archiveArtifacts artifacts: 'cypress-screenshots/**', fingerprint: true, allowEmptyArchive: true + + coverage = sh script: '''docker cp $IMAGE_NAME-cypress:/app/src/addons/$GIT_NAME/coverage cypress-coverage''', returnStatus: true + + if ( coverage == 0 ) { + publishHTML(target : [allowMissing: false, + alwaysLinkToLastBuild: true, + keepAll: true, + reportDir: 'cypress-coverage/coverage/lcov-report', + reportFiles: 'index.html', + reportName: 'CypressCoverage', + reportTitles: 'Integration Tests Code Coverage']) + } + sh '''for file in $(find cypress-results -name *.xml); do if [ $(grep -E 'failures="[1-9].*"' $file | wc -l) -eq 0 ]; then testname=$(grep -E 'file=.*failures="0"' $file | sed 's#.* file=".*\\/\\(.*\\.[jsxt]\\+\\)" time.*#\\1#' ); rm -f cypress-videos/videos/$testname.mp4; fi; done''' + archiveArtifacts artifacts: 'cypress-videos/**', fingerprint: true, allowEmptyArchive: true + } finally { + catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') { + junit testResults: 'cypress-results/**/*.xml', allowEmptyResults: true + } + sh script: "docker stop $IMAGE_NAME-plone", returnStatus: true + sh script: "docker rm -v $IMAGE_NAME-plone", returnStatus: true + sh script: "docker rm -v $IMAGE_NAME-cypress", returnStatus: true + } + } + } + } } } } } - // steps { - // parallel( - - // "Cypress": { - // node(label: 'docker') { - // script { - // try { - // sh '''docker pull eeacms/plone-backend; docker run -d --rm --name="$BUILD_TAG-plone" -e SITE="Plone" -e PROFILES="eea.kitkat:testing" eeacms/plone-backend''' - // sh '''docker pull plone/volto-addon-ci; docker run -i --name="$BUILD_TAG-cypress" --link $BUILD_TAG-plone:plone -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e DEPENDENCIES="$DEPENDENCIES" -e NODE_ENV=development -e VOLTO=$VOLTO plone/volto-addon-ci cypress''' - // } finally { - // try { - // sh '''rm -rf cypress-reports cypress-results cypress-coverage''' - // sh '''mkdir -p cypress-reports cypress-results cypress-coverage''' - // sh '''docker cp $BUILD_TAG-cypress:/opt/frontend/my-volto-project/src/addons/$GIT_NAME/cypress/videos cypress-reports/''' - // sh '''docker cp $BUILD_TAG-cypress:/opt/frontend/my-volto-project/src/addons/$GIT_NAME/cypress/reports cypress-results/''' - // coverage = sh script: '''docker cp $BUILD_TAG-cypress:/opt/frontend/my-volto-project/src/addons/$GIT_NAME/coverage cypress-coverage/''', returnStatus: true - // if ( coverage == 0 ) { - // publishHTML (target : [allowMissing: false, - // alwaysLinkToLastBuild: true, - // keepAll: true, - // reportDir: 'cypress-coverage/coverage/lcov-report', - // reportFiles: 'index.html', - // reportName: 'CypressCoverage', - // reportTitles: 'Integration Tests Code Coverage']) - // } - // sh '''touch empty_file; for ok_test in $(grep -E 'file=.*failures="0"' $(grep 'testsuites .*failures="0"' $(find cypress-results -name *.xml) empty_file | awk -F: '{print $1}') empty_file | sed 's/.* file="\\(.*\\)" time.*/\\1/' | sed 's#^cypress/integration/##g' | sed 's#^../../../node_modules/@eeacms/##g'); do rm -f cypress-reports/videos/$ok_test.mp4; rm -f cypress-reports/$ok_test.mp4; done''' - // archiveArtifacts artifacts: 'cypress-reports/**/*.mp4', fingerprint: true, allowEmptyArchive: true - // stash name: "cypress-coverage", includes: "cypress-coverage/**", allowEmpty: true - // } - // finally { - // catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') { - // junit testResults: 'cypress-results/**/*.xml', allowEmptyResults: true - // } - // sh script: "docker stop $BUILD_TAG-plone", returnStatus: true - // sh script: "docker rm -v $BUILD_TAG-plone", returnStatus: true - // sh script: "docker rm -v $BUILD_TAG-cypress", returnStatus: true - - // } - // } - // } - // } - // } - - // ) - // } - // } + post { + always { + sh script: "docker rmi $IMAGE_NAME-frontend", returnStatus: true + } + } + } stage('Report to SonarQube') { when { @@ -197,19 +225,16 @@ pipeline { } } steps { - node(label: 'swarm') { - script{ - checkout scm - unstash "xunit-reports" - // unstash "cypress-coverage" - def scannerHome = tool 'SonarQubeScanner'; - def nodeJS = tool 'NodeJS'; - withSonarQubeEnv('Sonarqube') { - sh '''sed -i "s#/opt/frontend/my-volto-project/src/addons/${GIT_NAME}/##g" xunit-reports/coverage/lcov.info''' - sh '''sed -i "s#src/addons/${GIT_NAME}/##g" xunit-reports/coverage/lcov.info''' - sh "export PATH=${scannerHome}/bin:${nodeJS}/bin:$PATH; sonar-scanner -Dsonar.javascript.lcov.reportPaths=./xunit-reports/coverage/lcov.info -Dsonar.sources=./src -Dsonar.projectKey=$GIT_NAME-$BRANCH_NAME -Dsonar.projectVersion=$BRANCH_NAME-$BUILD_NUMBER" - sh '''try=2; while [ \$try -gt 0 ]; do curl -s -XPOST -u "${SONAR_AUTH_TOKEN}:" "${SONAR_HOST_URL}api/project_tags/set?project=${GIT_NAME}-${BRANCH_NAME}&tags=${SONARQUBE_TAGS},${BRANCH_NAME}" > set_tags_result; if [ \$(grep -ic error set_tags_result ) -eq 0 ]; then try=0; else cat set_tags_result; echo "... Will retry"; sleep 60; try=\$(( \$try - 1 )); fi; done''' - } + script { + def scannerHome = tool 'SonarQubeScanner' + def nodeJS = tool 'NodeJS' + withSonarQubeEnv('Sonarqube') { + sh '''sed -i "s#/app/src/addons/${GIT_NAME}/##g" xunit-reports/coverage/lcov.info''' + sh '''sed -i "s#src/addons/${GIT_NAME}/##g" xunit-reports/coverage/lcov.info''' + sh '''cat xunit-reports/coverage/lcov.info''' + sh '''cat cypress-coverage/coverage/lcov.info''' + sh "export PATH=${scannerHome}/bin:${nodeJS}/bin:$PATH; sonar-scanner -Dsonar.javascript.lcov.reportPaths=./xunit-reports/coverage/lcov.info,./cypress-coverage/coverage/lcov.info -Dsonar.sources=./src -Dsonar.projectKey=$GIT_NAME-$BRANCH_NAME -Dsonar.projectVersion=$BRANCH_NAME-$BUILD_NUMBER" + sh '''try=5; while [ \$try -gt 0 ]; do curl -s -XPOST -u "${SONAR_AUTH_TOKEN}:" "${SONAR_HOST_URL}api/project_tags/set?project=${GIT_NAME}-${BRANCH_NAME}&tags=${SONARQUBE_TAGS},${BRANCH_NAME}" > set_tags_result; if [ \$(grep -ic error set_tags_result ) -eq 0 ]; then try=0; else cat set_tags_result; echo "... Will retry"; sleep 15; try=\$(( \$try - 1 )); fi; done''' } } } @@ -230,18 +255,15 @@ pipeline { } } steps { - node(label: 'docker') { - script { - sh '''docker pull eeacms/gitflow''' - sh '''echo "Error" > checkresult.txt''' - catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { - sh '''set -o pipefail; docker run -i --rm --name="$BUILD_TAG-gitflow-sn" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_NAME="$GIT_NAME" eeacms/gitflow /checkSonarqubemaster.sh | grep -v "Found script" | tee checkresult.txt''' - } - - publishChecks name: 'SonarQube', title: 'Sonarqube Code Quality Check', summary: "Quality check on the SonarQube metrics from branch develop, comparing it with the ones from master branch. No bugs are allowed", - text: readFile(file: 'checkresult.txt'), conclusion: "${currentBuild.currentResult}", - detailsURL: "${env.BUILD_URL}display/redirect" + script { + sh '''echo "Error" > checkresult.txt''' + catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { + sh '''set -o pipefail; docker run -i --rm --pull always --name="$IMAGE_NAME-gitflow-sn" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_NAME="$GIT_NAME" eeacms/gitflow /checkSonarqubemaster.sh | grep -v "Found script" | tee checkresult.txt''' } + + publishChecks name: 'SonarQube', title: 'Sonarqube Code Quality Check', summary: 'Quality check on the SonarQube metrics from branch develop, comparing it with the ones from master branch. No bugs are allowed', + text: readFile(file: 'checkresult.txt'), conclusion: "${currentBuild.currentResult}", + detailsURL: "${env.BUILD_URL}display/redirect" } } } @@ -254,20 +276,16 @@ pipeline { environment name: 'CHANGE_TARGET', value: 'master' } steps { - node(label: 'docker') { - script { - if ( env.CHANGE_BRANCH != "develop" ) { - error "Pipeline aborted due to PR not made from develop branch" - } - withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN')]) { - sh '''docker pull eeacms/gitflow''' - sh '''docker run -i --rm --name="$BUILD_TAG-gitflow-pr" -e GIT_CHANGE_TARGET="$CHANGE_TARGET" -e GIT_CHANGE_BRANCH="$CHANGE_BRANCH" -e GIT_CHANGE_AUTHOR="$CHANGE_AUTHOR" -e GIT_CHANGE_TITLE="$CHANGE_TITLE" -e GIT_TOKEN="$GITHUB_TOKEN" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e GIT_ORG="$GIT_ORG" -e GIT_NAME="$GIT_NAME" -e LANGUAGE=javascript eeacms/gitflow''' - } + script { + if (env.CHANGE_BRANCH != 'develop') { + error 'Pipeline aborted due to PR not made from develop branch' + } + withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN')]) { + sh '''docker run --pull always -i --rm --name="$IMAGE_NAME-gitflow-pr" -e GIT_CHANGE_TARGET="$CHANGE_TARGET" -e GIT_CHANGE_BRANCH="$CHANGE_BRANCH" -e GIT_CHANGE_AUTHOR="$CHANGE_AUTHOR" -e GIT_CHANGE_TITLE="$CHANGE_TITLE" -e GIT_TOKEN="$GITHUB_TOKEN" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e GIT_ORG="$GIT_ORG" -e GIT_NAME="$GIT_NAME" -e LANGUAGE=javascript eeacms/gitflow''' } } } } - } post { diff --git a/Makefile b/Makefile index f3614a8d..6e221b39 100644 --- a/Makefile +++ b/Makefile @@ -50,6 +50,11 @@ VOLTO_VERSION?=16 ADDON_PATH="${DIR}" ADDON_NAME="@eeacms/${ADDON_PATH}" DOCKER_COMPOSE=PLONE_VERSION=${PLONE_VERSION} VOLTO_VERSION=${VOLTO_VERSION} ADDON_NAME=${ADDON_NAME} ADDON_PATH=${ADDON_PATH} docker compose +RAZZLE_INTERNAL_API_PATH?="${RAZZLE_DEV_PROXY_API_PATH}" +RAZZLE_DEV_PROXY_API_PATH?="${RAZZLE_INTERNAL_API_PATH}" +CYPRESS_API_PATH="${RAZZLE_DEV_PROXY_API_PATH}" + + # Top-level targets .PHONY: all @@ -77,11 +82,11 @@ shell: ## Start a shell in the frontend container .PHONY: cypress-open cypress-open: ## Open cypress integration tests - NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress open + CYPRESS_API_PATH="${RAZZLE_DEV_PROXY_API_PATH}" NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress open .PHONY: cypress-run cypress-run: ## Run cypress integration tests - NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress run + CYPRESS_API_PATH="${RAZZLE_DEV_PROXY_API_PATH}" NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress run .PHONY: test test: ## Run jest tests @@ -129,3 +134,31 @@ i18n: ## i18n help: ## Show this help. @echo -e "$$(grep -hE '^\S+:.*##' $(MAKEFILE_LIST) | sed -e 's/:.*##\s*/:/' -e 's/^\(.\+\):\(.*\)/\\x1b[36m\1\\x1b[m:\2/' | column -c2 -t -s :)" head -n 14 Makefile + +.PHONY: ci-fix +ci-fix: + echo "Running lint-fix" + make lint-fix + echo "Running prettier-fix" + make prettier-fix + echo "Running stylelint-fix" + make stylelint-fix + +.PHONY: test-ci +test-ci: + cd /app + RAZZLE_JEST_CONFIG=src/addons/${ADDON_PATH}/jest-addon.config.js CI=true yarn test src/addons/${ADDON_PATH}/src --watchAll=false --reporters=default --reporters=jest-junit --collectCoverage --coverageReporters lcov cobertura text + +.PHONY: start-ci +start-ci: + cd ../.. + yarn start & + +.PHONY: cypress-ci +cypress-ci: + cp .coverage.babel.config.js /app/babel.config.js + make start-ci + $(NODE_MODULES)/.bin/wait-on -t 240000 http://localhost:3000 + NODE_ENV=development make cypress-run + + From 06a4ab151799b8cdf4a316dbcb0c323e0f568e30 Mon Sep 17 00:00:00 2001 From: valentinab25 Date: Thu, 2 Nov 2023 22:25:20 +0200 Subject: [PATCH 07/21] test: [JENKINS] Improve cypress time --- Jenkinsfile | 14 +++++++------- Makefile | 4 ++-- cypress.config.js | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 145e0b81..fdf7683d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -74,7 +74,7 @@ pipeline { stage('Build test image') { steps { checkout scm - sh '''docker build --build-arg="VOLTO_VERSION=$VOLTO" --build-arg="ADDON_NAME=$NAMESPACE/$GIT_NAME" --build-arg="ADDON_PATH=$GIT_NAME" . -t $IMAGE_NAME-frontend''' + sh '''docker build --pull --build-arg="VOLTO_VERSION=$VOLTO" --build-arg="ADDON_NAME=$NAMESPACE/$GIT_NAME" --build-arg="ADDON_PATH=$GIT_NAME" . -t $IMAGE_NAME-frontend''' } } @@ -159,12 +159,12 @@ pipeline { script { try { sh '''docker run --pull always --rm -d --name="$IMAGE_NAME-plone" -e SITE="Plone" -e PROFILES="$BACKEND_PROFILES" -e ADDONS="$BACKEND_ADDONS" eeacms/plone-backend''' - sh '''docker run --link $IMAGE_NAME-plone:plone --entrypoint=make --name="$IMAGE_NAME-cypress" --workdir=/app/src/addons/${GIT_NAME} -e "RAZZLE_INTERNAL_API_PATH=http://plone:8080/Plone" $IMAGE_NAME-frontend cypress-ci''' + sh '''timeout 3600 docker run --link $IMAGE_NAME-plone:plone --entrypoint=make --name="$IMAGE_NAME-cypress" --workdir=/app/src/addons/${GIT_NAME} -e "RAZZLE_INTERNAL_API_PATH=http://plone:8080/Plone" $IMAGE_NAME-frontend cypress-ci''' } finally { try { sh '''rm -rf cypress-videos cypress-results cypress-coverage cypress-screenshots''' sh '''mkdir -p cypress-videos cypress-results cypress-coverage cypress-screenshots''' - sh '''docker cp $IMAGE_NAME-cypress:/app/src/addons/$GIT_NAME/cypress/videos cypress-videos/''' + videos = sh script: '''docker cp $IMAGE_NAME-cypress:/app/src/addons/$GIT_NAME/cypress/videos cypress-videos/''', returnStatus: true sh '''docker cp $IMAGE_NAME-cypress:/app/src/addons/$GIT_NAME/cypress/reports cypress-results/''' screenshots = sh script: '''docker cp $IMAGE_NAME-cypress:/app/src/addons/$GIT_NAME/cypress/screenshots cypress-screenshots''', returnStatus: true @@ -181,8 +181,10 @@ pipeline { reportName: 'CypressCoverage', reportTitles: 'Integration Tests Code Coverage']) } - sh '''for file in $(find cypress-results -name *.xml); do if [ $(grep -E 'failures="[1-9].*"' $file | wc -l) -eq 0 ]; then testname=$(grep -E 'file=.*failures="0"' $file | sed 's#.* file=".*\\/\\(.*\\.[jsxt]\\+\\)" time.*#\\1#' ); rm -f cypress-videos/videos/$testname.mp4; fi; done''' - archiveArtifacts artifacts: 'cypress-videos/**', fingerprint: true, allowEmptyArchive: true + if ( videos == 0 ) { + sh '''for file in $(find cypress-results -name *.xml); do if [ $(grep -E 'failures="[1-9].*"' $file | wc -l) -eq 0 ]; then testname=$(grep -E 'file=.*failures="0"' $file | sed 's#.* file=".*\\/\\(.*\\.[jsxt]\\+\\)" time.*#\\1#' ); rm -f cypress-videos/videos/$testname.mp4; fi; done''' + archiveArtifacts artifacts: 'cypress-videos/**/*.mp4', fingerprint: true, allowEmptyArchive: true + } } finally { catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') { junit testResults: 'cypress-results/**/*.xml', allowEmptyResults: true @@ -231,8 +233,6 @@ pipeline { withSonarQubeEnv('Sonarqube') { sh '''sed -i "s#/app/src/addons/${GIT_NAME}/##g" xunit-reports/coverage/lcov.info''' sh '''sed -i "s#src/addons/${GIT_NAME}/##g" xunit-reports/coverage/lcov.info''' - sh '''cat xunit-reports/coverage/lcov.info''' - sh '''cat cypress-coverage/coverage/lcov.info''' sh "export PATH=${scannerHome}/bin:${nodeJS}/bin:$PATH; sonar-scanner -Dsonar.javascript.lcov.reportPaths=./xunit-reports/coverage/lcov.info,./cypress-coverage/coverage/lcov.info -Dsonar.sources=./src -Dsonar.projectKey=$GIT_NAME-$BRANCH_NAME -Dsonar.projectVersion=$BRANCH_NAME-$BUILD_NUMBER" sh '''try=5; while [ \$try -gt 0 ]; do curl -s -XPOST -u "${SONAR_AUTH_TOKEN}:" "${SONAR_HOST_URL}api/project_tags/set?project=${GIT_NAME}-${BRANCH_NAME}&tags=${SONARQUBE_TAGS},${BRANCH_NAME}" > set_tags_result; if [ \$(grep -ic error set_tags_result ) -eq 0 ]; then try=0; else cat set_tags_result; echo "... Will retry"; sleep 15; try=\$(( \$try - 1 )); fi; done''' } diff --git a/Makefile b/Makefile index 6e221b39..30b44f02 100644 --- a/Makefile +++ b/Makefile @@ -50,7 +50,7 @@ VOLTO_VERSION?=16 ADDON_PATH="${DIR}" ADDON_NAME="@eeacms/${ADDON_PATH}" DOCKER_COMPOSE=PLONE_VERSION=${PLONE_VERSION} VOLTO_VERSION=${VOLTO_VERSION} ADDON_NAME=${ADDON_NAME} ADDON_PATH=${ADDON_PATH} docker compose -RAZZLE_INTERNAL_API_PATH?="${RAZZLE_DEV_PROXY_API_PATH}" +RAZZLE_INTERNAL_API_PATH?="http://localhost:8080/Plone" RAZZLE_DEV_PROXY_API_PATH?="${RAZZLE_INTERNAL_API_PATH}" CYPRESS_API_PATH="${RAZZLE_DEV_PROXY_API_PATH}" @@ -86,7 +86,7 @@ cypress-open: ## Open cypress integration tests .PHONY: cypress-run cypress-run: ## Run cypress integration tests - CYPRESS_API_PATH="${RAZZLE_DEV_PROXY_API_PATH}" NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress run + CYPRESS_API_PATH="${RAZZLE_DEV_PROXY_API_PATH}" NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress run --browser chromium .PHONY: test test: ## Run jest tests diff --git a/cypress.config.js b/cypress.config.js index 4846ce98..7a9e0be9 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -2,12 +2,12 @@ const { defineConfig } = require('cypress'); module.exports = defineConfig({ viewportWidth: 1280, - defaultCommandTimeout: 5000, + defaultCommandTimeout: 8888, chromeWebSecurity: false, reporter: 'junit', - video: true, + video: false, retries: { - runMode: 1, + runMode: 2, openMode: 0, }, reporterOptions: { From 35460409817f496fc752ab34e37d6d33a069b2e9 Mon Sep 17 00:00:00 2001 From: valentinab25 Date: Fri, 3 Nov 2023 20:41:51 +0200 Subject: [PATCH 08/21] test: [JENKINS] Increase shm-size to cypress docker --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index fdf7683d..05a76565 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -159,7 +159,7 @@ pipeline { script { try { sh '''docker run --pull always --rm -d --name="$IMAGE_NAME-plone" -e SITE="Plone" -e PROFILES="$BACKEND_PROFILES" -e ADDONS="$BACKEND_ADDONS" eeacms/plone-backend''' - sh '''timeout 3600 docker run --link $IMAGE_NAME-plone:plone --entrypoint=make --name="$IMAGE_NAME-cypress" --workdir=/app/src/addons/${GIT_NAME} -e "RAZZLE_INTERNAL_API_PATH=http://plone:8080/Plone" $IMAGE_NAME-frontend cypress-ci''' + sh '''timeout 3600 docker run --shm-size=2g --link $IMAGE_NAME-plone:plone --entrypoint=make --name="$IMAGE_NAME-cypress" --workdir=/app/src/addons/${GIT_NAME} -e "RAZZLE_INTERNAL_API_PATH=http://plone:8080/Plone" $IMAGE_NAME-frontend cypress-ci''' } finally { try { sh '''rm -rf cypress-videos cypress-results cypress-coverage cypress-screenshots''' From 050ac982ec39e9a1b4885b665cdc118fca7b1283 Mon Sep 17 00:00:00 2001 From: valentinab25 Date: Mon, 6 Nov 2023 21:55:13 +0200 Subject: [PATCH 09/21] test: [JENKINS] Add cpu limit on cypress docker --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 05a76565..3e9d1875 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -159,7 +159,7 @@ pipeline { script { try { sh '''docker run --pull always --rm -d --name="$IMAGE_NAME-plone" -e SITE="Plone" -e PROFILES="$BACKEND_PROFILES" -e ADDONS="$BACKEND_ADDONS" eeacms/plone-backend''' - sh '''timeout 3600 docker run --shm-size=2g --link $IMAGE_NAME-plone:plone --entrypoint=make --name="$IMAGE_NAME-cypress" --workdir=/app/src/addons/${GIT_NAME} -e "RAZZLE_INTERNAL_API_PATH=http://plone:8080/Plone" $IMAGE_NAME-frontend cypress-ci''' + sh '''timeout -s 9 3600 docker run --shm-size=2g --cpu-quota=150000 --link $IMAGE_NAME-plone:plone --entrypoint=make --name="$IMAGE_NAME-cypress" --workdir=/app/src/addons/${GIT_NAME} -e "RAZZLE_INTERNAL_API_PATH=http://plone:8080/Plone" $IMAGE_NAME-frontend cypress-ci''' } finally { try { sh '''rm -rf cypress-videos cypress-results cypress-coverage cypress-screenshots''' From 99b3a84a266710fadf7d430117359b741cadede8 Mon Sep 17 00:00:00 2001 From: valentinab25 Date: Fri, 17 Nov 2023 04:08:56 +0200 Subject: [PATCH 10/21] test: [JENKINS] Run cypress in started frontend container --- Jenkinsfile | 7 ++++++- Makefile | 6 ++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3e9d1875..5cecbff1 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -159,7 +159,8 @@ pipeline { script { try { sh '''docker run --pull always --rm -d --name="$IMAGE_NAME-plone" -e SITE="Plone" -e PROFILES="$BACKEND_PROFILES" -e ADDONS="$BACKEND_ADDONS" eeacms/plone-backend''' - sh '''timeout -s 9 3600 docker run --shm-size=2g --cpu-quota=150000 --link $IMAGE_NAME-plone:plone --entrypoint=make --name="$IMAGE_NAME-cypress" --workdir=/app/src/addons/${GIT_NAME} -e "RAZZLE_INTERNAL_API_PATH=http://plone:8080/Plone" $IMAGE_NAME-frontend cypress-ci''' + sh '''docker run -d --shm-size=3g --link $IMAGE_NAME-plone:plone --name="$IMAGE_NAME-cypress" -e "RAZZLE_INTERNAL_API_PATH=http://plone:8080/Plone" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend start-ci''' + sh '''timeout -s 9 1800 docker exec --workdir=/app/src/addons/${GIT_NAME} $IMAGE_NAME-cypress make cypress-ci''' } finally { try { sh '''rm -rf cypress-videos cypress-results cypress-coverage cypress-screenshots''' @@ -189,6 +190,10 @@ pipeline { catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') { junit testResults: 'cypress-results/**/*.xml', allowEmptyResults: true } + catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') { + sh '''docker logs $IMAGE_NAME-cypress''' + } + sh script: "docker stop $IMAGE_NAME-cypress", returnStatus: true sh script: "docker stop $IMAGE_NAME-plone", returnStatus: true sh script: "docker rm -v $IMAGE_NAME-plone", returnStatus: true sh script: "docker rm -v $IMAGE_NAME-cypress", returnStatus: true diff --git a/Makefile b/Makefile index 30b44f02..efbf2fbd 100644 --- a/Makefile +++ b/Makefile @@ -151,14 +151,12 @@ test-ci: .PHONY: start-ci start-ci: + cp .coverage.babel.config.js /app/babel.config.js cd ../.. - yarn start & + yarn start .PHONY: cypress-ci cypress-ci: - cp .coverage.babel.config.js /app/babel.config.js - make start-ci $(NODE_MODULES)/.bin/wait-on -t 240000 http://localhost:3000 NODE_ENV=development make cypress-run - From 350f8a6928aafbf168472b572f8041a79f71f577 Mon Sep 17 00:00:00 2001 From: valentinab25 Date: Fri, 17 Nov 2023 20:09:03 +0200 Subject: [PATCH 11/21] test: [JENKINS] Use java17 for sonarqube scanner --- Jenkinsfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 5cecbff1..22c4b7db 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,4 +1,7 @@ pipeline { + tools { + jdk 'Java17' + } agent { node { label 'docker-host' } } From 8d9270a09506278ceaea25e8a72abdf5b22fcc78 Mon Sep 17 00:00:00 2001 From: Claudia Ifrim Date: Thu, 9 May 2024 17:24:26 +0300 Subject: [PATCH 12/21] update image size from 300 to 800 px --- package.json | 4 ++-- src/components/manage/Blocks/HabitatsBanner/View.jsx | 4 ++-- src/components/manage/Blocks/SpeciesBanner/View.jsx | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index d1b5a46f..e25f0336 100644 --- a/package.json +++ b/package.json @@ -40,9 +40,9 @@ "@cypress/code-coverage": "^3.10.0", "@plone/scripts": "*", "babel-plugin-transform-class-properties": "^6.24.1", - "md5": "^2.3.0", "husky": "^8.0.3", - "lint-staged": "^14.0.1" + "lint-staged": "^14.0.1", + "md5": "^2.3.0" }, "lint-staged": { "src/**/*.{js,jsx,ts,tsx,json}": [ diff --git a/src/components/manage/Blocks/HabitatsBanner/View.jsx b/src/components/manage/Blocks/HabitatsBanner/View.jsx index 2938f3ed..b068e00d 100644 --- a/src/components/manage/Blocks/HabitatsBanner/View.jsx +++ b/src/components/manage/Blocks/HabitatsBanner/View.jsx @@ -15,8 +15,8 @@ const SwiperLoader = loadable.lib(() => import('swiper')); const SwiperReactLoader = loadable.lib(() => import('swiper/react')); const getSource = (source) => { - let parsedSource = replaceQueryParam(source, 'x', 300); - parsedSource = replaceQueryParam(parsedSource, 'y', 300); + let parsedSource = replaceQueryParam(source, 'x', 800); + parsedSource = replaceQueryParam(parsedSource, 'y', 800); return parsedSource; }; diff --git a/src/components/manage/Blocks/SpeciesBanner/View.jsx b/src/components/manage/Blocks/SpeciesBanner/View.jsx index a2e1dd87..ffef75fa 100644 --- a/src/components/manage/Blocks/SpeciesBanner/View.jsx +++ b/src/components/manage/Blocks/SpeciesBanner/View.jsx @@ -16,8 +16,8 @@ const SwiperLoader = loadable.lib(() => import('swiper')); const SwiperReactLoader = loadable.lib(() => import('swiper/react')); const getSource = (source) => { - let parsedSource = replaceQueryParam(source, 'x', 300); - parsedSource = replaceQueryParam(parsedSource, 'y', 300); + let parsedSource = replaceQueryParam(source, 'x', 800); + parsedSource = replaceQueryParam(parsedSource, 'y', 800); return parsedSource; }; From eaded9b9ecd1ca2eb78aa8dd65838c063d95db85 Mon Sep 17 00:00:00 2001 From: ana-oprea Date: Fri, 10 May 2024 14:28:37 +0300 Subject: [PATCH 13/21] remove waitForResourceToLoad --- cypress/support/e2e.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/cypress/support/e2e.js b/cypress/support/e2e.js index f6964180..f8f752ce 100644 --- a/cypress/support/e2e.js +++ b/cypress/support/e2e.js @@ -35,10 +35,6 @@ export const slateBeforeEach = (contentType = 'Document') => { path: 'cypress', }); cy.visit('/cypress/my-page'); - cy.waitForResourceToLoad('@navigation'); - cy.waitForResourceToLoad('@breadcrumbs'); - cy.waitForResourceToLoad('@actions'); - cy.waitForResourceToLoad('@types'); cy.waitForResourceToLoad('my-page'); cy.navigate('/cypress/my-page/edit'); }; From ec0b9525b967f907922ae660bd9f520119cd80c1 Mon Sep 17 00:00:00 2001 From: Miu Razvan Date: Fri, 10 May 2024 16:28:29 +0300 Subject: [PATCH 14/21] try to use volto-spotlight theme in jenkins --- Dockerfile | 1 + package.json | 4 +++- theme.js | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 theme.js diff --git a/Dockerfile b/Dockerfile index b1ce6036..8a81c5e6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,6 +5,7 @@ FROM eeacms/frontend-builder:${VOLTO_VERSION} ARG ADDON_NAME ARG ADDON_PATH +COPY --chown=node:node ./theme.js /app/src/theme.js COPY --chown=node:node ./ /app/src/addons/${ADDON_PATH}/ RUN /setupAddon diff --git a/package.json b/package.json index e25f0336..226b50be 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "react" ], "addons": [ + "@eeacms/volto-spotlight", "@eeacms/volto-datablocks", "@eeacms/volto-openlayers-map", "@eeacms/volto-resize-helper", @@ -23,6 +24,7 @@ "url": "git@github.com:eea/volto-n2k.git" }, "dependencies": { + "@eeacms/volto-spotlight": "*", "@eeacms/volto-datablocks": "*", "@eeacms/volto-openlayers-map": "*", "@eeacms/volto-resize-helper": "*", @@ -85,4 +87,4 @@ "cypress:open": "make cypress-open", "prepare": "husky install" } -} +} \ No newline at end of file diff --git a/theme.js b/theme.js new file mode 100644 index 00000000..3409fc48 --- /dev/null +++ b/theme.js @@ -0,0 +1,2 @@ +import "@eeacms/volto-spotlight/semantic.less"; +import "@plone/volto/../theme/themes/pastanaga/extras/extras.less"; From a218b289fdbd0825540527cab4567ee3880a8e44 Mon Sep 17 00:00:00 2001 From: ana-oprea Date: Fri, 10 May 2024 16:41:13 +0300 Subject: [PATCH 15/21] fix(tests): add cypress 13 to devdependencies --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 226b50be..1aab178d 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "swiper": "9.1.1" }, "devDependencies": { + "cypress": "13.1.0", "@cypress/code-coverage": "^3.10.0", "@plone/scripts": "*", "babel-plugin-transform-class-properties": "^6.24.1", @@ -87,4 +88,4 @@ "cypress:open": "make cypress-open", "prepare": "husky install" } -} \ No newline at end of file +} From 50a4ff2a03ca964b93443ef98f79684d40e0b768 Mon Sep 17 00:00:00 2001 From: ana-oprea Date: Mon, 13 May 2024 12:09:03 +0300 Subject: [PATCH 16/21] fix sonarqube errors --- .../manage/Blocks/SiteHabitatsList/View.jsx | 2 +- .../manage/Blocks/StackedBarChart/StackedBars.jsx | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/components/manage/Blocks/SiteHabitatsList/View.jsx b/src/components/manage/Blocks/SiteHabitatsList/View.jsx index 206c3097..7e2df676 100644 --- a/src/components/manage/Blocks/SiteHabitatsList/View.jsx +++ b/src/components/manage/Blocks/SiteHabitatsList/View.jsx @@ -31,7 +31,7 @@ const View = (props) => {
{Object.keys(habitats)?.length ? ( Object.keys(habitats) - .sort() + .sort((a, b) => a.localeCompare(b)) .map((habitat) => { const expanded = expandedHabitats.includes(habitat); return ( diff --git a/src/components/manage/Blocks/StackedBarChart/StackedBars.jsx b/src/components/manage/Blocks/StackedBarChart/StackedBars.jsx index 5c9303f5..9faae469 100644 --- a/src/components/manage/Blocks/StackedBarChart/StackedBars.jsx +++ b/src/components/manage/Blocks/StackedBarChart/StackedBars.jsx @@ -34,12 +34,16 @@ function StackedBars(props) { d.forEach((v) => (v.key = d.key)); return d; }); + + const defaultColors = ['#70AD47', '#ED7D31', '#FF3F3F', '#AFABAB']; + const colorRange = + series.length > defaultColors.length + ? schemeSpectral[series.length] + : defaultColors; + const color = scaleOrdinal() .domain(series.map((d) => d.key)) - .range( - ['#70AD47', '#ED7D31', '#FF3F3F', '#AFABAB'] || - schemeSpectral[series.length], - ) + .range(colorRange) .unknown('#ccc'); return ( From 2ae40c1cfff7446120769a59a950bbcd93491988 Mon Sep 17 00:00:00 2001 From: EEA Jenkins <@users.noreply.github.com> Date: Mon, 13 May 2024 09:25:31 +0000 Subject: [PATCH 17/21] Automated release 1.0.34 --- CHANGELOG.md | 30 ++++++++++++++++++++++++++++-- package.json | 2 +- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f74d790b..4d9f678b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,11 +4,37 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). -### [1.0.33](https://github.com/eea/volto-n2k/compare/1.0.32...1.0.33) - 3 July 2023 +### [1.0.34](https://github.com/eea/volto-n2k/compare/1.0.33...1.0.34) - 13 May 2024 + +#### :bug: Bug Fixes + +- fix(tests): add cypress 13 to devdependencies [ana-oprea - [`a218b28`](https://github.com/eea/volto-n2k/commit/a218b289fdbd0825540527cab4567ee3880a8e44)] + +#### :house: Internal changes + +- chore: [JENKINS] Refactor automated testing [valentinab25 - [`e4f9fc8`](https://github.com/eea/volto-n2k/commit/e4f9fc800b753b97cca7c685bc47dd48804276f0)] +- chore: husky, lint-staged use fixed versions [valentinab25 - [`647d621`](https://github.com/eea/volto-n2k/commit/647d621d52400c50f5bc629b3ddc4f2121f14ffa)] +- chore:volto 16 in tests, update docs, fix stylelint overrides [valentinab25 - [`60d94b6`](https://github.com/eea/volto-n2k/commit/60d94b61ff8826abc57af9616793a1a247f585b5)] + +#### :house: Documentation changes + +- docs: Cleanup Makefile, update DEVELOP documentation, i18n - refs #254894 [valentinab25 - [`d6d017d`](https://github.com/eea/volto-n2k/commit/d6d017de1409f7319684f1c98d2c017d35631e83)] #### :hammer_and_wrench: Others -- hide arrows if pictures length <= 1 [Miu Razvan - [`5dfee21`](https://github.com/eea/volto-n2k/commit/5dfee212b039d92c325665eed203c99280fd8155)] +- fix sonarqube errors [ana-oprea - [`50a4ff2`](https://github.com/eea/volto-n2k/commit/50a4ff2a03ca964b93443ef98f79684d40e0b768)] +- try to use volto-spotlight theme in jenkins [Miu Razvan - [`ec0b952`](https://github.com/eea/volto-n2k/commit/ec0b9525b967f907922ae660bd9f520119cd80c1)] +- remove waitForResourceToLoad [ana-oprea - [`eaded9b`](https://github.com/eea/volto-n2k/commit/eaded9b9ecd1ca2eb78aa8dd65838c063d95db85)] +- update image size from 300 to 800 px [Claudia Ifrim - [`8d9270a`](https://github.com/eea/volto-n2k/commit/8d9270a09506278ceaea25e8a72abdf5b22fcc78)] +- test: [JENKINS] Use java17 for sonarqube scanner [valentinab25 - [`350f8a6`](https://github.com/eea/volto-n2k/commit/350f8a6928aafbf168472b572f8041a79f71f577)] +- test: [JENKINS] Run cypress in started frontend container [valentinab25 - [`99b3a84`](https://github.com/eea/volto-n2k/commit/99b3a84a266710fadf7d430117359b741cadede8)] +- test: [JENKINS] Add cpu limit on cypress docker [valentinab25 - [`050ac98`](https://github.com/eea/volto-n2k/commit/050ac982ec39e9a1b4885b665cdc118fca7b1283)] +- test: [JENKINS] Increase shm-size to cypress docker [valentinab25 - [`3546040`](https://github.com/eea/volto-n2k/commit/35460409817f496fc752ab34e37d6d33a069b2e9)] +- test: [JENKINS] Improve cypress time [valentinab25 - [`06a4ab1`](https://github.com/eea/volto-n2k/commit/06a4ab151799b8cdf4a316dbcb0c323e0f568e30)] +- test: EN locales, pre-commit fix, feature PRs checks Refs #257193 [valentinab25 - [`4850d6a`](https://github.com/eea/volto-n2k/commit/4850d6a65349fe49dbe9244c30592ae38c9aeaba)] +- test: Update Makefile and docker-compose to align it with Jenkinsfile [valentinab25 - [`2c91856`](https://github.com/eea/volto-n2k/commit/2c9185688a2fe6b36e5eeb2963f6c8676e3c5628)] +### [1.0.33](https://github.com/eea/volto-n2k/compare/1.0.32...1.0.33) - 3 July 2023 + ### [1.0.32](https://github.com/eea/volto-n2k/compare/1.0.31...1.0.32) - 26 June 2023 #### :hammer_and_wrench: Others diff --git a/package.json b/package.json index 1aab178d..2bc13b39 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@eeacms/volto-n2k", - "version": "1.0.33", + "version": "1.0.34", "description": "volto-n2k: Volto add-on", "main": "src/index.js", "author": "European Environment Agency: IDM2 A-Team", From ea4cd65a14719c5c60b899332d7ed289c1a50e5c Mon Sep 17 00:00:00 2001 From: ana-oprea Date: Mon, 13 May 2024 14:03:39 +0300 Subject: [PATCH 18/21] fix: fix issue where schemeSpectral was never used due to the always truthy color array --- .../manage/Blocks/StackedBarChart/StackedBars.jsx | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/components/manage/Blocks/StackedBarChart/StackedBars.jsx b/src/components/manage/Blocks/StackedBarChart/StackedBars.jsx index 9faae469..f3c67ebd 100644 --- a/src/components/manage/Blocks/StackedBarChart/StackedBars.jsx +++ b/src/components/manage/Blocks/StackedBarChart/StackedBars.jsx @@ -12,7 +12,7 @@ const getSerieData = (serie) => { function StackedBars(props) { const { d3 } = props; - const { scaleOrdinal, schemeSpectral, stack } = d3; + const { scaleOrdinal, stack } = d3; const { element, height, @@ -35,15 +35,9 @@ function StackedBars(props) { return d; }); - const defaultColors = ['#70AD47', '#ED7D31', '#FF3F3F', '#AFABAB']; - const colorRange = - series.length > defaultColors.length - ? schemeSpectral[series.length] - : defaultColors; - const color = scaleOrdinal() .domain(series.map((d) => d.key)) - .range(colorRange) + .range(['#70AD47', '#ED7D31', '#FF3F3F', '#AFABAB']) .unknown('#ccc'); return ( From 6d0704e744edf8622684c5c4f0198c796cedc593 Mon Sep 17 00:00:00 2001 From: EEA Jenkins <@users.noreply.github.com> Date: Mon, 13 May 2024 11:16:28 +0000 Subject: [PATCH 19/21] Automated release 1.0.34 --- CHANGELOG.md | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d9f678b..2fc82a3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,11 +8,11 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). #### :bug: Bug Fixes +- fix: fix issue where schemeSpectral was never used due to the always truthy color array [ana-oprea - [`ea4cd65`](https://github.com/eea/volto-n2k/commit/ea4cd65a14719c5c60b899332d7ed289c1a50e5c)] - fix(tests): add cypress 13 to devdependencies [ana-oprea - [`a218b28`](https://github.com/eea/volto-n2k/commit/a218b289fdbd0825540527cab4567ee3880a8e44)] #### :house: Internal changes -- chore: [JENKINS] Refactor automated testing [valentinab25 - [`e4f9fc8`](https://github.com/eea/volto-n2k/commit/e4f9fc800b753b97cca7c685bc47dd48804276f0)] - chore: husky, lint-staged use fixed versions [valentinab25 - [`647d621`](https://github.com/eea/volto-n2k/commit/647d621d52400c50f5bc629b3ddc4f2121f14ffa)] - chore:volto 16 in tests, update docs, fix stylelint overrides [valentinab25 - [`60d94b6`](https://github.com/eea/volto-n2k/commit/60d94b61ff8826abc57af9616793a1a247f585b5)] @@ -26,11 +26,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - try to use volto-spotlight theme in jenkins [Miu Razvan - [`ec0b952`](https://github.com/eea/volto-n2k/commit/ec0b9525b967f907922ae660bd9f520119cd80c1)] - remove waitForResourceToLoad [ana-oprea - [`eaded9b`](https://github.com/eea/volto-n2k/commit/eaded9b9ecd1ca2eb78aa8dd65838c063d95db85)] - update image size from 300 to 800 px [Claudia Ifrim - [`8d9270a`](https://github.com/eea/volto-n2k/commit/8d9270a09506278ceaea25e8a72abdf5b22fcc78)] -- test: [JENKINS] Use java17 for sonarqube scanner [valentinab25 - [`350f8a6`](https://github.com/eea/volto-n2k/commit/350f8a6928aafbf168472b572f8041a79f71f577)] -- test: [JENKINS] Run cypress in started frontend container [valentinab25 - [`99b3a84`](https://github.com/eea/volto-n2k/commit/99b3a84a266710fadf7d430117359b741cadede8)] -- test: [JENKINS] Add cpu limit on cypress docker [valentinab25 - [`050ac98`](https://github.com/eea/volto-n2k/commit/050ac982ec39e9a1b4885b665cdc118fca7b1283)] -- test: [JENKINS] Increase shm-size to cypress docker [valentinab25 - [`3546040`](https://github.com/eea/volto-n2k/commit/35460409817f496fc752ab34e37d6d33a069b2e9)] -- test: [JENKINS] Improve cypress time [valentinab25 - [`06a4ab1`](https://github.com/eea/volto-n2k/commit/06a4ab151799b8cdf4a316dbcb0c323e0f568e30)] - test: EN locales, pre-commit fix, feature PRs checks Refs #257193 [valentinab25 - [`4850d6a`](https://github.com/eea/volto-n2k/commit/4850d6a65349fe49dbe9244c30592ae38c9aeaba)] - test: Update Makefile and docker-compose to align it with Jenkinsfile [valentinab25 - [`2c91856`](https://github.com/eea/volto-n2k/commit/2c9185688a2fe6b36e5eeb2963f6c8676e3c5628)] ### [1.0.33](https://github.com/eea/volto-n2k/compare/1.0.32...1.0.33) - 3 July 2023 @@ -287,7 +282,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - Update [razvanMiu - [`42ab50e`](https://github.com/eea/volto-n2k/commit/42ab50e6681a47251d15ac06b836c6f8c27157fa)] - Added bubble chart [razvanMiu - [`89fba5e`](https://github.com/eea/volto-n2k/commit/89fba5e5db41aa955ba2d0ed58c9f0042c461504)] - Group species by id_eunis in species list [razvanMiu - [`543c957`](https://github.com/eea/volto-n2k/commit/543c9573b53acd8eecc9afbb6ae7beeddba53966)] -- Add Sonarqube tag using frontend addons list [EEA Jenkins - [`2ca3e4c`](https://github.com/eea/volto-n2k/commit/2ca3e4c092211f92339791d71db81f5b4ca2d562)] - update maps - species and habitats distribution maps [Claudia Ifrim - [`ad12eb1`](https://github.com/eea/volto-n2k/commit/ad12eb141907d6f28444f1eafc3f687735d2a68d)] - update format for common name and author [Claudia Ifrim - [`26b7a2f`](https://github.com/eea/volto-n2k/commit/26b7a2f3d20c7701b57fb24f39fc7dfeceec3ce8)] - update format for species name (common / scientific) [Claudia Ifrim - [`abdedcf`](https://github.com/eea/volto-n2k/commit/abdedcfe645665031dedf050fd2c5cdde8c14a50)] From f7ffa9a8d4621fe4d0e46fd6450791a9f6d5c7e7 Mon Sep 17 00:00:00 2001 From: ana-oprea Date: Mon, 13 May 2024 15:28:07 +0300 Subject: [PATCH 20/21] use volto-spotlight theme in jenkins --- Dockerfile | 1 - theme.js | 2 -- 2 files changed, 3 deletions(-) delete mode 100644 theme.js diff --git a/Dockerfile b/Dockerfile index 8a81c5e6..b1ce6036 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,6 @@ FROM eeacms/frontend-builder:${VOLTO_VERSION} ARG ADDON_NAME ARG ADDON_PATH -COPY --chown=node:node ./theme.js /app/src/theme.js COPY --chown=node:node ./ /app/src/addons/${ADDON_PATH}/ RUN /setupAddon diff --git a/theme.js b/theme.js deleted file mode 100644 index 3409fc48..00000000 --- a/theme.js +++ /dev/null @@ -1,2 +0,0 @@ -import "@eeacms/volto-spotlight/semantic.less"; -import "@plone/volto/../theme/themes/pastanaga/extras/extras.less"; From 1b11a928b748e616cac50aab3ded085950036d03 Mon Sep 17 00:00:00 2001 From: EEA Jenkins <@users.noreply.github.com> Date: Mon, 13 May 2024 12:38:59 +0000 Subject: [PATCH 21/21] Automated release 1.0.34 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2fc82a3b..1cc397fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). #### :hammer_and_wrench: Others +- use volto-spotlight theme in jenkins [ana-oprea - [`f7ffa9a`](https://github.com/eea/volto-n2k/commit/f7ffa9a8d4621fe4d0e46fd6450791a9f6d5c7e7)] - fix sonarqube errors [ana-oprea - [`50a4ff2`](https://github.com/eea/volto-n2k/commit/50a4ff2a03ca964b93443ef98f79684d40e0b768)] - try to use volto-spotlight theme in jenkins [Miu Razvan - [`ec0b952`](https://github.com/eea/volto-n2k/commit/ec0b9525b967f907922ae660bd9f520119cd80c1)] - remove waitForResourceToLoad [ana-oprea - [`eaded9b`](https://github.com/eea/volto-n2k/commit/eaded9b9ecd1ca2eb78aa8dd65838c063d95db85)]