Skip to content

Commit

Permalink
Merge pull request #2 from eea/develop
Browse files Browse the repository at this point in the history
Develop #95020
  • Loading branch information
avoinea authored May 25, 2018
2 parents 4c1f98d + 4459e1d commit 9ddc25a
Show file tree
Hide file tree
Showing 6 changed files with 306 additions and 141 deletions.
158 changes: 73 additions & 85 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,159 +6,110 @@ pipeline {
}

stages {
stage('Tests') {

stage('Code') {
steps {
parallel(

"WWW": {
node(label: 'docker-1.13') {
script {
try {
sh '''docker run -i --name="$BUILD_TAG-www" -e GIT_NAME="$GIT_NAME" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" eeacms/www-devel /debug.sh bin/test -v -vv -s $GIT_NAME'''
} finally {
sh '''docker rm -v $BUILD_TAG-www'''
}
}
"ZPT Lint": {
node(label: 'docker') {
sh '''docker run -i --rm --name="$BUILD_TAG-zptlint" -e GIT_BRANCH="$BRANCH_NAME" -e ADDONS="$GIT_NAME" -e DEVELOP="src/$GIT_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" eeacms/plone-test:4 zptlint'''
}
},

"KGS": {
node(label: 'docker-1.13') {
script {
try {
sh '''docker run -i --name="$BUILD_TAG-kgs" -e GIT_NAME="$GIT_NAME" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" eeacms/kgs-devel /debug.sh bin/test --test-path /plone/instance/src/$GIT_NAME -v -vv -s $GIT_NAME'''
} finally {
sh '''docker rm -v $BUILD_TAG-kgs'''
}
}
"JS Lint": {
node(label: 'docker') {
sh '''docker run -i --rm --name="$BUILD_TAG-jslint" -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/jslint4java'''
}
},

"Plone4": {
node(label: 'docker-1.13') {
script {
try {
sh '''docker run -i --name="$BUILD_TAG-plone4" -e GIT_BRANCH="$BRANCH_NAME" -e ADDONS="$GIT_NAME" -e DEVELOP="src/$GIT_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" eeacms/plone-test:4 -v -vv -s $GIT_NAME'''
} finally {
sh '''docker rm -v $BUILD_TAG-plone4'''
}
}
"PyFlakes": {
node(label: 'docker') {
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'''
}
},

"i18n": {
node(label: 'docker') {
sh '''docker run -i --rm --name=$BUILD_TAG-i18n -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/i18ndude'''
}
}
)
}
}

stage('Code Analysis') {
stage('Tests') {
steps {
parallel(

"ZPT Lint": {
node(label: 'docker-1.13') {
script {
try {
sh '''docker run -i --name="$BUILD_TAG-zptlint" -e GIT_BRANCH="$BRANCH_NAME" -e ADDONS="$GIT_NAME" -e DEVELOP="src/$GIT_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" eeacms/plone-test:4 zptlint'''
} finally {
sh '''docker rm -v $BUILD_TAG-zptlint'''
}
}
}
},

"JS Lint": {
node(label: 'docker-1.13') {
script {
try {
sh '''docker run -i --name="$BUILD_TAG-jslint" -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/jslint4java'''
} finally {
sh '''docker rm -v $BUILD_TAG-jslint'''
}
}
"WWW": {
node(label: 'docker') {
sh '''docker run -i --rm --name="$BUILD_TAG-www" -e GIT_NAME="$GIT_NAME" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" eeacms/www-devel /debug.sh bin/test -v -vv -s $GIT_NAME'''
}
},

"PyFlakes": {
node(label: 'docker-1.13') {
script {
try {
sh '''docker run -i --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'''
} finally {
sh '''docker rm -v $BUILD_TAG-pyflakes'''
}
}
"KGS": {
node(label: 'docker') {
sh '''docker run -i --rm --name="$BUILD_TAG-kgs" -e GIT_NAME="$GIT_NAME" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" eeacms/kgs-devel /debug.sh bin/test --test-path /plone/instance/src/$GIT_NAME -v -vv -s $GIT_NAME'''
}
},

"i18n": {
node(label: 'docker-1.13') {
script {
try {
sh '''docker run -i --name=$BUILD_TAG-i18n -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/i18ndude'''
} finally {
sh '''docker rm -v $BUILD_TAG-i18n'''
}
}
"Plone4": {
node(label: 'docker') {
sh '''docker run -i --rm --name="$BUILD_TAG-plone4" -e GIT_BRANCH="$BRANCH_NAME" -e ADDONS="$GIT_NAME" -e DEVELOP="src/$GIT_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" eeacms/plone-test:4 -v -vv -s $GIT_NAME'''
}
}
)
}
}

stage('Code Syntax') {
stage('Cosmetics') {
steps {
parallel(

"JS Hint": {
node(label: 'docker-1.13') {
node(label: 'docker') {
script {
try {
sh '''docker run -i --name="$BUILD_TAG-jshint" -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/jshint'''
sh '''docker run -i --rm --name="$BUILD_TAG-jshint" -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/jshint'''
} catch (err) {
echo "Unstable: ${err}"
} finally {
sh '''docker rm -v $BUILD_TAG-jshint'''
}
}
}
},

"CSS Lint": {
node(label: 'docker-1.13') {
node(label: 'docker') {
script {
try {
sh '''docker run -i --name="$BUILD_TAG-csslint" -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/csslint'''
sh '''docker run -i --rm --name="$BUILD_TAG-csslint" -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/csslint'''
} catch (err) {
echo "Unstable: ${err}"
} finally {
sh '''docker rm -v $BUILD_TAG-csslint'''
}
}
}
},

"PEP8": {
node(label: 'docker-1.13') {
node(label: 'docker') {
script {
try {
sh '''docker run -i --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'''
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'''
} catch (err) {
echo "Unstable: ${err}"
} finally {
sh '''docker rm -v $BUILD_TAG-pep8'''
}
}
}
},

"PyLint": {
node(label: 'docker-1.13') {
node(label: 'docker') {
script {
try {
sh '''docker run -i --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'''
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'''
} catch (err) {
echo "Unstable: ${err}"
} finally {
sh '''docker rm -v $BUILD_TAG-pylint'''
}
}
}
Expand All @@ -168,6 +119,43 @@ pipeline {
}
}

stage('Pull Request') {
when {
not {
environment name: 'CHANGE_ID', value: ''
}
environment name: 'CHANGE_TARGET', value: 'master'
}
steps {
node(label: 'docker') {
script {
if ( env.CHANGE_BRANCH != "develop" && !( env.CHANGE_BRANCH.startsWith("hotfix")) ) {
error "Pipeline aborted due to PR not made from develop or hotfix branch"
}
withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN')]) {
sh '''docker run -i --rm --name="$BUILD_TAG-gitflow-pr" -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" eeacms/gitflow'''
}
}
}
}
}

stage('Release') {
when {
allOf {
environment name: 'CHANGE_ID', value: ''
branch 'master'
}
}
steps {
node(label: 'docker') {
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'eea-jenkins', usernameVariable: 'EGGREPO_USERNAME', passwordVariable: 'EGGREPO_PASSWORD'],string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN'),[$class: 'UsernamePasswordMultiBinding', credentialsId: 'pypi-jenkins', usernameVariable: 'PYPI_USERNAME', passwordVariable: 'PYPI_PASSWORD']]) {
sh '''docker run -i --rm --name="$BUILD_TAG-gitflow-master" -e GIT_BRANCH="$BRANCH_NAME" -e EGGREPO_USERNAME="$EGGREPO_USERNAME" -e EGGREPO_PASSWORD="$EGGREPO_PASSWORD" -e GIT_NAME="$GIT_NAME" -e PYPI_USERNAME="$PYPI_USERNAME" -e PYPI_PASSWORD="$PYPI_PASSWORD" -e GIT_ORG="$GIT_ORG" -e GIT_TOKEN="$GITHUB_TOKEN" eeacms/gitflow'''
}
}
}
}

}

post {
Expand Down
8 changes: 6 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
=========
EEA Cache
=========
.. image:: http://ci.eionet.europa.eu/job/eea/job/eea.cache/job/master/badge/icon
:target: http://ci.eionet.europa.eu/job/eea/job/eea.cache/job/master/display/redirect
.. image:: https://ci.eionet.europa.eu/buildStatus/icon?job=eea/eea.cache/develop
:target: https://ci.eionet.europa.eu/job/eea/job/eea.cache/job/develop/display/redirect
:alt: Develop
.. image:: https://ci.eionet.europa.eu/buildStatus/icon?job=eea/eea.cache/master
:target: https://ci.eionet.europa.eu/job/eea/job/eea.cache/job/master/display/redirect
:alt: Master

Introduction
============
Expand Down
17 changes: 16 additions & 1 deletion docs/HISTORY.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
Changelog
=========

8.1.dev0 - (unreleased)
8.2 - (2018-05-24)
-----------------------
* Bug fix: Speed-up cache invalidation for backward-references
[avoinea refs #95020]
* Feature: replaced invalidate_cache method with a method that use eea.cache
[alecghica refs #95020]
* Feature: "Refresh this page" method redirect you back to the original context
[alecghica refs #95020]
* Feature: cache.settings if called in a context of a default view it will
also invalidate its parent
[alecghica refs #95020]
* Bug fix: fixed case under all invalidate methods when a broken relations
is present and None is found instead of an object
[alecghica refs #95020]

8.1 - (2017-12-12)
------------------
* Change: Replace eeacms/zptlint with eeacms/plone-test:4 zptlint
[avoinea refs #90415]

Expand Down
55 changes: 53 additions & 2 deletions eea/cache/browser/app/edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from z3c.form import form, button, interfaces, util
from plone.supermodel import model
from plone.autoform.form import AutoExtensibleForm
from Products.CMFCore.utils import getToolByName
from Products.statusmessages.interfaces import IStatusMessage
from eea.cache.interfaces import ICacheAware
from eea.cache.browser.interfaces import VARNISH
from eea.cache.config import EEAMessageFactory as _
Expand Down Expand Up @@ -43,6 +45,12 @@ class ISettings(model.Schema):
default=False
)

redirectURL = schema.URI(
title=_(u"Redirect URL"),
description=_(u"Redirect URL when request parameter is present."),
required=False
)


class SettingsBehavior(object):
""" Cache invalidation behaviour
Expand Down Expand Up @@ -166,12 +174,45 @@ def backRefs(self, value):
if value.get('memcache') and self.invalidate_memcache:
self.invalidate_memcache.backRefs()

@property
def redirectURL(self):
""" Redirect URL
"""
return ''

@redirectURL.setter
def redirectURL(self, value):
""" Redirect URL
"""
return


class SettingsForm(AutoExtensibleForm, form.EditForm):
""" Cache settings
"""
schema = ISettings

def updateWidgets(self):
""" Update widgets
"""
super(SettingsForm, self).updateWidgets()
self.widgets['redirectURL'].mode = interfaces.HIDDEN_MODE

def update(self):
""" Update form
"""
super(SettingsForm, self).update()
redirect_url = self.request.get('redirect', '')

if redirect_url:
for name, widget in self.widgets.items():
if name != 'redirectURL':
# Select everything by default
widget.items[0]['checked'] = True
else:
# Add the redirect URL
widget.value = redirect_url

def applyChanges(self, content, data):
""" Apply changes
"""
Expand Down Expand Up @@ -207,15 +248,25 @@ def invalidate(self, action):
""" Invalidate cache
"""
self.status = u""
msg_invalidated = _(u"Cache invalidated")
portal_url = getToolByName(self.context, 'portal_url')()
redirectURL = self.widgets['redirectURL'].value
data, errors = self.extractData()

if not redirectURL.startswith(portal_url):
redirectURL = ''

if errors:
self.status = self.formErrorsMessage
return

content = self.getContent()
changes = self.applyChanges(content, data)
if changes:
self.status = _(u"Cache invalidated")
if redirectURL and changes:
IStatusMessage(self.request).addStatusMessage(msg_invalidated,
type='info')
self.request.response.redirect(redirectURL)
elif changes:
self.status = msg_invalidated
else:
self.status = _(u"Nothing selected to invalidate")
Loading

0 comments on commit 9ddc25a

Please sign in to comment.