-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
88 lines (69 loc) · 2.32 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
require 'yaml'
require 'pathname'
ROOT_PATH = File.expand_path File.dirname(__FILE__)
RELEASE_FILE_PATH = File.join ROOT_PATH, 'release.yaml'
# Read YAML configuration
File.open(RELEASE_FILE_PATH) { |f| YAML.load f }.each do |param, val|
Object.const_set "RELEASE_#{param.upcase}", val
end
namespace :build do
desc "Creating virtual environment"
task :venv do
%x[ virtualenv --clear --no-site-packages . >&2 ]
raise "Virtualenv creation failed" unless $?.success?
end
desc "Entering virtual environment"
task :activate do
# backticks required here, because source or .
# are shell builtins and therefore not accessible with
# which
%x[ `. bin/activate` ]
end
desc "Exiting virtual environment"
task :deactivate do
%x[ deactivate ]
end
desc "Install dependencies in a virtual environment"
task :deps => [:venv, :activate] do
# Here we use stderr to display the output
# on Jenkins, stdout is not
%x[ ./bin/python setup.py develop >&2 ]
raise "Dependencies failed" unless $?.success?
end
desc "Run test suite"
task :test => [:deps, :activate] do
%x[ ./bin/python #{RELEASE_TEST_FILE} -v ]
raise "Tests failed" unless $?.success?
end
desc "Clean building directories"
task :clean do
%x[ rm -rf build dist *.egg-info ]
end
desc "Build the package"
task :package => [:clean, :test, :activate] do
%x[ ./bin/python setup.py sdist >&2 ]
raise "Packaging failed" unless $?.success?
end
desc "Publish the package"
task :publish => :package do
package_name=%x[ basename dist/*tar.gz ].strip
package_url = "#{RELEASE_REPO_URL}/#{package_name}"
%x[ nd -p dist/#{package_name} #{package_url} ]
raise "Publishing failed" unless $?.success?
puts "Package #{package_name} published to #{RELEASE_REPO_URL}"
end
desc "Create .deb"
task :debian => [:clean, :test] do
fpm_bin = %x[ env PATH=$PATH:$(gem env gemdir)/bin which fpm ].strip
unless $?.success? && File.executable?(fpm_bin)
raise "Failed to locate the FPM binary"
end
%x[ #{fpm_bin} -t deb -s python setup.py ]
end
desc "Install Python module in a virtual environment"
task :install => [:venv, :activate] do
%x[ ./bin/python setup.py install >&2 ]
raise "Installation failed" unless $?.success?
end
end
task :default => 'build:package'