diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 0000000..9183f9d --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,2 @@ +[ -n "$CI" ] && exit 0 +yarn lint-staged diff --git a/CHANGELOG.md b/CHANGELOG.md index 9cf7bd1..bda9f79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,31 @@ 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). +### [5.2.4](https://github.com/eea/volto-slate-zotero/compare/5.2.3...5.2.4) - 11 October 2023 + +#### :house: Internal changes + +- chore:volto 16 in tests, update docs, fix stylelint overrides [valentinab25 - [`726bc0a`](https://github.com/eea/volto-slate-zotero/commit/726bc0a66e250df5c8970f6909045fff97f206bc)] +- style: lint-staged reorder in package.json [Alin Voinea - [`e72a4cf`](https://github.com/eea/volto-slate-zotero/commit/e72a4cf63ae5653522965f8237a1d4239c2a0135)] + +#### :house: Documentation changes + +- docs: Update README and DEVELOP [Alin Voinea - [`a4c20e5`](https://github.com/eea/volto-slate-zotero/commit/a4c20e50a4c799fbdb90b5cb268adcfc8fb95c80)] +- docs: Update README and DEVELOP [Alin Voinea - [`d5edf70`](https://github.com/eea/volto-slate-zotero/commit/d5edf70bfa59020b8af56b9660dffe4dd1a067fd)] + +#### :hammer_and_wrench: Others + +- test: change e2e test [ana-oprea - [`93bde44`](https://github.com/eea/volto-slate-zotero/commit/93bde44a744b27a9d8db26d3726c006690ca0d5d)] +- test: change e2e test [ana-oprea - [`c8f1e43`](https://github.com/eea/volto-slate-zotero/commit/c8f1e43e973442dcb160aa575b4ee601db2a3dbd)] +- test: change e2e test [ana-oprea - [`2b6823b`](https://github.com/eea/volto-slate-zotero/commit/2b6823b30b10516e382173d3daf3bfaf83e53f0a)] +- test: change e2e test [ana-oprea - [`4d65aa0`](https://github.com/eea/volto-slate-zotero/commit/4d65aa04b6bdb59c31e9ce1861834915013457ee)] +- test: change volto version in Jenkinsfile [ana-oprea - [`41998e6`](https://github.com/eea/volto-slate-zotero/commit/41998e6ddfc6064039f65853693af0ec56afb56b)] +- test: update package.json pre-commit lint order [ana-oprea - [`f5cf3ad`](https://github.com/eea/volto-slate-zotero/commit/f5cf3ad4d03a909ac41b03a0c94a6adfc97aab27)] +- test: eslint [ana-oprea - [`30889ce`](https://github.com/eea/volto-slate-zotero/commit/30889ce2208653b2efaec4c702cf4245cc8204ba)] +- test: eslint [ana-oprea - [`c981671`](https://github.com/eea/volto-slate-zotero/commit/c981671b761e2591bd845ef5c1bb5f8396cd306a)] +- test: increase cypress timeout [ana-oprea - [`c3604bb`](https://github.com/eea/volto-slate-zotero/commit/c3604bba4366325106798a861554387a101a3f04)] +- test: Re-enable cypress [Alin Voinea - [`b4a2cb9`](https://github.com/eea/volto-slate-zotero/commit/b4a2cb9d316b23e49f284b5b01fc58b38ade8ab7)] +- test: EN locales, pre-commit fix, feature PRs checks Refs #257193 [valentinab25 - [`7a7c214`](https://github.com/eea/volto-slate-zotero/commit/7a7c2143e2ee7fffdbbcb330c1f3f6c74724956d)] ### [5.2.3](https://github.com/eea/volto-slate-zotero/compare/5.2.2...5.2.3) - 1 September 2023 #### :bug: Bug Fixes diff --git a/DEVELOP.md b/DEVELOP.md index 19a0d4d..292ad03 100644 --- a/DEVELOP.md +++ b/DEVELOP.md @@ -16,30 +16,26 @@ 1. Go to http://localhost:3000 -1. Happy hacking! +1. Initialize git hooks ```Bash - cd src/addons/volto-slate-zotero/ + yarn prepare ``` +1. Happy hacking! + ### Or add @eeacms/volto-slate-zotero 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` - $ npm install -g yo - $ npm install -g @plone/generator-volto - $ npm install -g mrs-developer + npm install -g yo @plone/generator-volto mrs-developer 1. Create new volto app - $ yo @plone/volto my-volto-project \ - --workspace src/addons/volto-slate-zotero \ - --addon @eeacms/volto-slate-zotero \ - --no-interactive \ - --skip-install - $ cd my-volto-project + yo @plone/volto my-volto-project --addon @eeacms/volto-slate-zotero --skip-install + cd my-volto-project 1. Add the following to `mrs.developer.json`: @@ -54,28 +50,26 @@ Before starting make sure your development environment is properly set. See [Vol 1. Install - $ yarn develop - $ yarn + make develop + yarn 1. Start backend - $ docker run -d --name plone -p 8080:8080 -e SITE=Plone 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 - $ yarn start + yarn start 1. Go to http://localhost:3000 1. Happy hacking! - $ cd src/addons/volto-slate-zotero/ + cd src/addons/volto-slate-zotero/ ## Cypress diff --git a/Jenkinsfile b/Jenkinsfile index 9ef24b3..5355ebf 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,7 +6,7 @@ pipeline { NAMESPACE = "@eeacms" SONARQUBE_TAGS = "volto.eea.europa.eu,www.eea.europa.eu-ims,climate-energy.eea.europa.eu,sustainability.eionet.europa.eu,forest.eea.europa.eu,biodiversity.europa.eu,clms.land.copernicus.eu,industry.eea.europa.eu,water.europa.eu-freshwater,demo-www.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu,water.europa.eu-marine,climate-adapt.eea.europa.eu,climate-advisory-board.devel4cph.eea.europa.eu,climate-advisory-board.europa.eu,www.eea.europa.eu-en" DEPENDENCIES = "" - VOLTO = "" + VOLTO = "16" } stages { @@ -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' + } } } } @@ -108,72 +114,84 @@ pipeline { } } - // stage('Integration tests') { - // when { - // allOf { - // environment name: 'CHANGE_ID', value: '' - // anyOf { - // not { changelog '.*^Automated release [0-9\\.]+$' } - // branch 'master' - // } - // } - // } - // steps { - // parallel( + 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' + } + } + } + } + steps { + parallel( - // "Cypress": { - // node(label: 'docker') { - // script { - // try { - // sh '''docker pull eeacms/plone-backend; docker run --rm -d --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 + "Cypress": { + node(label: 'docker') { + script { + try { + sh '''docker pull eeacms/plone-backend; docker run --rm -d --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 - // } - // } - // } - // } - // } + } + } + } + } + } - // ) - // } - // } + ) + } + } 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' } } } @@ -183,7 +201,7 @@ pipeline { script{ checkout scm unstash "xunit-reports" - // unstash "cypress-coverage" + unstash "cypress-coverage" def scannerHome = tool 'SonarQubeScanner'; def nodeJS = tool 'NodeJS'; withSonarQubeEnv('Sonarqube') { @@ -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 { @@ -222,6 +246,7 @@ pipeline { } } + stage('Pull Request') { when { not { diff --git a/Makefile b/Makefile index 4a5cbed..f3614a8 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/README.md b/README.md index 9c2b82e..041fb9e 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,10 @@ This version requires: `@plone/volto >= 16.0.0.alpha.15` (`volto-slate` part of Volto Core). +## Dependencies (Backend) + +* [eea.zotero](https://pypi.org/project/eea.zotero) + ## Getting started ### Try volto-slate-zotero with Docker @@ -79,19 +83,6 @@ Go to http://localhost:3000 1. Happy editing! - -## Dependencies - -### Backend - -- [Plone](https://plone.org/download) -- [plone.restapi](https://pypi.org/project/plone.restapi/) -- [eea.zotero](https://pypi.org/project/eea.zotero) - -### Frontend - -- [Volto](https://github.com/plone/volto) - ## Release See [RELEASE.md](https://github.com/eea/volto-slate-zotero/blob/master/RELEASE.md). @@ -100,7 +91,6 @@ See [RELEASE.md](https://github.com/eea/volto-slate-zotero/blob/master/RELEASE.m See [DEVELOP.md](https://github.com/eea/volto-slate-zotero/blob/master/DEVELOP.md). - ## Copyright and license The Initial Owner of the Original Code is European Environment Agency (EEA). diff --git a/RELEASE.md b/RELEASE.md index 24f98ee..4e311a0 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). diff --git a/cypress.config.js b/cypress.config.js index 30be8ac..3fc8919 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -7,7 +7,7 @@ module.exports = defineConfig({ reporter: 'junit', video: true, retries: { - runMode: 8, + runMode: 1, openMode: 0, }, reporterOptions: { diff --git a/cypress/e2e/01-slate-zotero-block.cy.js b/cypress/e2e/01-slate-zotero-block.cy.js index 30ac91c..9267bad 100644 --- a/cypress/e2e/01-slate-zotero-block.cy.js +++ b/cypress/e2e/01-slate-zotero-block.cy.js @@ -145,7 +145,13 @@ describe('Slate citations', () => { cy.clickSlateButton('Citation'); // select first Zotero collection - cy.get('.pastanaga-menu-list ul>li button').wait(2000).first().click(); + cy.get('.pastanaga-menu-list ul>li button').should('be.visible'); + cy.get('.pastanaga-menu-list ul>li button').should('contain', '2009'); + cy.get('.pastanaga-menu-list ul>li button') + .should('be.visible') + .should('be.enabled') + .first() + .click({ force: true }); // select first item from the Zotero collection cy.get('.items.pastanaga-menu .pastanaga-menu-list ul li') @@ -203,7 +209,7 @@ describe('Slate citations', () => { // In Footnotes block first reference has "a,b" to link to citing elements cy.get('.footnotes-listing-block ol') - .click() + .click({ force: true }) .children() .first() .find('sup') diff --git a/package.json b/package.json index 6c0662c..2e66e5a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@eeacms/volto-slate-zotero", - "version": "5.2.3", + "version": "5.2.4", "description": "Zotero integration with Volto Slate Footnotes", "main": "src/index.js", "author": "European Environment Agency: IDM2 A-Team", @@ -31,8 +31,31 @@ "@cypress/code-coverage": "^3.10.0", "@plone/scripts": "*", "babel-plugin-transform-class-properties": "^6.24.1", + "husky": "*", + "lint-staged": "*", "md5": "^2.3.0" }, + "lint-staged": { + "src/**/*.{js,jsx,ts,tsx,json}": [ + "make prettier-fix", + "make lint-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", "release-major-beta": "release-it major --preRelease=beta", @@ -40,7 +63,7 @@ "bootstrap": "npm install -g ejs; npm link ejs; node bootstrap", "test": "make test", "test:fix": "make test-update", - "pre-commit": "yarn stylelint:fix && yarn prettier:fix && yarn lint:fix", + "pre-commit": "yarn stylelint:fix && yarn prettier:fix && yarn lint:fix && yarn i18n", "stylelint": "make stylelint", "stylelint:overrides": "make stylelint-overrides", "stylelint:fix": "make stylelint-fix", @@ -50,6 +73,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" } }