@eeacms/volto-marine-policy 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/.coverage.babel.config.js +9 -0
  2. package/.eslintrc.js +65 -0
  3. package/.husky/pre-commit +2 -0
  4. package/.release-it.json +17 -0
  5. package/CHANGELOG.md +5 -0
  6. package/DEVELOP.md +53 -0
  7. package/DEVELOP.md.tpl +106 -0
  8. package/Jenkinsfile.tpl +416 -0
  9. package/LICENSE.md +9 -0
  10. package/Makefile.tpl +165 -0
  11. package/README.md +172 -0
  12. package/README.md.tpl +93 -0
  13. package/RELEASE.md +74 -0
  14. package/babel.config.js +17 -0
  15. package/bootstrap +41 -0
  16. package/cypress.config.js +24 -0
  17. package/docker-compose.yml +32 -0
  18. package/jest-addon.config.js +35 -0
  19. package/jest-addon.config.js.tpl +51 -0
  20. package/jest.setup.js +65 -0
  21. package/locales/de/LC_MESSAGES/volto.po +14 -0
  22. package/locales/en/LC_MESSAGES/volto.po +14 -0
  23. package/locales/it/LC_MESSAGES/volto.po +14 -0
  24. package/locales/ro/LC_MESSAGES/volto.po +14 -0
  25. package/locales/volto.pot +16 -0
  26. package/package.json +68 -0
  27. package/package.json.tpl +70 -0
  28. package/razzle.extend.js +29 -0
  29. package/src/components/Blocks/CustomBlockTemplates/customBlockTemplates.js +25 -0
  30. package/src/components/Blocks/MsfdDataExplorerBlock/Edit.jsx +29 -0
  31. package/src/components/Blocks/MsfdDataExplorerBlock/View.jsx +105 -0
  32. package/src/components/Blocks/MsfdDataExplorerBlock/index.js +23 -0
  33. package/src/components/Blocks/MsfdDataExplorerBlock/schema.jsx +30 -0
  34. package/src/components/Result/MarineMeasureItem.jsx +83 -0
  35. package/src/components/Widgets/MeasureViewWidget.jsx +233 -0
  36. package/src/components/Widgets/String.jsx +15 -0
  37. package/src/components/Widgets/TextAlign.jsx +41 -0
  38. package/src/components/Widgets/measure.css +101 -0
  39. package/src/components/index.js +15 -0
  40. package/src/components/theme/AppExtras/PrintPage/PrintPage.jsx +61 -0
  41. package/src/components/theme/AppExtras/PrintPage/css/printpage.less +29 -0
  42. package/src/components/theme/AppExtras/PrintPage/index.js +3 -0
  43. package/src/components/theme/AppExtras/ScrollToTop/ScrollToTop.jsx +61 -0
  44. package/src/components/theme/AppExtras/ScrollToTop/css/scrolltop.less +19 -0
  45. package/src/components/theme/AppExtras/ScrollToTop/index.js +3 -0
  46. package/src/components/theme/AppExtras/index.js +18 -0
  47. package/src/components/theme/DatabaseItemView/DatabaseItemView.jsx +39 -0
  48. package/src/components/theme/DatabaseItemView/style.less +87 -0
  49. package/src/components/theme/Header/HeroSection.jsx +45 -0
  50. package/src/components/theme/Header/StickyHeader.jsx +51 -0
  51. package/src/components/theme/Header/less/globals.less +18 -0
  52. package/src/components/theme/Header/less/herosection.less +64 -0
  53. package/src/components/theme/Header/less/herosection.variables +18 -0
  54. package/src/components/theme/ItemMetadata/ItemMetadata.jsx +217 -0
  55. package/src/components/theme/ItemMetadata/ItemMetadataSnippet.jsx +69 -0
  56. package/src/components/theme/ItemMetadata/ItemTitle.jsx +29 -0
  57. package/src/components/theme/MetadataListingView/MapPreview.jsx +105 -0
  58. package/src/components/theme/MetadataListingView/MetadataHeader.jsx +66 -0
  59. package/src/components/theme/MetadataListingView/MetadataListingView.jsx +36 -0
  60. package/src/components/theme/MetadataListingView/style.less +219 -0
  61. package/src/components/theme/SimpleListingView/SimpleListingView.jsx +97 -0
  62. package/src/components/theme/SimpleListingView/style.less +33 -0
  63. package/src/components/theme/Tableau/TableauDownload.jsx +86 -0
  64. package/src/components/theme/Tableau/TableauFullscreen.jsx +78 -0
  65. package/src/components/theme/Tableau/TableauShare.jsx +128 -0
  66. package/src/components/theme/View/FullwidthView.jsx +102 -0
  67. package/src/components/theme/View/HeroSectionView.jsx +125 -0
  68. package/src/constants/ActionTypes.js +12 -0
  69. package/src/constants/measureFields.js +56 -0
  70. package/src/customizations/@eeacms/volto-block-style/StyleWrapper/schema.js +217 -0
  71. package/src/customizations/@eeacms/volto-eea-design-system/ui/Header/Header.jsx +358 -0
  72. package/src/customizations/@eeacms/volto-eea-design-system/ui/Header/HeaderMenuPopUp.js +403 -0
  73. package/src/customizations/@eeacms/volto-eea-design-system/ui/Header/HeaderSearchPopUp.js +131 -0
  74. package/src/customizations/@eeacms/volto-eea-design-system/ui/Logo/Logo.jsx +32 -0
  75. package/src/customizations/@eeacms/volto-eea-design-system/ui/Logo/marine_logo.svg +63 -0
  76. package/src/customizations/volto/components/manage/Contents/ContentsBreadcrumbs.jsx +81 -0
  77. package/src/customizations/volto/components/manage/Contents/README.md +1 -0
  78. package/src/customizations/volto/components/manage/Toolbar/PersonalTools.jsx +205 -0
  79. package/src/customizations/volto/components/manage/Toolbar/Toolbar.jsx +624 -0
  80. package/src/customizations/volto/components/theme/Breadcrumbs/Breadcrumbs.jsx +49 -0
  81. package/src/customizations/volto/components/theme/Breadcrumbs/README.md +1 -0
  82. package/src/customizations/volto/components/theme/Header/Header.jsx +272 -0
  83. package/src/helpers/index.js +2 -0
  84. package/src/helpers/useCopyToClipboard.js +25 -0
  85. package/src/helpers/useOutsideClick.js +20 -0
  86. package/src/icons/arrow.svg +3 -0
  87. package/src/icons/basket.svg +3 -0
  88. package/src/icons/newspaper.svg +3 -0
  89. package/src/icons/popup.svg +3 -0
  90. package/src/icons/search.svg +3 -0
  91. package/src/icons/star-full.svg +3 -0
  92. package/src/icons/user.svg +3 -0
  93. package/src/index.js +466 -0
  94. package/src/reducers/breadcrumb/breadcrumb.js +59 -0
  95. package/src/reducers/index.js +2 -0
  96. package/src/reducers/localnavigation/localnavigation.js +69 -0
  97. package/src/search/config.js +98 -0
  98. package/src/search/facets.js +85 -0
  99. package/src/search/index.js +48 -0
  100. package/src/search/views.js +15 -0
  101. package/src/slate-styles.less +43 -0
  102. package/src/static/bise_logo.svg +1 -0
  103. package/src/static/cca_logo.svg +20 -0
  104. package/src/static/ec_logo.svg +343 -0
  105. package/src/static/ec_logo_white.svg +10 -0
  106. package/src/static/eea_logo.svg +14 -0
  107. package/src/static/footer-fishes.svg +21 -0
  108. package/src/static/forest_logo.svg +30 -0
  109. package/src/static/freshwater_logo.svg +12 -0
  110. package/src/static/marine_logo.svg +63 -0
  111. package/src/static/marine_logo_white.svg +44 -0
  112. package/src/utils.js +38 -0
  113. package/theme/assets/fonts/Poppins/Poppins-Bold.ttf +0 -0
  114. package/theme/assets/fonts/Poppins/Poppins-Bold.woff +0 -0
  115. package/theme/assets/fonts/Poppins/Poppins-Bold.woff2 +0 -0
  116. package/theme/assets/fonts/Poppins/Poppins-ExtraBold.ttf +0 -0
  117. package/theme/assets/fonts/Poppins/Poppins-Light.ttf +0 -0
  118. package/theme/assets/fonts/Poppins/Poppins-Light.woff +0 -0
  119. package/theme/assets/fonts/Poppins/Poppins-Light.woff2 +0 -0
  120. package/theme/assets/fonts/Poppins/Poppins-Regular.ttf +0 -0
  121. package/theme/assets/fonts/Poppins/Poppins-Regular.woff +0 -0
  122. package/theme/assets/fonts/Poppins/Poppins-Regular.woff2 +0 -0
  123. package/theme/assets/fonts/Poppins/Poppins-SemiBold.ttf +0 -0
  124. package/theme/assets/fonts/Poppins/Poppins-SemiBold.woff +0 -0
  125. package/theme/assets/fonts/Poppins/Poppins-SemiBold.woff2 +0 -0
  126. package/theme/assets/fonts/Roboto/Roboto-Light.ttf +0 -0
  127. package/theme/assets/fonts/Roboto/Roboto-Light.woff +0 -0
  128. package/theme/assets/fonts/Roboto/Roboto-Light.woff2 +0 -0
  129. package/theme/assets/fonts/Roboto/Roboto-Medium.ttf +0 -0
  130. package/theme/assets/fonts/Roboto/Roboto-Medium.woff +0 -0
  131. package/theme/assets/fonts/Roboto/Roboto-Medium.woff2 +0 -0
  132. package/theme/assets/fonts/Roboto/Roboto-Regular.ttf +0 -0
  133. package/theme/assets/fonts/Roboto/Roboto-Regular.woff +0 -0
  134. package/theme/assets/fonts/Roboto/Roboto-Regular.woff2 +0 -0
  135. package/theme/assets/images/Footer/ec_logo.svg +10 -0
  136. package/theme/assets/images/Header/climate-adapt-logo-1.svg +20 -0
  137. package/theme/assets/images/Header/climate-adapt-logo.svg +22 -0
  138. package/theme/assets/images/spinner.svg +1 -0
  139. package/theme/collections/table.variables +17 -0
  140. package/theme/elements/button.overrides +22 -0
  141. package/theme/extras/banner.variables +5 -0
  142. package/theme/extras/contextNavigation.overrides +60 -0
  143. package/theme/extras/contextNavigation.variables +32 -0
  144. package/theme/extras/footer.variables +6 -0
  145. package/theme/extras/header.overrides +20 -0
  146. package/theme/extras/header.variables +7 -0
  147. package/theme/extras/hero.overrides +4 -0
  148. package/theme/extras/inpageNavigation.variables +5 -0
  149. package/theme/extras/mixins.less +8 -0
  150. package/theme/globals/site.overrides +349 -0
  151. package/theme/globals/site.variables +997 -0
  152. package/theme/theme.config +136 -0
  153. package/theme/tokens/colors.less +9 -0
  154. package/theme/tokens/tokens.less +1 -0
@@ -0,0 +1,9 @@
1
+ const defaultBabel = require('@plone/volto/babel');
2
+
3
+ function applyDefault(api) {
4
+ const voltoBabel = defaultBabel(api);
5
+ voltoBabel.plugins.push('istanbul');
6
+ return voltoBabel;
7
+ }
8
+
9
+ module.exports = applyDefault;
package/.eslintrc.js ADDED
@@ -0,0 +1,65 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const projectRootPath = fs.realpathSync(__dirname + '/../../../');
4
+
5
+ let voltoPath = path.join(projectRootPath, 'node_modules/@plone/volto');
6
+ let configFile;
7
+ if (fs.existsSync(`${projectRootPath}/tsconfig.json`))
8
+ configFile = `${projectRootPath}/tsconfig.json`;
9
+ else if (fs.existsSync(`${projectRootPath}/jsconfig.json`))
10
+ configFile = `${projectRootPath}/jsconfig.json`;
11
+
12
+ if (configFile) {
13
+ const jsConfig = require(configFile).compilerOptions;
14
+ const pathsConfig = jsConfig.paths;
15
+ if (pathsConfig['@plone/volto'])
16
+ voltoPath = `./${jsConfig.baseUrl}/${pathsConfig['@plone/volto'][0]}`;
17
+ }
18
+
19
+ const AddonConfigurationRegistry = require(`${voltoPath}/addon-registry.js`);
20
+ const reg = new AddonConfigurationRegistry(projectRootPath);
21
+
22
+ // Extends ESlint configuration for adding the aliases to `src` directories in Volto addons
23
+ const addonAliases = Object.keys(reg.packages).map((o) => [
24
+ o,
25
+ reg.packages[o].modulePath,
26
+ ]);
27
+
28
+ const addonExtenders = reg.getEslintExtenders().map((m) => require(m));
29
+
30
+ const defaultConfig = {
31
+ extends: `${voltoPath}/.eslintrc`,
32
+ settings: {
33
+ 'import/resolver': {
34
+ alias: {
35
+ map: [
36
+ ['@plone/volto', '@plone/volto/src'],
37
+ ['@plone/volto-slate', '@plone/volto/packages/volto-slate/src'],
38
+ ...addonAliases,
39
+ ['@package', `${__dirname}/src`],
40
+ ['@root', `${__dirname}/src`],
41
+ ['~', `${__dirname}/src`],
42
+ ],
43
+ extensions: ['.js', '.jsx', '.json'],
44
+ },
45
+ 'babel-plugin-root-import': {
46
+ rootPathSuffix: 'src',
47
+ },
48
+ },
49
+ },
50
+ rules: {
51
+ 'react/jsx-no-target-blank': [
52
+ 'error',
53
+ {
54
+ allowReferrer: true,
55
+ },
56
+ ],
57
+ }
58
+ };
59
+
60
+ const config = addonExtenders.reduce(
61
+ (acc, extender) => extender.modify(acc),
62
+ defaultConfig,
63
+ );
64
+
65
+ module.exports = config;
@@ -0,0 +1,2 @@
1
+ [ -n "$CI" ] && exit 0
2
+ yarn lint-staged
@@ -0,0 +1,17 @@
1
+ {
2
+ "npm": {
3
+ "publish": false
4
+ },
5
+ "git": {
6
+ "changelog": "npx auto-changelog --stdout --commit-limit false -u --template https://raw.githubusercontent.com/release-it/release-it/master/templates/changelog-compact.hbs",
7
+ "tagName": "${version}"
8
+ },
9
+ "github": {
10
+ "release": true,
11
+ "releaseName": "${version}",
12
+ "releaseNotes": "npx auto-changelog --stdout --commit-limit false -u --template https://raw.githubusercontent.com/release-it/release-it/master/templates/changelog-compact.hbs"
13
+ },
14
+ "hooks": {
15
+ "after:bump": "npx auto-changelog --commit-limit false -p"
16
+ }
17
+ }
package/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ ## 1.0.0
4
+
5
+ - Initial release
package/DEVELOP.md ADDED
@@ -0,0 +1,53 @@
1
+ # volto-marine-policy
2
+
3
+ ## Develop
4
+
5
+ Before starting make sure your development environment is properly set. See [Volto Developer Documentation](https://docs.voltocms.com/getting-started/install/)
6
+
7
+ 1. Make sure you have installed `yo`, `@plone/generator-volto` and `mrs-developer`
8
+
9
+ npm install -g yo @plone/generator-volto mrs-developer
10
+
11
+ 1. Create new volto app
12
+
13
+ yo @plone/volto my-volto-project --addon @eeacms/volto-marine-policy --skip-install
14
+ cd my-volto-project
15
+
16
+ 1. Add the following to `mrs.developer.json`:
17
+
18
+ {
19
+ "volto-marine-policy": {
20
+ "url": "https://github.com/eea/volto-marine-policy.git",
21
+ "package": "@eeacms/volto-marine-policy",
22
+ "branch": "develop",
23
+ "path": "src"
24
+ }
25
+ }
26
+
27
+ 1. Install
28
+
29
+ yarn develop
30
+ yarn
31
+
32
+ 1. Start backend
33
+
34
+ docker pull plone
35
+ docker run -d --name plone -p 8080:8080 -e SITE=Plone -e PROFILES="profile-plone.restapi:blocks" plone
36
+
37
+ ...wait for backend to setup and start - `Ready to handle requests`:
38
+
39
+ docker logs -f plone
40
+
41
+ ...you can also check http://localhost:8080/Plone
42
+
43
+ 1. Start frontend
44
+
45
+ yarn start
46
+
47
+ 1. Go to http://localhost:3000
48
+
49
+ 1. Happy hacking!
50
+
51
+ cd src/addons/volto-marine-policy/
52
+
53
+ n-template/
package/DEVELOP.md.tpl ADDED
@@ -0,0 +1,106 @@
1
+ # <%= name %>
2
+
3
+ ## Develop
4
+
5
+ 1. Make sure you have `docker` and `docker compose` installed and running on your machine:
6
+
7
+ ```Bash
8
+ git clone https://github.com/eea/<%= name %>.git
9
+ cd <%= name %>
10
+ git checkout -b bugfix-123456 develop
11
+ make
12
+ make start
13
+ ```
14
+
15
+ 1. Wait for `Volto started at 0.0.0.0:3000` meesage
16
+
17
+ 1. Go to http://localhost:3000
18
+
19
+ 1. Initialize git hooks
20
+
21
+ ```Bash
22
+ yarn prepare
23
+ ```
24
+
25
+ 1. Happy hacking!
26
+
27
+ ### Or add <%= addonName %> to your Volto project
28
+
29
+ Before starting make sure your development environment is properly set. See [Volto Developer Documentation](https://docs.voltocms.com/getting-started/install/)
30
+
31
+ 1. Make sure you have installed `yo`, `@plone/generator-volto` and `mrs-developer`
32
+
33
+ npm install -g yo @plone/generator-volto mrs-developer
34
+
35
+ 1. Create new volto app
36
+
37
+ yo @plone/volto my-volto-project --addon <%= addonName %> --skip-install
38
+ cd my-volto-project
39
+
40
+ 1. Add the following to `mrs.developer.json`:
41
+
42
+ {
43
+ "<%= name %>": {
44
+ "url": "https://github.com/eea/<%= name %>.git",
45
+ "package": "<%= addonName %>",
46
+ "branch": "develop",
47
+ "path": "src"
48
+ }
49
+ }
50
+
51
+ 1. Install
52
+
53
+ make develop
54
+ yarn
55
+
56
+ 1. Start backend
57
+
58
+ docker run --pull always -it --rm --name plone -p 8080:8080 -e SITE=Plone plone/plone-backend
59
+
60
+ ...wait for backend to setup and start - `Ready to handle requests`:
61
+
62
+ ...you can also check http://localhost:8080/Plone
63
+
64
+ 1. Start frontend
65
+
66
+ yarn start
67
+
68
+ 1. Go to http://localhost:3000
69
+
70
+ 1. Happy hacking!
71
+
72
+ cd src/addons/<%= name %>/
73
+
74
+ ## Cypress
75
+
76
+ To run cypress locally, first make sure you don't have any Volto/Plone running on ports `8080` and `3000`.
77
+
78
+ You don't have to be in a `clean-volto-project`, you can be in any Volto Frontend
79
+ project where you added `<%= name %>` to `mrs.developer.json`
80
+
81
+ Go to:
82
+
83
+ ```BASH
84
+ cd src/addons/<%= name %>/
85
+ ```
86
+
87
+ Start:
88
+
89
+ ```Bash
90
+ make
91
+ make start
92
+ ```
93
+
94
+ This will build and start with Docker a clean `Plone backend` and `Volto Frontend` with `<%= name %>` block installed.
95
+
96
+ Open Cypress Interface:
97
+
98
+ ```Bash
99
+ make cypress-open
100
+ ```
101
+
102
+ Or run it:
103
+
104
+ ```Bash
105
+ make cypress-run
106
+ ```
@@ -0,0 +1,416 @@
1
+ pipeline {
2
+ tools {
3
+ jdk 'Java17'
4
+ }
5
+ agent {
6
+ node { label 'docker-host' }
7
+ }
8
+
9
+ environment {
10
+ GIT_NAME = "<%= name %>"
11
+ NAMESPACE = "@eeacms"
12
+ SONARQUBE_TAGS = "volto.eea.europa.eu"
13
+ DEPENDENCIES = ""
14
+ BACKEND_PROFILES = "eea.kitkat:testing"
15
+ BACKEND_ADDONS = ""
16
+ VOLTO = "17"
17
+ VOLTO16_BREAKING_CHANGES = "no"
18
+ IMAGE_NAME = BUILD_TAG.toLowerCase()
19
+ }
20
+
21
+ stages {
22
+ stage('Release') {
23
+ when {
24
+ allOf {
25
+ environment name: 'CHANGE_ID', value: ''
26
+ branch 'master'
27
+ }
28
+ }
29
+ steps {
30
+ node(label: 'docker') {
31
+ withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN'), string(credentialsId: 'eea-jenkins-npm-token', variable: 'NPM_TOKEN')]) {
32
+ 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'''
33
+ }
34
+ }
35
+ }
36
+ }
37
+
38
+ stage('Check if testing needed') {
39
+ when {
40
+ allOf {
41
+ not { branch 'master' }
42
+ not { branch 'develop' }
43
+ environment name: 'CHANGE_ID', value: ''
44
+ }
45
+ }
46
+ steps {
47
+ script {
48
+ checkout scm
49
+ withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN')]) {
50
+ 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
51
+
52
+ if (check_result == 0) {
53
+ env.SKIP_TESTS = 'yes'
54
+ }
55
+ }
56
+ }
57
+ }
58
+ }
59
+
60
+ stage('Testing') {
61
+ when {
62
+ anyOf {
63
+ allOf {
64
+ not { environment name: 'CHANGE_ID', value: '' }
65
+ environment name: 'CHANGE_TARGET', value: 'develop'
66
+ }
67
+ allOf {
68
+ environment name: 'CHANGE_ID', value: ''
69
+ anyOf {
70
+ not { changelog '.*^Automated release [0-9\\.]+$' }
71
+ branch 'master'
72
+ }
73
+ }
74
+ }
75
+ }
76
+ parallel {
77
+
78
+ stage('Volto 17') {
79
+ agent { node { label 'docker-1.13'} }
80
+ stages {
81
+ stage('Build test image') {
82
+ steps {
83
+ 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'''
84
+ }
85
+ }
86
+
87
+ stage('Fix code') {
88
+ when {
89
+ environment name: 'CHANGE_ID', value: ''
90
+ not { branch 'master' }
91
+ }
92
+ steps {
93
+ script {
94
+ 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)
95
+ sh '''docker cp $IMAGE_NAME-fix:/app/src/addons/$GIT_NAME/src .'''
96
+ sh '''docker rm -v $IMAGE_NAME-fix'''
97
+ FOUND_FIX = sh(script: '''git diff | wc -l''', returnStdout: true).trim()
98
+
99
+ if (FOUND_FIX != '0') {
100
+ withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN')]) {
101
+ sh '''sed -i "s|url = .*|url = https://eea-jenkins:$GITHUB_TOKEN@github.com/eea/$GIT_NAME.git|" .git/config'''
102
+ }
103
+ sh '''git fetch origin $GIT_BRANCH:$GIT_BRANCH'''
104
+ sh '''git checkout $GIT_BRANCH'''
105
+ sh '''git add src/'''
106
+ sh '''git commit -m "style: Automated code fix" '''
107
+ sh '''git push --set-upstream origin $GIT_BRANCH'''
108
+ sh '''exit 1'''
109
+ }
110
+ }
111
+ }
112
+ }
113
+
114
+ stage('ES lint') {
115
+ when { environment name: 'SKIP_TESTS', value: '' }
116
+ steps {
117
+ sh '''docker run --rm --name="$IMAGE_NAME-eslint" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend lint'''
118
+ }
119
+ }
120
+
121
+ stage('Style lint') {
122
+ when { environment name: 'SKIP_TESTS', value: '' }
123
+ steps {
124
+ sh '''docker run --rm --name="$IMAGE_NAME-stylelint" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend stylelint'''
125
+ }
126
+ }
127
+
128
+ stage('Prettier') {
129
+ when { environment name: 'SKIP_TESTS', value: '' }
130
+ steps {
131
+ sh '''docker run --rm --name="$IMAGE_NAME-prettier" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend prettier'''
132
+ }
133
+ }
134
+ stage('Unit tests') {
135
+ when { environment name: 'SKIP_TESTS', value: '' }
136
+ steps {
137
+ script {
138
+ try {
139
+ sh '''docker run --name="$IMAGE_NAME-volto" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend test-ci'''
140
+ sh '''rm -rf xunit-reports'''
141
+ sh '''mkdir -p xunit-reports'''
142
+ sh '''docker cp $IMAGE_NAME-volto:/app/coverage xunit-reports/'''
143
+ sh '''docker cp $IMAGE_NAME-volto:/app/junit.xml xunit-reports/'''
144
+ publishHTML(target : [
145
+ allowMissing: false,
146
+ alwaysLinkToLastBuild: true,
147
+ keepAll: true,
148
+ reportDir: 'xunit-reports/coverage/lcov-report',
149
+ reportFiles: 'index.html',
150
+ reportName: 'UTCoverage',
151
+ reportTitles: 'Unit Tests Code Coverage'
152
+ ])
153
+ } finally {
154
+ catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') {
155
+ junit testResults: 'xunit-reports/junit.xml', allowEmptyResults: true
156
+ }
157
+ sh script: '''docker rm -v $IMAGE_NAME-volto''', returnStatus: true
158
+ }
159
+ }
160
+ }
161
+ }
162
+
163
+ stage('Integration tests') {
164
+ when { environment name: 'SKIP_TESTS', value: '' }
165
+ steps {
166
+ script {
167
+ try {
168
+ 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'''
169
+ sh '''docker run -d --shm-size=4g --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'''
170
+ frontend = sh script:'''docker exec --workdir=/app/src/addons/${GIT_NAME} $IMAGE_NAME-cypress make check-ci''', returnStatus: true
171
+ if ( frontend != 0 ) {
172
+ sh '''docker logs $IMAGE_NAME-cypress; exit 1'''
173
+ }
174
+
175
+ sh '''timeout -s 9 1800 docker exec --workdir=/app/src/addons/${GIT_NAME} $IMAGE_NAME-cypress make cypress-ci'''
176
+ } finally {
177
+ try {
178
+ if ( frontend == 0 ) {
179
+ sh '''rm -rf cypress-videos cypress-results cypress-coverage cypress-screenshots'''
180
+ sh '''mkdir -p cypress-videos cypress-results cypress-coverage cypress-screenshots'''
181
+ videos = sh script: '''docker cp $IMAGE_NAME-cypress:/app/src/addons/$GIT_NAME/cypress/videos cypress-videos/''', returnStatus: true
182
+ sh '''docker cp $IMAGE_NAME-cypress:/app/src/addons/$GIT_NAME/cypress/reports cypress-results/'''
183
+ screenshots = sh script: '''docker cp $IMAGE_NAME-cypress:/app/src/addons/$GIT_NAME/cypress/screenshots cypress-screenshots''', returnStatus: true
184
+
185
+ archiveArtifacts artifacts: 'cypress-screenshots/**', fingerprint: true, allowEmptyArchive: true
186
+
187
+ coverage = sh script: '''docker cp $IMAGE_NAME-cypress:/app/src/addons/$GIT_NAME/coverage cypress-coverage''', returnStatus: true
188
+
189
+ if ( coverage == 0 ) {
190
+ publishHTML(target : [allowMissing: false,
191
+ alwaysLinkToLastBuild: true,
192
+ keepAll: true,
193
+ reportDir: 'cypress-coverage/coverage/lcov-report',
194
+ reportFiles: 'index.html',
195
+ reportName: 'CypressCoverage',
196
+ reportTitles: 'Integration Tests Code Coverage'])
197
+ }
198
+ if ( videos == 0 ) {
199
+ 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'''
200
+ archiveArtifacts artifacts: 'cypress-videos/**/*.mp4', fingerprint: true, allowEmptyArchive: true
201
+ }
202
+ }
203
+ } finally {
204
+ catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') {
205
+ junit testResults: 'cypress-results/**/*.xml', allowEmptyResults: true
206
+ }
207
+ catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') {
208
+ sh '''docker logs $IMAGE_NAME-cypress'''
209
+ }
210
+ sh script: "docker stop $IMAGE_NAME-cypress", returnStatus: true
211
+ sh script: "docker stop $IMAGE_NAME-plone", returnStatus: true
212
+ sh script: "docker rm -v $IMAGE_NAME-plone", returnStatus: true
213
+ sh script: "docker rm -v $IMAGE_NAME-cypress", returnStatus: true
214
+ }
215
+ }
216
+ }
217
+ }
218
+ }
219
+
220
+ stage('Report to SonarQube') {
221
+ when {
222
+ anyOf {
223
+ allOf {
224
+ not { environment name: 'CHANGE_ID', value: '' }
225
+ environment name: 'CHANGE_TARGET', value: 'develop'
226
+ environment name: 'SKIP_TESTS', value: ''
227
+ }
228
+ allOf {
229
+ environment name: 'CHANGE_ID', value: ''
230
+ environment name: 'SKIP_TESTS', value: ''
231
+ anyOf {
232
+ allOf {
233
+ branch 'develop'
234
+ not { changelog '.*^Automated release [0-9\\.]+$' }
235
+ }
236
+ branch 'master'
237
+ }
238
+ }
239
+ }
240
+ }
241
+ steps {
242
+ script {
243
+ def scannerHome = tool 'SonarQubeScanner'
244
+ def nodeJS = tool 'NodeJS'
245
+ withSonarQubeEnv('Sonarqube') {
246
+ sh '''sed -i "s#/app/src/addons/${GIT_NAME}/##g" xunit-reports/coverage/lcov.info'''
247
+ sh '''sed -i "s#src/addons/${GIT_NAME}/##g" xunit-reports/coverage/lcov.info'''
248
+ 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"
249
+ 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'''
250
+ }
251
+ }
252
+ }
253
+ }
254
+
255
+
256
+ }
257
+ }
258
+
259
+ stage('Volto 16') {
260
+ agent { node { label 'integration'} }
261
+ when {
262
+ environment name: 'SKIP_TESTS', value: ''
263
+ not { environment name: 'VOLTO16_BREAKING_CHANGES', value: 'yes' }
264
+ }
265
+ stages {
266
+ stage('Build test image') {
267
+ steps {
268
+ sh '''docker build --pull --build-arg="VOLTO_VERSION=16" --build-arg="ADDON_NAME=$NAMESPACE/$GIT_NAME" --build-arg="ADDON_PATH=$GIT_NAME" . -t $IMAGE_NAME-frontend16'''
269
+ }
270
+ }
271
+
272
+ stage('Unit tests Volto 16') {
273
+ steps {
274
+ script {
275
+ try {
276
+ sh '''docker run --name="$IMAGE_NAME-volto16" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend16 test-ci'''
277
+ sh '''rm -rf xunit-reports16'''
278
+ sh '''mkdir -p xunit-reports16'''
279
+ sh '''docker cp $IMAGE_NAME-volto16:/app/junit.xml xunit-reports16/'''
280
+ } finally {
281
+ catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') {
282
+ junit testResults: 'xunit-reports16/junit.xml', allowEmptyResults: true
283
+ }
284
+ sh script: '''docker rm -v $IMAGE_NAME-volto16''', returnStatus: true
285
+ }
286
+ }
287
+ }
288
+ }
289
+
290
+ stage('Integration tests Volto 16') {
291
+ steps {
292
+ script {
293
+ try {
294
+ sh '''docker run --pull always --rm -d --name="$IMAGE_NAME-plone16" -e SITE="Plone" -e PROFILES="$BACKEND_PROFILES" -e ADDONS="$BACKEND_ADDONS" eeacms/plone-backend'''
295
+ sh '''docker run -d --shm-size=4g --link $IMAGE_NAME-plone16:plone --name="$IMAGE_NAME-cypress16" -e "RAZZLE_INTERNAL_API_PATH=http://plone:8080/Plone" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend16 start-ci'''
296
+ frontend = sh script:'''docker exec --workdir=/app/src/addons/${GIT_NAME} $IMAGE_NAME-cypress16 make check-ci''', returnStatus: true
297
+ if ( frontend != 0 ) {
298
+ sh '''docker logs $IMAGE_NAME-cypress16; exit 1'''
299
+ }
300
+ sh '''timeout -s 9 1800 docker exec --workdir=/app/src/addons/${GIT_NAME} $IMAGE_NAME-cypress16 make cypress-ci'''
301
+ } finally {
302
+ try {
303
+ if ( frontend == 0 ) {
304
+ sh '''rm -rf cypress-videos16 cypress-results16 cypress-coverage16 cypress-screenshots16'''
305
+ sh '''mkdir -p cypress-videos16 cypress-results16 cypress-coverage16 cypress-screenshots16'''
306
+ videos = sh script: '''docker cp $IMAGE_NAME-cypress16:/app/src/addons/$GIT_NAME/cypress/videos cypress-videos16/''', returnStatus: true
307
+ sh '''docker cp $IMAGE_NAME-cypress16:/app/src/addons/$GIT_NAME/cypress/reports cypress-results16/'''
308
+ screenshots = sh script: '''docker cp $IMAGE_NAME-cypress16:/app/src/addons/$GIT_NAME/cypress/screenshots cypress-screenshots16''', returnStatus: true
309
+
310
+ archiveArtifacts artifacts: 'cypress-screenshots16/**', fingerprint: true, allowEmptyArchive: true
311
+
312
+ if ( videos == 0 ) {
313
+ sh '''for file in $(find cypress-results16 -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-videos16/videos/$testname.mp4; fi; done'''
314
+ archiveArtifacts artifacts: 'cypress-videos16/**/*.mp4', fingerprint: true, allowEmptyArchive: true
315
+ }
316
+ }
317
+ } finally {
318
+ catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') {
319
+ junit testResults: 'cypress-results16/**/*.xml', allowEmptyResults: true
320
+ }
321
+ catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') {
322
+ sh '''docker logs $IMAGE_NAME-cypress16'''
323
+ }
324
+ sh script: "docker stop $IMAGE_NAME-cypress16", returnStatus: true
325
+ sh script: "docker stop $IMAGE_NAME-plone16", returnStatus: true
326
+ sh script: "docker rm -v $IMAGE_NAME-plone16", returnStatus: true
327
+ sh script: "docker rm -v $IMAGE_NAME-cypress16", returnStatus: true
328
+ }
329
+ }
330
+ }
331
+ }
332
+ }
333
+
334
+ }
335
+ }
336
+ }
337
+ post {
338
+ always {
339
+ sh script: "docker rmi $IMAGE_NAME-frontend", returnStatus: true
340
+ sh script: "docker rmi $IMAGE_NAME-frontend16", returnStatus: true
341
+ }
342
+ }
343
+ }
344
+
345
+
346
+ stage('SonarQube compare to master') {
347
+ when {
348
+ anyOf {
349
+ allOf {
350
+ not { environment name: 'CHANGE_ID', value: '' }
351
+ environment name: 'CHANGE_TARGET', value: 'develop'
352
+ environment name: 'SKIP_TESTS', value: ''
353
+ }
354
+ allOf {
355
+ environment name: 'SKIP_TESTS', value: ''
356
+ environment name: 'CHANGE_ID', value: ''
357
+ branch 'develop'
358
+ not { changelog '.*^Automated release [0-9\\.]+$' }
359
+ }
360
+ }
361
+ }
362
+ steps {
363
+ script {
364
+ sh '''echo "Error" > checkresult.txt'''
365
+ catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
366
+ 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'''
367
+ }
368
+
369
+ 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',
370
+ text: readFile(file: 'checkresult.txt'), conclusion: "${currentBuild.currentResult}",
371
+ detailsURL: "${env.BUILD_URL}display/redirect"
372
+ }
373
+ }
374
+ }
375
+
376
+ stage('Pull Request') {
377
+ when {
378
+ not {
379
+ environment name: 'CHANGE_ID', value: ''
380
+ }
381
+ environment name: 'CHANGE_TARGET', value: 'master'
382
+ }
383
+ steps {
384
+ script {
385
+ if (env.CHANGE_BRANCH != 'develop') {
386
+ error 'Pipeline aborted due to PR not made from develop branch'
387
+ }
388
+ withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN')]) {
389
+ 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'''
390
+ }
391
+ }
392
+ }
393
+ }
394
+ }
395
+
396
+ post {
397
+ always {
398
+ cleanWs(cleanWhenAborted: true, cleanWhenFailure: true, cleanWhenNotBuilt: true, cleanWhenSuccess: true, cleanWhenUnstable: true, deleteDirs: true)
399
+ }
400
+ changed {
401
+ script {
402
+ def details = """<h1>${env.JOB_NAME} - Build #${env.BUILD_NUMBER} - ${currentBuild.currentResult}</h1>
403
+ <p>Check console output at <a href="${env.BUILD_URL}/display/redirect">${env.JOB_BASE_NAME} - #${env.BUILD_NUMBER}</a></p>
404
+ """
405
+ emailext(
406
+ subject: '$DEFAULT_SUBJECT',
407
+ body: details,
408
+ attachLog: true,
409
+ compressLog: true,
410
+ recipientProviders: [[$class: 'DevelopersRecipientProvider'], [$class: 'CulpritsRecipientProvider']]
411
+ )
412
+ }
413
+ }
414
+ }
415
+ }
416
+