Debian Codegraph @

Rakefile

raw
1 require 'rake/testtask'
2
3 ENV['LANG'] = 'C.UTF-8'
4 ENV['TESTOPTS'] ||= '--verbose'
5
6 task :default => :test
7
8 task :test => :version_check do
9 puts '=> Unit tests'
10 Rake::Task['test:unit'].invoke
11 puts '=> Integration tests'
12 Rake::Task['test:integration'].invoke
13 end
14
15 Rake::TestTask.new('test:unit') do |t|
16 t.libs << "test"
17 t.test_files = FileList['test/unit/*_test.rb']
18 t.verbose = true
19 end
20
21 Rake::TestTask.new('test:coverage') do |t|
22 t.libs << "test"
23 t.test_files = FileList['test/unit/*_test.rb']
24 t.ruby_opts = ['-rsimplecov']
25 t.verbose = true
26 end
27
28 Rake::TestTask.new('test:integration') do |t|
29 t.libs << 'test'
30 t.test_files = FileList['test/integration/*_test.rb']
31 t.verbose = true
32 end
33
34 desc "Run tests in debug mode (e.g. don't delete temporary files)"
35 task 'test:debug' do
36 ENV['DEBUG'] = 'yes'
37 Rake::Task['test'].invoke
38 end
39
40 desc "Builds the Debian package and installs it on your system"
41 task :install do
42 sh 'dpkg-buildpackage -us -uc'
43 sh "sudo debi"
44 end
45
46 desc "Builds a git snapshot package"
47 task 'snapshot:build', :install do |task,args|
48 if !system('git diff-index --quiet HEAD')
49 fail "Can't build package; you have uncommitted changes"
50 end
51
52 date = `date --iso=seconds |sed 's/+.*//' |sed 's/[-T:]//g'`.chomp
53 branch = `git symbolic-ref --short HEAD`.strip
54 newbranch = 'snapshot-' + date
55
56 sh 'git checkout -b ' + newbranch
57 sh "sed -i '1 s/)/~git#{date})/' debian/changelog"
58 sh 'git commit -a -m snapshot-' + date
59 begin
60 sh 'DEB_BUILD_OPTIONS=nocheck gbp buildpackage --git-ignore-branch -us -uc'
61 if args[:install]
62 sh 'sudo debi'
63 end
64 ensure
65 sh 'git checkout ' + branch
66 end
67 end
68
69 desc "Installs a git snapshot package"
70 task 'snapshot:install' do
71 Rake::Task['snapshot:build'].invoke(true)
72 end
73
74
75 desc "Checks for inconsistencies between version numbers in the code and in debian/changelog"
76 task :version_check do
77 $code_version = `ruby -Ilib -rgem2deb/version -e 'puts Gem2Deb::VERSION'`.strip
78 $debian_version = `dpkg-parsechangelog | grep '^Version: ' | cut -d ' ' -f 2`.strip
79 if $code_version != $debian_version
80 msg ="W: Inconsistent version numbers: lib/gem2deb/version.rb says #{$code_version}, debian/changelog says #{$debian_version}"
81 if STDIN.isatty && STDOUT.isatty && STDERR.isatty
82 # highlight the message in red
83 puts("\033[31;40m%s\033[m" % msg)
84 else
85 puts msg
86 end
87 fail if ENV.has_key?('VERSION_CHECK_FATAL')
88 end
89 end
90
91 namespace :release do
92 desc "Releases to Debian (very much tied to terceiro's workflow)"
93 task :debian do
94 ENV['VERSION_CHECK_FATAL'] = 'yes'
95 Rake::Task['version_check'].invoke
96
97 sh 'gbp buildpackage --git-builder=sbuild'
98 sh 'gbp buildpackage --git-tag-only'
99 sh 'debsign'
100 sh 'git push --all'
101 sh 'git push --tags'
102 sh 'debrelease'
103 end
104 end