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/Jenkinsfile b/Jenkinsfile index ea6de58..82c905e 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' + } } } } @@ -110,11 +116,17 @@ pipeline { stage('Integration 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' + } } } } @@ -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' } } } @@ -200,10 +218,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 30be8ac..4846ce9 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 32eec0e..cf43a04 100644 --- a/package.json +++ b/package.json @@ -22,12 +22,35 @@ "@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": "*" }, "repository": { "type": "git", "url": "git@github.com:eea/volto-columns-block.git" }, + "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", "release-major-beta": "release-it major --preRelease=beta", @@ -45,7 +68,8 @@ "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" }, "jest": { "enableSymlinks": true