File: Rakefile

package info (click to toggle)
ruby-ffi-yajl 2.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 908 kB
  • sloc: ruby: 1,903; ansic: 527; makefile: 6
file content (139 lines) | stat: -rw-r--r-- 3,444 bytes parent folder | download
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
$LOAD_PATH << File.expand_path(File.join(File.dirname( __FILE__ ), "lib"))

require "rspec/core/rake_task"
require "rubygems/package_task"
require "rake/extensiontask"
require "ffi_yajl/version"

Dir[File.expand_path("../*gemspec", __FILE__)].reverse_each do |gemspec_path|
  gemspec = eval(IO.read(gemspec_path))
  Gem::PackageTask.new(gemspec).define
end

begin
  require "github_changelog_generator/task"
  GitHubChangelogGenerator::RakeTask.new :changelog do |config|
    config.issues = false
    config.since_tag = "1.0.1"
    config.exclude_labels = %w{duplicate question invalid wontfix changelog_skip}
  end
rescue LoadError
  puts "no github-changelog-generator"
end

desc "Build it and ship it"
task ship: [:clean, :gem] do
  sh("git tag #{FFI_Yajl::VERSION}")
  sh("git push --tags")
  Dir[File.expand_path("../pkg/*.gem", __FILE__)].reverse_each do |built_gem|
    sh("gem push #{built_gem}")
  end
end

unix_gemspec = eval(File.read("ffi-yajl.gemspec"))

task :clean do
  sh "rm -f Gemfile.lock"
  sh "rm -rf pkg/* tmp/* .bundle lib/ffi_yajl/ext/*"
end

desc "install the gem locally"
task install: [:package] do
  if defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
    sh %{gem install pkg/#{unix_gemspec.name}-#{unix_gemspec.version}-universal-java.gem}
  else
    sh %{gem install pkg/#{unix_gemspec.name}-#{unix_gemspec.version}.gem}
  end
end

spec = Gem::Specification.load("ffi-yajl.gemspec")

Rake::ExtensionTask.new do |ext|
  ext.name = "encoder"
  ext.lib_dir = "lib/ffi_yajl/ext"
  ext.ext_dir = "ext/ffi_yajl/ext/encoder"
  ext.gem_spec = spec
end

Rake::ExtensionTask.new do |ext|
  ext.name = "parser"
  ext.lib_dir = "lib/ffi_yajl/ext"
  ext.ext_dir = "ext/ffi_yajl/ext/parser"
  ext.gem_spec = spec
end

Rake::ExtensionTask.new do |ext|
  ext.name = "dlopen"
  ext.lib_dir = "lib/ffi_yajl/ext"
  ext.ext_dir = "ext/ffi_yajl/ext/dlopen"
  ext.gem_spec = spec
end

#
# test tasks
#

desc "Run all specs against both extensions"
task :spec do
  Rake::Task["spec:ffi"].invoke
  if !defined?(RUBY_ENGINE) || RUBY_ENGINE !~ /jruby/
    Rake::Task["spec:ext"].invoke
  end
end

namespace :spec do
  desc "Run all specs against ffi extension"
  RSpec::Core::RakeTask.new(:ffi) do |t|
    ENV["FORCE_FFI_YAJL"] = "ffi"
    t.pattern = FileList["spec/**/*_spec.rb"]
  end
  if !defined?(RUBY_ENGINE) || RUBY_ENGINE !~ /jruby/
    desc "Run all specs again c extension"
    RSpec::Core::RakeTask.new(:ext) do |t|
      ENV["FORCE_FFI_YAJL"] = "ext"
      t.pattern = FileList["spec/**/*_spec.rb"]
    end
  end
end

namespace :integration do
  begin
    require "kitchen"
  rescue LoadError
    task :vagrant do
      puts "test-kitchen gem is not installed"
    end
  else
    desc "Run Test Kitchen with Vagrant"
    task :vagrant do
      Kitchen.logger = Kitchen.default_file_logger
      Kitchen::Config.new.instances.each do |instance|
        instance.test(:always)
      end
    end
  end
end
namespace :style do
  desc "Run Ruby style checks"
  begin
    require "chefstyle"
    require "rubocop/rake_task"
  rescue LoadError
    task :rubocop do
      puts "chefstyle gem is not installed"
    end
  else
    RuboCop::RakeTask.new(:rubocop) do |t|
      t.fail_on_error = false
    end
  end
end

desc "Run all style checks"
task style: ["style:rubocop"]

desc "Run style + spec tests by default on travis"
task travis: %w{style spec}

desc "Run style + spec tests by default"
task default: %w{compile style spec}