Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement transifex addon #400

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8fa9cd9
Stub in transifex addon
Mar 3, 2015
074e51c
Merge remote-tracking branch 'origin/master' into db-implement-transi…
Apr 13, 2015
20f5276
Greatly simplify transifex addon, bump client version constraint
Apr 13, 2015
bd1af86
Account for missing config hash
Apr 13, 2015
f534e27
Merge config into defaults instead of relying on Hash#reverse_merge
Apr 13, 2015
70cb51a
Use env var defaults for the whole ~/.transifexrc file
Apr 13, 2015
856408b
Do not push translations by default
Apr 13, 2015
ee07285
Trying to get at the right config sub-part for transifex
Apr 13, 2015
4aea3c0
Rename transifex method for clarity
Apr 13, 2015
0ae4a45
Only run transifex integration on success
Apr 13, 2015
fe438d0
Collapse up transifex a bit, allow for disabling auto push
Apr 13, 2015
d270be3
Add logic for running tx push on specific branches & job number
Apr 13, 2015
3489a9f
Adjust hook methods for transifex integration
Apr 13, 2015
830e27e
Folding transifex operations, messaging more
Apr 13, 2015
40d9916
Seeing if `after_after_script` triggers for us
Apr 13, 2015
f29619c
Add more messaging around reasons for not pushing
Apr 13, 2015
2f6a282
Check the build number with a raw command separately
Apr 13, 2015
faf91fe
Merge remote-tracking branch 'origin/master' into db-implement-transi…
Apr 17, 2015
55c36b4
Merge remote-tracking branch 'origin/master' into db-implement-transi…
Jun 1, 2015
e5964f1
fixing pip due to virtualenv shenanigans
emmaaaaaaaaaaaa Jun 2, 2015
5cd56b1
Auto-merged master into db-implement-transifex-addon on deployment.
emdantrim Jun 2, 2015
925da8c
Removed condition check for matching job ID
Jun 2, 2015
beeb76e
Merge branch 'db-implement-transifex-addon' of github.com:travis-ci/t…
Jun 2, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/travis/build/addons.rb
Expand Up @@ -10,6 +10,7 @@
require 'travis/build/addons/postgresql'
require 'travis/build/addons/sauce_connect'
require 'travis/build/addons/ssh_known_hosts'
require 'travis/build/addons/transifex'

module Travis
module Build
Expand Down Expand Up @@ -46,7 +47,8 @@ def run_stage?(addon, stage)
def addon(name, config)
const = self.class.const_get(name.to_s.camelize)
const.new(script, sh, data, config) if const && run_addon?(const)
rescue NameError
rescue NameError => e
warn e
end

def addon_config
Expand Down
83 changes: 83 additions & 0 deletions lib/travis/build/addons/transifex.rb
@@ -0,0 +1,83 @@
require 'travis/build/addons/base'

module Travis
module Build
class Addons
class Transifex < Base
CLIENT_VERSION = '>=0.11'
SUPER_USER_SAFE = true
DEFAULTS = {
hostname: 'https://www.transifex.com',
username: '',
password: '',
token: '',
auto_push: {
enabled: true,
job: 1,

This comment was marked as spam.

branches: %w(master)
}
}.freeze

def before_before_script
install
configure
end

def after_after_script
sh.if '$TRAVIS_TEST_RESULT = 0' do
sh.fold 'transifex.push' do
if tx_config[:auto_push][:enabled]
source_push
else
sh.echo 'Skipping push to Transifex', ansi: :yellow
end
end
end
end

private

def install
sh.fold 'transifex.install' do
sh.echo 'Installing Transifex Client (beta)', ansi: :yellow
sh.if '$VIRTUAL_ENV' do
sh.cmd "pip install 'transifex-client#{CLIENT_VERSION}'", echo: true
end
sh.else do
sh.cmd "pip install --user 'transifex-client#{CLIENT_VERSION}'", echo: true
end
sh.export 'PATH', '$HOME/.local/bin:$PATH', echo: true
end
end

def configure
sh.echo "Writing #{tx_rc_path}", ansi: :yellow
sh.cmd <<-EOF.gsub(/^ {14}/, ''), echo: false
echo "[${TX_HOSTNAME:-#{tx_config[:hostname]}}]
hostname = ${TX_HOSTNAME:-#{tx_config[:hostname]}}
username = ${TX_USERNAME:-#{tx_config[:username]}}
password = ${TX_PASSWORD:-#{tx_config[:password]}}
token = ${TX_TOKEN:-#{tx_config[:token]}}" > #{tx_rc_path}
EOF
end

def source_push
sh.if "$TRAVIS_BRANCH =~ '^(#{tx_config[:auto_push][:branches].join('|')})$'" do
sh.echo 'Pushing to Transifex', ansi: :yellow
sh.cmd 'tx push --source --no-interactive', echo: true
end
sh.else do
sh.echo "Not Pushing to Transifex for branch '$TRAVIS_BRANCH'", ansi: :yellow
end

def tx_config
@tx_config ||= DEFAULTS.deep_merge((config || {}).deep_symbolize_keys)
end

def tx_rc_path
@tx_rc_path ||= "#{Travis::Build::HOME_DIR}/.transifexrc"
end
end
end
end
end