-
Notifications
You must be signed in to change notification settings - Fork 88
Expand file tree
/
Copy pathRakefile
More file actions
125 lines (108 loc) · 3.85 KB
/
Rakefile
File metadata and controls
125 lines (108 loc) · 3.85 KB
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
require 'rspec/core/rake_task'
require 'bundler/gem_tasks'
desc 'Run all specs'
RSpec::Core::RakeTask.new(:spec)
task :default => :spec
namespace 'test:ruby' do |ns|
src = File.dirname(File.expand_path(__FILE__))
%w(3.4 3.3 3.2 3.1 3.0 2.7).each do |version|
task version do
sh %(
docker run -i --rm -v #{src}:/src ruby:#{version}
bash -c '
git config --global --add safe.directory /src/.git
&& git clone -s /src /work
&& cd /work
&& bundle install -j 4
&& bundle exec rake
'
).gsub(/\s+/, ' ').strip
end
end
end
namespace 'test:distro' do
src = File.dirname(File.expand_path(__FILE__))
distros = {
'debian-11' => 'debian:11',
'debian-12' => 'debian:12',
'debian-13' => 'debian:trixie',
'ubuntu-20.04' => 'ubuntu:20.04',
'ubuntu-22.04' => 'ubuntu:22.04',
'ubuntu-24.04' => 'ubuntu:24.04',
'rocky-8' => 'rockylinux:8',
'rocky-9' => 'rockylinux:9',
'alpine-3.18' => 'alpine:3.18',
'alpine-3.19' => 'alpine:3.19',
'alpine-3.20' => 'alpine:3.20',
'fedora-40' => 'fedora:40',
'fedora-41' => 'fedora:41',
# openSUSE Tumbleweed ships Ruby 4.0 which is incompatible with
# our dependencies (cabin/fpm require 'logger' which was removed
# from Ruby's standard library in 4.0). Leap 15.x ships Ruby 2.5
# which is below our minimum (2.7). Re-enable when dependencies
# support Ruby 4.0.
#'opensuse-tw' => 'opensuse/tumbleweed:latest',
'archlinux' => 'archlinux:latest',
}
distros.each do |name, image|
install_cmd = case image
when /debian|ubuntu/
'apt-get update && apt-get install -y ruby ruby-dev build-essential git'
when /rockylinux:8/
# Rocky 8 ships with Ruby 2.5, enable Ruby 3.1 module stream
'dnf module enable -y ruby:3.1 && dnf install -y ruby ruby-devel gcc gcc-c++ make git redhat-rpm-config'
when /rockylinux|fedora/
'dnf install -y ruby ruby-devel gcc gcc-c++ make git redhat-rpm-config'
when /alpine/
'apk add ruby ruby-dev build-base git'
when /opensuse/
'zypper -n install ruby ruby-devel gcc gcc-c++ make git'
when /archlinux/
'pacman -Sy --noconfirm ruby base-devel git'
end
# Bundler >= 2.5 requires Ruby >= 3.2. Use 2.4.22 for older Ruby.
bundler_install = 'ruby -e "exit(Gem::Version.new(RUBY_VERSION) >= Gem::Version.new(%(3.2)) ? 0 : 1)" && gem install bundler || gem install bundler -v 2.4.22'
desc "Run tests on #{name}"
task name do
sh %(docker run -i --rm -v #{src}:/src #{image} sh -c '
#{install_cmd} &&
#{bundler_install} &&
export PATH="$(ruby -e "puts Gem.user_dir")/bin:$PATH" &&
git config --global --add safe.directory /src &&
cp -r /src /work && cd /work &&
bundle install -j 4 &&
COVERAGE=false bundle exec rspec spec/facts_spec.rb spec/dependency_inspector_spec.rb spec/integration/native_detection_spec.rb
').gsub(/\s+/, ' ').strip
end
end
desc 'Run tests on all distributions'
task :all => distros.keys
end
begin
require 'systemu'
namespace :docs do |ns|
docs_dir = File.join(File.dirname(File.expand_path(__FILE__)), 'docs')
Dir.chdir docs_dir do
sphinxbuild = ENV['SPHINXBUILD'] || 'sphinx-build'
status, stdout, stderr = systemu "make SPHINXBUILD=#{sphinxbuild} help"
next if status != 0
desc 'clean up doc builds'
task 'clean' do
Dir.chdir docs_dir do
system "make SPHINXBUILD=#{sphinxbuild} clean"
end
end
stdout.each_line.grep(/^\s+(\w+?)\s+(.*)$/) do
t, d = $1, $2
desc d
task t do
Dir.chdir docs_dir do
system "make SPHINXBUILD=#{sphinxbuild} #{t}"
end
end
end
end
end
rescue LoadError
# systemu gem not available; skip docs tasks
end