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
Closed
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
8fa9cd9
Stub in transifex addon
074e51c
Merge remote-tracking branch 'origin/master' into db-implement-transi…
20f5276
Greatly simplify transifex addon, bump client version constraint
bd1af86
Account for missing config hash
f534e27
Merge config into defaults instead of relying on Hash#reverse_merge
70cb51a
Use env var defaults for the whole ~/.transifexrc file
856408b
Do not push translations by default
ee07285
Trying to get at the right config sub-part for transifex
4aea3c0
Rename transifex method for clarity
0ae4a45
Only run transifex integration on success
fe438d0
Collapse up transifex a bit, allow for disabling auto push
d270be3
Add logic for running tx push on specific branches & job number
3489a9f
Adjust hook methods for transifex integration
830e27e
Folding transifex operations, messaging more
40d9916
Seeing if `after_after_script` triggers for us
f29619c
Add more messaging around reasons for not pushing
2f6a282
Check the build number with a raw command separately
faf91fe
Merge remote-tracking branch 'origin/master' into db-implement-transi…
55c36b4
Merge remote-tracking branch 'origin/master' into db-implement-transi…
e5964f1
fixing pip due to virtualenv shenanigans
emmaaaaaaaaaaaa 5cd56b1
Auto-merged master into db-implement-transifex-addon on deployment.
emdantrim 925da8c
Removed condition check for matching job ID
beeb76e
Merge branch 'db-implement-transifex-addon' of github.com:travis-ci/t…
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This comment was marked as spam.
Sorry, something went wrong.