Skip to content

Commit b19f948

Browse files
authored
Merge pull request #14 from eea/develop
Release
2 parents f4a359c + e0d8d07 commit b19f948

24 files changed

Lines changed: 335 additions & 251 deletions

.travis.yml

Lines changed: 0 additions & 49 deletions
This file was deleted.

Jenkinsfile

Lines changed: 88 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,34 @@ pipeline {
2828
}
2929
},
3030

31-
"PEP8": {
31+
"Ruff": {
3232
node(label: 'docker') {
3333
script {
34-
sh '''docker run -i --rm --name="$BUILD_TAG-pep8" -e GIT_SRC="https://github.com/eea/$GIT_NAME.git" -e GIT_NAME="$GIT_NAME" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" eeacms/pep8'''
35-
}
36-
}
37-
},
38-
39-
"PyLint": {
40-
node(label: 'docker') {
41-
script {
42-
sh '''docker run -i --rm --name="$BUILD_TAG-pylint" -e GIT_SRC="https://github.com/eea/$GIT_NAME.git" -e GIT_NAME="$GIT_NAME" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" eeacms/pylint'''
34+
if (!(env.BRANCH_NAME != "master" && (env.CHANGE_ID == null || env.CHANGE_ID == ''))) {
35+
return
36+
}
37+
checkout scm
38+
fix_result = sh(script: '''docker run --pull=always --name="$BUILD_TAG-ruff-fix" -e GIT_SRC="https://github.com/eea/$GIT_NAME.git" -e GIT_NAME="$GIT_NAME" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" eeacms/ruff format''', returnStatus: true)
39+
sh '''docker cp $BUILD_TAG-ruff-fix:/code/$GIT_NAME .'''
40+
sh '''cp -rf eea.website.policy/* .'''
41+
sh '''rm -rf eea.website.policy'''
42+
sh '''docker rm -v $BUILD_TAG-ruff-fix'''
43+
FOUND_FIX = sh(script: '''git diff --name-only '*.py' | wc -l''', returnStdout: true).trim()
44+
45+
if (FOUND_FIX != '0') {
46+
withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN')]) {
47+
sh '''sed -i "s|url = .*|url = https://eea-jenkins:$GITHUB_TOKEN@github.com/eea/$GIT_NAME.git|" .git/config'''
48+
}
49+
sh '''git fetch origin $GIT_BRANCH:$GIT_BRANCH'''
50+
sh '''git checkout $GIT_BRANCH'''
51+
sh '''git add -- '*.py' '''
52+
sh '''git commit -m "style: Automated code fix" '''
53+
sh '''git push --set-upstream origin $GIT_BRANCH'''
54+
sh '''exit 1'''
55+
}
4356
}
4457
}
4558
}
46-
4759
)
4860
}
4961
}
@@ -64,9 +76,32 @@ pipeline {
6476
}
6577
},
6678

67-
"PyFlakes": {
79+
"Ruff": {
6880
node(label: 'docker') {
69-
sh '''docker run -i --rm --name="$BUILD_TAG-pyflakes" -e GIT_SRC="https://github.com/eea/$GIT_NAME.git" -e GIT_NAME="$GIT_NAME" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" eeacms/pyflakes'''
81+
script {
82+
if (!(env.BRANCH_NAME != "master" && (env.CHANGE_ID == null || env.CHANGE_ID == ''))) {
83+
return
84+
}
85+
checkout scm
86+
fix_result = sh(script: '''docker run --pull=always --name="$BUILD_TAG-ruff-fix" -e GIT_SRC="https://github.com/eea/$GIT_NAME.git" -e GIT_NAME="$GIT_NAME" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" eeacms/ruff check''', returnStatus: true)
87+
sh '''docker cp $BUILD_TAG-ruff-fix:/code/$GIT_NAME .'''
88+
sh '''cp -rf eea.website.policy/* .'''
89+
sh '''rm -rf eea.website.policy'''
90+
sh '''docker rm -v $BUILD_TAG-ruff-fix'''
91+
FOUND_FIX = sh(script: '''git diff --name-only '*.py' | wc -l''', returnStdout: true).trim()
92+
93+
if (FOUND_FIX != '0') {
94+
withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN')]) {
95+
sh '''sed -i "s|url = .*|url = https://eea-jenkins:$GITHUB_TOKEN@github.com/eea/$GIT_NAME.git|" .git/config'''
96+
}
97+
sh '''git fetch origin $GIT_BRANCH:$GIT_BRANCH'''
98+
sh '''git checkout $GIT_BRANCH'''
99+
sh '''git add -- '*.py' '''
100+
sh '''git commit -m "lint: Automated code fix" '''
101+
sh '''git push --set-upstream origin $GIT_BRANCH'''
102+
sh '''exit 1'''
103+
}
104+
}
70105
}
71106
},
72107

@@ -79,56 +114,46 @@ pipeline {
79114
}
80115
}
81116

82-
// stage('Tests') {
83-
// steps {
84-
// parallel(
85-
// "Plone 5": {
86-
// node(label: 'docker') {
87-
// sh '''docker run -i --rm --name="$BUILD_TAG-plone5" -e GIT_BRANCH="$BRANCH_NAME" -e ADDONS="$GIT_NAME" -e DEVELOP="src/$GIT_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" eeacms/plone-test:5-python3 -v -vv -s $GIT_NAME'''
88-
// }
89-
// },
90-
91-
// // "Plone 6": {
92-
// // node(label: 'docker') {
93-
// // script {
94-
// // checkout scm
95-
// // sh '''docker run -i --rm --name="$BUILD_TAG-plone6" -v $(pwd):/app/src/$GIT_NAME -e ADDONS="/app/src/$GIT_NAME[test]" -e DEVELOP="/app/src/$GIT_NAME" eeacms/eea-website-backend bin/zope-testrunner --auto-color --auto-progress --test-path /app/src/$GIT_NAME'''
96-
// // }
97-
// // }
98-
// // }
99-
// )
100-
// }
101-
// }
102-
103-
// stage('Report to SonarQube') {
104-
// when {
105-
// allOf {
106-
// environment name: 'CHANGE_ID', value: ''
107-
// }
108-
// }
109-
// steps {
110-
// node(label: 'swarm') {
111-
// script{
112-
// checkout scm
113-
// // dir("xunit-reports") {
114-
// // unstash "xunit-reports"
115-
// // }
116-
// // unstash "coverage.xml"
117-
// // dir('xunit-functional') {
118-
// // unstash "xunit-functional"
119-
// // }
120-
// def scannerHome = tool 'SonarQubeScanner';
121-
// def nodeJS = tool 'NodeJS11';
122-
// withSonarQubeEnv('Sonarqube') {
123-
// // sh '''sed -i "s|/plone/instance/src/$GIT_NAME|$(pwd)|g" coverage.xml'''
124-
// // sh '''find xunit-functional -type f -exec mv {} xunit-reports/ ";"'''
125-
// sh "export PATH=$PATH:${scannerHome}/bin:${nodeJS}/bin; sonar-scanner -Dsonar.python.xunit.skipDetails=true -Dsonar.python.xunit.reportPath=xunit-reports/*.xml -Dsonar.python.coverage.reportPath=coverage.xml -Dsonar.sources=./eea -Dsonar.projectKey=$GIT_NAME-$BRANCH_NAME -Dsonar.projectVersion=$BRANCH_NAME-$BUILD_NUMBER"
126-
// 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'''
127-
// }
128-
// }
129-
// }
130-
// }
131-
// }
117+
stage('Tests') {
118+
steps {
119+
parallel(
120+
"Plone6 & Python3": {
121+
node(label: 'docker') {
122+
sh '''docker run --pull="always" -i --name="$BUILD_TAG-tests" -e GIT_NAME="$GIT_NAME" -e GIT_BRANCH="$BRANCH_NAME" -e DEVELOP="src/$GIT_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" eeacms/plone-test:6'''
123+
sh '''docker cp $BUILD_TAG-tests:/app/coverage ./coverage'''
124+
sh '''docker rm -v $BUILD_TAG-tests'''
125+
stash includes: 'coverage/**', name: 'coverage'
126+
}
127+
}
128+
)
129+
}
130+
}
131+
132+
stage('Report to SonarQube') {
133+
when {
134+
allOf {
135+
environment name: 'CHANGE_ID', value: ''
136+
}
137+
}
138+
steps {
139+
node(label: 'swarm') {
140+
script {
141+
checkout scm
142+
unstash 'coverage'
143+
junit 'coverage/junit-results/testreports/*.xml'
144+
def scannerHome = tool 'SonarQubeScanner';
145+
def nodeJS = tool 'NodeJS11';
146+
sh "sed -i 's|<source>/app</source>|<source>.</source>|g' coverage/coverage.xml"
147+
sh "sed -i \"s|filename=\\\"src/$GIT_NAME/|filename=\\\"|g\" coverage/coverage.xml"
148+
sh "sed -i \"s|package name=\\\"src\\.$GIT_NAME|package name=\\\"|g\" coverage/coverage.xml"
149+
withSonarQubeEnv('Sonarqube') {
150+
sh "export PATH=$PATH:${scannerHome}/bin:${nodeJS}/bin; sonar-scanner -Dsonar.python.xunit.skipDetails=true -Dsonar.python.xunit.reportPath=coverage/junit-results/testreports/*.xml -Dsonar.python.coverage.reportPaths=coverage/coverage.xml -Dsonar.sources=./eea -Dsonar.exclusions=**/tests/**,**/setup.py -Dsonar.projectKey=$GIT_NAME-$BRANCH_NAME -Dsonar.projectVersion=$BRANCH_NAME-$BUILD_NUMBER"
151+
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'''
152+
}
153+
}
154+
}
155+
}
156+
}
132157

133158
stage('Pull Request') {
134159
when {

docs/HISTORY.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
Changelog
22
=========
33

4+
4.1 - (2025-11-19)
5+
---------------------------
6+
* Change: Replace Python linting to ruff
7+
[mihaidobrescu1111 = refs #286821]
8+
* Change: Add plone6 tests
9+
[mihaidobrescu1111 = refs #293593]
10+
411
4.0 - (2024-05-20)
512
---------------------------
613
* Change: Upgrade step to Volto 17 teaserGrid to gridBlock

eea/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# -*- coding: utf-8 -*-
2-
""" Init """
3-
__import__('pkg_resources').declare_namespace(__name__)
2+
"""Init"""
3+
4+
__import__("pkg_resources").declare_namespace(__name__)

eea/website/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# -*- coding: utf-8 -*-
2-
""" Init """
3-
__import__('pkg_resources').declare_namespace(__name__)
2+
"""Init"""
3+
4+
__import__("pkg_resources").declare_namespace(__name__)

eea/website/policy/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
""" Main product initializer
2-
"""
1+
"""Main product initializer"""
2+
33
from zope.i18nmessageid.message import MessageFactory
4-
EEAMessageFactory = MessageFactory('eea')
4+
5+
EEAMessageFactory = MessageFactory("eea")
56

67

78
def initialize(context):
8-
"""Initializer called when used as a Zope 2 product.
9-
"""
9+
"""Initializer called when used as a Zope 2 product."""
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
""" Browser
2-
"""
1+
"""Browser"""

eea/website/policy/configure.zcml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
<include package="eea.dexterity.indicators" />
1010
<include package="eea.dexterity.themes" />
1111
<include package="eea.progress.workflow" />
12+
<include package="eea.progress.editing" />
13+
<include package="eea.api.dataconnector" />
14+
<include package="collective.volto.subsites" />
1215

1316
<include file="profiles.zcml" />
1417
<include package=".behaviors" />
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
""" i18n
2-
"""
1+
"""i18n"""

eea/website/policy/profiles/default/metadata.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<metadata>
3-
<version>4.0</version>
3+
<version>5.0</version>
44
<dependencies>
55
<dependency>profile-eea.website.policy:languages</dependency>
66
<dependency>profile-plone.app.multilingual:default</dependency>

0 commit comments

Comments
 (0)