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

Test all targets #34

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,17 @@ sudo: required
services:
- docker
before_install:
- openssl aes-256-cbc -K $encrypted_e0bbaa80af07_key -iv $encrypted_e0bbaa80af07_iv -in .travis/sshkey-mruby-cli-bins-travis.enc -out .travis/sshkey-mruby-cli-bins-travis -d
- sudo apt-get -qq update
install:
- sudo sh -c "curl -L https://github.com/docker/compose/releases/download/1.3.3/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose"
- sudo sh -c "curl -L https://github.com/docker/compose/releases/download/1.5.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose";
- sudo chmod +x /usr/local/bin/docker-compose
script:
- docker-compose run test
after_success:
- if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then
eval "$(ssh-agent -s)";
chmod 600 .travis/sshkey-mruby-cli-bins-travis;
ssh-add .travis/sshkey-mruby-cli-bins-travis;
rake local:send_bins_for_test;
fi
Binary file added .travis/sshkey-mruby-cli-bins-travis.enc
Binary file not shown.
44 changes: 44 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,50 @@ namespace :local do
require_relative 'mrblib/mruby-cli/version'
puts "mruby-cli #{MRubyCLI::Version::VERSION}"
end

def clone_mruby_cli_bins
Dir.chdir(APP_ROOT) do
`git clone [email protected]:toch/mruby-cli-bins.git`
return "#{APP_ROOT}/mruby-cli-bins" if $?.success?
end
nil
end

def detect_current_branch
return nil unless ENV.key? 'TRAVIS'
return ENV['TRAVIS_BRANCH'] if ENV['TRAVIS_PULL_REQUEST'] == "false"
nil
end

SUPPORTED_TARGET = {
"linux" => "x86_64-pc-linux-gnu",
"osx" => "x86_64-apple-darwin14",
"win" => "x86_64-w64-mingw32"
}

def push_mruby_cli_bins(dir, branch)
Dir.chdir(dir) do
`git checkout #{branch} || git checkout -b #{branch}`
SUPPORTED_TARGET.each do |target, dir|
bin_dir = "#{APP_ROOT}/mruby/build/#{dir}/bin"
bin_file = "mruby-cli"
bin_file << ".exe" if target == "win"
`cp #{bin_dir}/#{bin_file} #{dir}/bin/`
`git add #{dir}/bin/#{bin_file}`
end
`git commit -m "Travis Build #{ENV['TRAVIS_BUILD_NUMBER']} on branch #{branch}\n[MRUBY_CLI_SHA:#{ENV['TRAVIS_COMMIT']}]"`
`git push origin #{branch}`
end
end

desc "prepare the bins and send them to mruby-cli-bins"
task :send_bins_for_test do
mruby_cli_bins_dir = clone_mruby_cli_bins
abort "[send bins for test] impossible to clone mruby-cli-bins" unless mruby_cli_bins_dir
current_branch = detect_current_branch
abort "[send bins for test] impossible to detect current branch" unless current_branch
push_mruby_cli_bins(mruby_cli_bins_dir, current_branch)
end
end

def is_in_a_docker_container?
Expand Down