From 2e589d19cb847da39699bd21987ef1d7a2f92466 Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Tue, 14 Aug 2012 12:47:01 -0700 Subject: [PATCH] New job template for translation management. Add a new job template for translation management. Add two jobs for translation management. The first will will update transifex with the new .pot and .po files after every merge to a project. The second will commit the new .pot and .po files and submit for review once a day. Add puppet manifest for the slave that these jobs will be running on. Apply the template to nova. Change-Id: I5242f81bd6ff13d1ed8610ef9e3b39fd3dbd7301 Reviewed-on: https://review.openstack.org/11369 Reviewed-by: James E. Blair Approved: Monty Taylor Reviewed-by: Monty Taylor Tested-by: Jenkins --- manifests/site.pp | 7 +++ .../propose_translation_update.sh | 37 +++++++++++++++ .../upstream_translation_update.sh | 30 ++++++++++++ .../jenkins_job_builder/config/projects.yaml | 1 + .../config/translation-jobs.yaml | 47 +++++++++++++++++++ .../openstack_project/files/zuul/layout.yaml | 1 + .../manifests/translation_slave.pp | 23 +++++++++ .../templates/transifexrc.erb | 5 ++ 8 files changed, 151 insertions(+) create mode 100755 modules/jenkins/files/slave_scripts/propose_translation_update.sh create mode 100755 modules/jenkins/files/slave_scripts/upstream_translation_update.sh create mode 100644 modules/openstack_project/files/jenkins_job_builder/config/translation-jobs.yaml create mode 100644 modules/openstack_project/manifests/translation_slave.pp create mode 100644 modules/openstack_project/templates/transifexrc.erb diff --git a/manifests/site.pp b/manifests/site.pp index 578c85aeec..bdda1e1fed 100644 --- a/manifests/site.pp +++ b/manifests/site.pp @@ -141,6 +141,13 @@ node /^ci-backup-.*\.openstack\.org$/ { # Jenkins slaves: # +node 'tx.slave.openstack.org' { + class { 'openstack_project::translation_slave': + transifex_username => 'openstackjenkins', + transifex_password => hiera('transifex_password') + } +} + # Rollout cgroups to precise slaves. node /^precise.*\.slave\.openstack\.org$/ { include openstack_project::puppet_cron diff --git a/modules/jenkins/files/slave_scripts/propose_translation_update.sh b/modules/jenkins/files/slave_scripts/propose_translation_update.sh new file mode 100755 index 0000000000..6b6b9072dc --- /dev/null +++ b/modules/jenkins/files/slave_scripts/propose_translation_update.sh @@ -0,0 +1,37 @@ +#!/bin/bash -xe + +PROJECT=$1 + +git config user.name "OpenStack Jenkins" +git config user.email "jenkins@openstack.org" + +# See if there is an open change in the transifex/translations topic +# If so, amend the commit with new changes since then +previous=`ssh -p 29418 review.openstack.org gerrit query --current-patch-set status:open project:openstack/$PROJECT topic:transifex/translations | grep "^ number:" | awk '{print $2}'` +if [ "x${previous}" != "x" ] ; then + git review -d ${previous} + amend="--amend" +fi + +# initialize transifex client +tx init +tx set --auto-local -r ${PROJECT}.${PROJECT}-translations "${PROJECT}/locale//LC_MESSAGES/${PROJECT}.po" --source-lang en --source-file ${PROJECT}/locale/${PROJECT}.pot --execute + +# Pull all upstream translations +tx pull -a +# Update the .pot file +python setup.py extract_messages +# Use updated .pot file to update translations +python setup.py update_catalog +# Add all changed files to git +git add $PROJECT/locale/* + +if [ ! `git diff-index --quiet HEAD --` ] +then + # Commit and review + git commit ${amend} -m "Imported Translations from Transifex" + git review -t transifex/translations + + # Push changes to transifex + tx push -st +fi diff --git a/modules/jenkins/files/slave_scripts/upstream_translation_update.sh b/modules/jenkins/files/slave_scripts/upstream_translation_update.sh new file mode 100755 index 0000000000..17a3df64f8 --- /dev/null +++ b/modules/jenkins/files/slave_scripts/upstream_translation_update.sh @@ -0,0 +1,30 @@ +#!/bin/bash -xe + +PROJECT=$1 + +if [ ! `echo $ZUUL_REFNAME | grep master` ] +then + exit 0 +fi + +git config user.name "OpenStack Jenkins" +git config user.email "jenkins@openstack.org" + +# initialize transifex client +tx init +tx set --auto-local -r ${PROJECT}.${PROJECT}-translations "${PROJECT}/locale//LC_MESSAGES/${PROJECT}.po" --source-lang en --source-file ${PROJECT}/locale/${PROJECT}.pot --execute + +# Pull all upstream translations +tx pull -a +# Update the .pot file +python setup.py extract_messages +# Use updated .pot file to update translations +python setup.py update_catalog +# Add all changed files to git +git add $PROJECT/locale/* + +if [ ! `git diff-index --quiet HEAD --` ] +then + # Push changes to transifex + tx push -st +fi diff --git a/modules/openstack_project/files/jenkins_job_builder/config/projects.yaml b/modules/openstack_project/files/jenkins_job_builder/config/projects.yaml index 6b2ce5e28e..6efb6e27f8 100644 --- a/modules/openstack_project/files/jenkins_job_builder/config/projects.yaml +++ b/modules/openstack_project/files/jenkins_job_builder/config/projects.yaml @@ -199,6 +199,7 @@ - python-essex-bitrot-jobs - openstack-publish-jobs - gate-{name}-pylint + - translation-jobs - project: diff --git a/modules/openstack_project/files/jenkins_job_builder/config/translation-jobs.yaml b/modules/openstack_project/files/jenkins_job_builder/config/translation-jobs.yaml new file mode 100644 index 0000000000..6086db797a --- /dev/null +++ b/modules/openstack_project/files/jenkins_job_builder/config/translation-jobs.yaml @@ -0,0 +1,47 @@ +- job-template: + name: '{name}-upstream-translation-update' + concurrent: false + + triggers: + - zuul-post + + builders: + - gerrit-git-prep + - shell: | + #!/bin/bash -xe + /usr/local/jenkins/slave_scripts/upstream_translation_update.sh {name} + + publishers: + - console-log-post + + node: 'tx' + +- job-template: + name: '{name}-propose-translation-update' + concurrent: false + + triggers: + - timed: '@daily' + + builders: + - shell: | + #!/bin/bash -xe + /usr/local/jenkins/slave_scripts/propose_translation_update.sh {name} + + publishers: + - console-log-periodic + + scm: + - git: + url: 'git://github.com/{github-org}/{name}.git' + branches: + - 'origin/master' + + node: 'tx' + + +- job-group: + name: translation-jobs + jobs: + - '{name}-upstream-translation-update' + - '{name}-propose-translation-update' diff --git a/modules/openstack_project/files/zuul/layout.yaml b/modules/openstack_project/files/zuul/layout.yaml index 723944bcae..78e940dbf6 100644 --- a/modules/openstack_project/files/zuul/layout.yaml +++ b/modules/openstack_project/files/zuul/layout.yaml @@ -313,6 +313,7 @@ projects: - nova-tarball - nova-coverage - nova-docs + - nova-upstream-translation-update publish: - nova-tarball - nova-docs diff --git a/modules/openstack_project/manifests/translation_slave.pp b/modules/openstack_project/manifests/translation_slave.pp new file mode 100644 index 0000000000..ac71d2e250 --- /dev/null +++ b/modules/openstack_project/manifests/translation_slave.pp @@ -0,0 +1,23 @@ +class openstack_project::translation_slave ( + transifex_username = 'openstackci', + transifex_password +) { + + include openstack_project::slave + + package { ['transifex-client', 'Babel']: + ensure => latest, + provider => pip, + require => Class[pip] + } + + file { '/home/jenkins/.transifexrc': + owner => 'jenkins', + group => 'jenkins', + mode => 0600, + ensure => 'present', + content => template('openstack_project/transifexrc.erb'), + require => User['jenkins'], + } + +} diff --git a/modules/openstack_project/templates/transifexrc.erb b/modules/openstack_project/templates/transifexrc.erb new file mode 100644 index 0000000000..6166707331 --- /dev/null +++ b/modules/openstack_project/templates/transifexrc.erb @@ -0,0 +1,5 @@ +[https://www.transifex.com] +hostname = https://www.transifex.com +password = <%= transifex_password %> +token = +username = <%= transifex_username %>