-
Notifications
You must be signed in to change notification settings - Fork 96
/
Rakefile
43 lines (34 loc) · 1.05 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
#!/usr/bin/env rake
require 'bundler'
Bundler::GemHelper.install_tasks
require 'rake/testtask'
require 'rubocop/rake_task'
desc 'Run Rubocop to check for style violations'
RuboCop::RakeTask.new
desc 'Run unit tests'
Rake::TestTask.new(:test) do |test|
test.libs << 'lib' << 'test'
test.test_files = FileList['test/plugin/*.rb']
test.verbose = true
end
# Building the gem will use the local file mode, so ensure it's world-readable.
# https://github.com/GoogleCloudPlatform/fluent-plugin-google-cloud/issues/53
desc 'Fix file permissions'
task :fix_perms do
files = [
'lib/fluent/plugin/*.rb',
'lib/google/**/*.rb'
].flat_map do |file|
file.include?('*') ? Dir.glob(file) : [file]
end
files.each do |file|
mode = File.stat(file).mode & 0o777
next unless mode & 0o444 != 0o444
puts "Changing mode of #{file} from #{mode.to_s(8)} to "\
"#{(mode | 0o444).to_s(8)}"
chmod mode | 0o444, file
end
end
desc 'Run unit tests and RuboCop to check for style violations'
task all: %i[rubocop test fix_perms]
task default: :all