From 0f9094901cc317d132706e63bb15b98808b864a5 Mon Sep 17 00:00:00 2001 From: Terence Lee Date: Wed, 6 Sep 2017 22:34:48 -0500 Subject: [PATCH] add files for CI binary distribution --- ruby/lib/helix_runtime/cli/bootstrap.rb | 12 +++++ .../helix_runtime/cli/templates/.appveyor.yml | 40 ++++++++++++++++ .../helix_runtime/cli/templates/.travis.yml | 47 +++++++++++++++++++ .../cli/templates/publish_to_rubygems.rb | 20 ++++++++ 4 files changed, 119 insertions(+) create mode 100644 ruby/lib/helix_runtime/cli/templates/.appveyor.yml create mode 100644 ruby/lib/helix_runtime/cli/templates/.travis.yml create mode 100644 ruby/lib/helix_runtime/cli/templates/publish_to_rubygems.rb diff --git a/ruby/lib/helix_runtime/cli/bootstrap.rb b/ruby/lib/helix_runtime/cli/bootstrap.rb index c72f057f..b3757688 100644 --- a/ruby/lib/helix_runtime/cli/bootstrap.rb +++ b/ruby/lib/helix_runtime/cli/bootstrap.rb @@ -43,6 +43,18 @@ def add_gitignore template "gitignore", "#{base_path}/.gitignore" end + def add_publish_to_rubygems_file + template "publish_to_rubygems.rb", "#{base_path}/.scripts/publish_to_rubygems.rb" + end + + def add_travis_yml_file + template ".travis.yml", "#{base_path}/.travis.yml" + end + + def add_appveyor_yml_file + template ".appveyor.yml", "#{base_path}/.appveyor.yml" + end + def update_rakefile unless File.exists?("#{base_path}/Rakefile") create_file "#{base_path}/Rakefile", "require 'bundler/setup'\n" diff --git a/ruby/lib/helix_runtime/cli/templates/.appveyor.yml b/ruby/lib/helix_runtime/cli/templates/.appveyor.yml new file mode 100644 index 00000000..6314163c --- /dev/null +++ b/ruby/lib/helix_runtime/cli/templates/.appveyor.yml @@ -0,0 +1,40 @@ +environment: + nodejs_version: 8 + rust_channel: stable + matrix: + - platform: x64 + rust_target: x86_64-pc-windows-msvc + ruby_version: 22-x64 + - platform: x86 + rust_target: i686-pc-windows-msvc + ruby_version: 22 + +os: Visual Studio 2015 + +install: + - appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe + - rustup-init -yv --default-toolchain %rust_channel% --default-host %rust_target% + - rm rustup-init.exe + - set PATH=%PATH%;%USERPROFILE%\.cargo\bin + - set PATH=C:\Ruby%RUBY_VERSION%\bin;C:\Ruby%RUBY_VERSION%\DevKit\bin;%PATH% + - bundle install --path vendor/bundle + - bundle exec rake helix:copy_dll + +build: false + +before_test: + - rustc -vV + - cargo -vV + - ruby -v + - gem -v + - bundle -v + +test_script: + - bundle exec rake + +after_test: + - ruby ./.scripts/publish_to_rubygems.rb %APPVEYOR_REPO_TAG_NAME% + +artifacts: + - name: binary + path: <%= app_name %>-*.gem diff --git a/ruby/lib/helix_runtime/cli/templates/.travis.yml b/ruby/lib/helix_runtime/cli/templates/.travis.yml new file mode 100644 index 00000000..5c10f203 --- /dev/null +++ b/ruby/lib/helix_runtime/cli/templates/.travis.yml @@ -0,0 +1,47 @@ +language: ruby + +rvm: + - 2.2.7 + +sudo: false + +cache: bundler + +env: + global: + +before_install: +# setup rustc +- curl https://sh.rustup.rs -sSf | sh -s -- -y +- $HOME/.cargo/bin/rustup default stable +# get commit message +- COMMIT_MESSAGE=$(git show -s --format=%B $TRAVIS_COMMIT | tr -d '\n') +# put local node-pre-gyp on PATH +- export PATH=./node_modules/.bin/:$HOME/.cargo/bin/:$PATH + +install: +# ensure source install works +- bundle install --path vendor/bundle + +script: +# if publishing, test installing from remote +# INSTALL_RESULT=0 +# if [[ $PUBLISH_BINARY == true ]]; then INSTALL_RESULT=$(npm install --fallback-to-build=false > /dev/null)$? || true; fi; +# if install returned non zero (errored) then we first unpublish and then call false so travis will bail at this line +# if [[ $INSTALL_RESULT != 0 ]]; then echo "returned $INSTALL_RESULT";node-pre-gyp unpublish;false; fi +# If success then we arrive here so lets clean up +# node-pre-gyp clean +# +# test our module +- bundle exec rake + + +after_success: +# if publishing, do it +- ruby ./.scripts/publish_to_rubygems.rb $TRAVIS_TAG + +matrix: + include: + - os: linux + - os: osx + osx_image: xcode8.3 diff --git a/ruby/lib/helix_runtime/cli/templates/publish_to_rubygems.rb b/ruby/lib/helix_runtime/cli/templates/publish_to_rubygems.rb new file mode 100644 index 00000000..66d359aa --- /dev/null +++ b/ruby/lib/helix_runtime/cli/templates/publish_to_rubygems.rb @@ -0,0 +1,20 @@ +require 'fileutils' + +puts `gem build <%= app_name %>.gemspec` + +git_tag = ARGV[0] + +if git_tag && git_tag.match(/^v[0-9.]+/) + require 'yaml' + gem_config_dir = "#{Dir.home}/.gem" + credentials_file = "#{gem_config_dir}/credentials" + + FileUtils.mkdir_p gem_config_dir + File.open(credentials_file, 'w') do |f| + yaml = { rubygems_api_key: ENV['RUBYGEMS_AUTH_TOKEN'] }.to_yaml + f.puts yaml + end + File.chmod 0600, credentials_file + + puts `gem push <%= app_name %>-*.gem` +end