Skip to content

Commit

Permalink
Update build scripts for rubyc 0.5 + ruby 2.5 (#839)
Browse files Browse the repository at this point in the history
  • Loading branch information
kke authored and jakolehm committed Nov 23, 2018
1 parent 94ba665 commit 2625e2c
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .drone.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pipeline:
test-ruby:
image: ruby:2.4
image: ruby:2.5
commands:
- gem install bundler -Nf
- bundle install --path bundler
Expand Down
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ AllCops:
- Gemfile
- "*.gemspec"
- bundler/**/*
TargetRubyVersion: 2.4
TargetRubyVersion: 2.5

Style/PercentLiteralDelimiters:
PreferredDelimiters:
Expand Down
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
include:
- stage: publish binary
script: ./build/travis/macos.sh
rvm: 2.4
rvm: 2.5
os: osx
deploy:
provider: s3
Expand All @@ -28,7 +28,7 @@ jobs:
all_branches: true
- stage: publish binary
script: ./build/travis/macos_oss.sh
rvm: 2.4
rvm: 2.5
os: osx
deploy:
provider: s3
Expand All @@ -41,4 +41,4 @@ jobs:
local-dir: upload
skip_cleanup: true
on:
all_branches: true
all_branches: true
10 changes: 6 additions & 4 deletions build/drone/ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ set -ue

# build binary
apt-get update -y
apt-get install -y -q squashfs-tools build-essential ruby bison ruby-dev git-core texinfo curl
curl -sL https://dl.bintray.com/kontena/ruby-packer/0.5.0-dev/rubyc-linux-amd64.gz | gunzip > /usr/local/bin/rubyc
apt-get install -y -q squashfs-tools build-essential ruby bison ruby-dev git-core texinfo curl openssl

update-ca-certificates

curl -sL https://dl.bintray.com/kontena/ruby-packer/0.5.0-dev/rubyc-0.5.0-extra-linux-amd64.gz | gunzip > /usr/local/bin/rubyc
chmod +x /usr/local/bin/rubyc

gem install bundler
version=${DRONE_TAG#"v"}
package="pharos-cluster-linux-amd64-${version}"
mkdir -p /root/.pharos/build
rubyc -o "$package" -d /root/.pharos/build --make-args=--silent pharos-cluster
rubyc --openssl-dir=/etc/ssl -o "$package" -d /root/.pharos/build --make-args=--silent pharos-cluster
rm -rf /root/.pharos/build
./"$package" version
13 changes: 7 additions & 6 deletions build/drone/ubuntu_oss.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@
set -ue

apt-get update -y
apt-get install -y -q squashfs-tools build-essential ruby bison ruby-dev git-core texinfo curl
apt-get install -y -q squashfs-tools build-essential ruby bison ruby-dev git-core texinfo curl openssl

rm -rf non-oss/
update-ca-certificates

# build binary
curl -sL https://dl.bintray.com/kontena/ruby-packer/0.5.0-dev/rubyc-linux-amd64.gz | gunzip > /usr/local/bin/rubyc
curl -sL https://dl.bintray.com/kontena/ruby-packer/0.5.0-dev/rubyc-0.5.0-extra-linux-amd64.gz | gunzip > /usr/local/bin/rubyc
chmod +x /usr/local/bin/rubyc

gem install bundler
rm -rf non-oss/

version=${DRONE_TAG#"v"}
package="pharos-cluster-linux-amd64-${version}+oss"
mkdir -p /root/.pharos/build
rubyc -o "$package" -d /root/.pharos/build --make-args=--silent pharos-cluster
rubyc --openssl-dir=/etc/ssl -o "$package" -d /root/.pharos/build --make-args=--silent pharos-cluster
rm -rf /root/.pharos/build
./"$package" version
8 changes: 6 additions & 2 deletions build/travis/macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ set -ue
export PHAROS_NON_OSS=true

brew install squashfs
curl -sL https://dl.bintray.com/kontena/ruby-packer/0.5.0-dev/rubyc-darwin-amd64.gz | gunzip > /usr/local/bin/rubyc
brew install openssl || brew upgrade openssl || true

curl -sL https://curl.haxx.se/ca/cacert.pem > /usr/local/etc/openssl/cacert.pem

curl -sL https://dl.bintray.com/kontena/ruby-packer/0.5.0-dev/rubyc-0.5.0-extra-darwin-amd64.gz | gunzip > /usr/local/bin/rubyc
chmod +x /usr/local/bin/rubyc

version=${TRAVIS_TAG#"v"}
package="pharos-cluster-darwin-amd64-${version}"
rubyc -o "$package" --make-args=--silent pharos-cluster
rubyc --openssl-dir=/usr/local/etc/openssl -o "$package" --make-args=--silent pharos-cluster
./"$package" version

rm -rf upload/
Expand Down
12 changes: 8 additions & 4 deletions build/travis/macos_oss.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@

set -ue

rm -rf non-oss/

brew install squashfs
curl -sL https://dl.bintray.com/kontena/ruby-packer/0.5.0-dev/rubyc-darwin-amd64.gz | gunzip > /usr/local/bin/rubyc
brew install openssl || brew upgrade openssl || true

curl -sL https://curl.haxx.se/ca/cacert.pem > /usr/local/etc/openssl/cacert.pem

curl -sL https://dl.bintray.com/kontena/ruby-packer/0.5.0-dev/rubyc-0.5.0-extra-darwin-amd64.gz | gunzip > /usr/local/bin/rubyc
chmod +x /usr/local/bin/rubyc

rm -rf non-oss/

version=${TRAVIS_TAG#"v"}
package="pharos-cluster-darwin-amd64-${version}+oss"
rubyc -o "$package" --make-args=--silent pharos-cluster
rubyc --openssl-dir=/usr/local/etc/openssl -o "$package" --make-args=--silent pharos-cluster
./"$package" version

rm -rf upload/
Expand Down
10 changes: 4 additions & 6 deletions lib/pharos/cluster_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,10 @@ def apply_reset_hosts(hosts)

def apply_addons_cluster_config_modifications
addon_manager.each do |addon|
begin
addon.apply_modify_cluster_config
rescue Pharos::Error => e
error_msg = "#{addon.name} => " + e.message
raise Pharos::AddonManager::InvalidConfig, error_msg
end
addon.apply_modify_cluster_config
rescue Pharos::Error => e
error_msg = "#{addon.name} => " + e.message
raise Pharos::AddonManager::InvalidConfig, error_msg
end
end

Expand Down
17 changes: 7 additions & 10 deletions lib/pharos/command_options/load_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,15 @@ module LoadConfig
def self.included(base)
base.prepend(InstanceMethods)
base.option ['-c', '--config'], 'PATH', 'path to config file (default: cluster.yml)', attribute_name: :config_yaml do |config_file|
begin
Pharos::YamlFile.new(File.realpath(config_file))
rescue Errno::ENOENT
signal_usage_error 'File does not exist: %<path>s' % { path: config_file }
end
Pharos::YamlFile.new(File.realpath(config_file))
rescue Errno::ENOENT
signal_usage_error 'File does not exist: %<path>s' % { path: config_file }
end

base.option '--tf-json', 'PATH', 'path to terraform output json' do |config_path|
begin
File.realpath(config_path)
rescue Errno::ENOENT
signal_usage_error 'File does not exist: %<path>s' % { path: config_path }
end
File.realpath(config_path)
rescue Errno::ENOENT
signal_usage_error 'File does not exist: %<path>s' % { path: config_path }
end
end

Expand All @@ -39,6 +35,7 @@ def default_config_yaml
# @return [Pharos::Config]
def load_config
return @config if @config

puts(pastel.green("==> Reading instructions ...")) if $stdout.tty?

config_hash = config_yaml.load(ENV.to_h)
Expand Down
8 changes: 3 additions & 5 deletions lib/pharos/phases/gather_facts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,9 @@ def read_resolvconf
def read_routes
routes = []
ssh.exec!("sudo ip route").each_line do |line|
begin
routes << Pharos::Configuration::Host::Route.parse(line)
rescue RuntimeError => exc
logger.warn { exc }
end
routes << Pharos::Configuration::Host::Route.parse(line)
rescue RuntimeError => exc
logger.warn { exc }
end

routes
Expand Down
18 changes: 8 additions & 10 deletions lib/pharos/ssh_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,14 @@ def run_single(host)
def run_parallel
threads = filtered_hosts.map do |host|
Thread.new do
begin
[host, host.ssh.exec(command_list)]
rescue StandardError => ex
[
host,
Pharos::SSH::RemoteCommand::Result.new.tap do |r|
r.output << ex.message
end
]
end
[host, host.ssh.exec(command_list)]
rescue StandardError => ex
[
host,
Pharos::SSH::RemoteCommand::Result.new.tap do |r|
r.output << ex.message
end
]
end
end
results = threads.map(&:value)
Expand Down

0 comments on commit 2625e2c

Please sign in to comment.