-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update rake building steps for monorepo layout
- Loading branch information
Showing
4 changed files
with
62 additions
and
41 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
/build | ||
/apps/*/vendor/bundle | ||
/apps/*/node_modules | ||
/apps/*/.built | ||
/packaging/*.tar.gz |
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 |
---|---|---|
@@ -1,66 +1,87 @@ | ||
require "json" | ||
require "pathname" | ||
require "time" | ||
|
||
PROJ_DIR = Pathname.new(__dir__) | ||
CONFIG_FILE = PROJ_DIR.join(ENV["CNFFILE"] || "config.json") | ||
BUILD_ROOT = Pathname.new(ENV["OBJDIR"] || "build") | ||
APPS_DIR = PROJ_DIR.join('apps') | ||
INSTALL_ROOT = Pathname.new(ENV["PREFIX"] || "/opt/ood") | ||
|
||
def all_components | ||
JSON.parse(CONFIG_FILE.read).map { |c| Component.new(c) } | ||
def apps | ||
Dir["#{APPS_DIR}/*"].map { |d| Component.new(d) } | ||
end | ||
|
||
class Component | ||
attr_reader :name | ||
attr_reader :url | ||
attr_reader :tag | ||
attr_reader :path | ||
#attr_reader :built | ||
|
||
def initialize(opts = {}) | ||
@name = opts.fetch("name") { raise ArgumentError, "No name specified. Missing argument: name" }.to_s | ||
@url = opts.fetch("url") { raise ArgumentError, "No url specified. Missing argument: url" }.to_s | ||
@tag = opts.fetch("tag") { raise ArgumentError, "No tag specified. Missing argument: tag" }.to_s | ||
@app = opts.fetch("app", nil) | ||
def initialize(app) | ||
@name = File.basename(app) | ||
@path = Pathname.new(app) | ||
#@built = @path.join('.built') | ||
end | ||
end | ||
|
||
def app? | ||
!!@app | ||
desc "Package OnDemand" | ||
task :package do | ||
`which gtar 1>/dev/null 2>&1` | ||
if $?.success? | ||
tar = 'gtar' | ||
else | ||
tar = 'tar' | ||
end | ||
|
||
def build_root | ||
app? ? BUILD_ROOT.join("apps", name) : BUILD_ROOT.join(name) | ||
version = ENV['VERSION'] | ||
if ! version | ||
latest_commit = `git rev-list --tags --max-count=1`.strip[0..6] | ||
latest_tag = `git describe --tags #{latest_commit}`.strip[1..-1] | ||
datetime = Time.now.strftime("%Y%m%d-%H%M") | ||
version = "#{latest_tag}-#{datetime}-#{latest_commit}" | ||
end | ||
sh "git ls-files | #{tar} -c --transform 's,^,ondemand-#{version}/,' -T - | gzip > packaging/v#{version}.tar.gz" | ||
end | ||
|
||
def download_url | ||
"#{url}/archive/#{tag}.tar.gz" | ||
namespace :build do | ||
apps.each do |a| | ||
desc "Build #{a.name} app" | ||
task a.name.to_sym do | ||
setup_path = a.path.join("bin", "setup") | ||
if setup_path.exist? && setup_path.executable? | ||
sh "PASSENGER_APP_ENV=production PASSENGER_BASE_URI=/pun/sys/#{a.name} #{setup_path}" | ||
end | ||
end | ||
end | ||
end | ||
|
||
task :default => :build | ||
desc "Build all apps" | ||
task :all => apps.map { |a| a.name } | ||
end | ||
|
||
all_components.each do |c| | ||
file c.build_root => CONFIG_FILE do | ||
rm_rf c.build_root if c.build_root.directory? | ||
mkdir_p c.build_root unless c.build_root.directory? | ||
sh "curl -skL #{c.download_url} | tar xzf - -C #{c.build_root} --strip-components=1" | ||
setup_path = c.build_root.join("bin", "setup") | ||
=begin | ||
apps.each do |a| | ||
file a.built do | ||
setup_path = a.path.join("bin", "setup") | ||
if setup_path.exist? && setup_path.executable? | ||
sh "PASSENGER_APP_ENV=production PASSENGER_BASE_URI=/pun/sys/#{c.name} #{setup_path}" | ||
sh "PASSENGER_APP_ENV=production PASSENGER_BASE_URI=/pun/sys/#{a.name} #{setup_path}" | ||
sh "touch #{a.built}" | ||
end | ||
c.build_root.join("VERSION").write(c.tag) if c.app? | ||
end | ||
end | ||
=end | ||
|
||
desc "Build OnDemand" | ||
task :build => all_components.map(&:build_root) | ||
task :build => 'build:all' | ||
#task :build => all_apps.map(&:built) | ||
|
||
directory INSTALL_ROOT.to_s | ||
|
||
desc "Install OnDemand" | ||
task :install => [:build, INSTALL_ROOT] do | ||
sh "rsync -rptl --delete --copy-unsafe-links #{BUILD_ROOT}/ #{INSTALL_ROOT}" | ||
task :install => [INSTALL_ROOT] do | ||
sh "cp -r mod_ood_proxy #{INSTALL_ROOT}/" | ||
sh "cp -r nginx_stage #{INSTALL_ROOT}/" | ||
sh "cp -r ood_auth_map #{INSTALL_ROOT}/" | ||
sh "cp -r ood-portal-generator #{INSTALL_ROOT}/" | ||
sh "cp -r #{APPS_DIR} #{INSTALL_ROOT}/" | ||
end | ||
|
||
desc "Clean up build" | ||
task :clean do | ||
rm_rf BUILD_ROOT | ||
sh "git clean -Xdf" | ||
end |
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