-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRakefile
More file actions
147 lines (123 loc) · 4.62 KB
/
Rakefile
File metadata and controls
147 lines (123 loc) · 4.62 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
require "bundler/setup"
require "fileutils"
require "shellwords"
require_relative "lib/plur"
# Race detection: when PLUR_RACE is set, configure Go to build with race detector
if ENV["PLUR_RACE"] && ENV["PLUR_RACE"] != "0"
# Add -race to GOFLAGS (idempotent)
goflags = Shellwords.split(ENV["GOFLAGS"].to_s)
unless goflags.include?("-race")
goflags << "-race"
ENV["GOFLAGS"] = goflags.join(" ")
end
# Race detector requires CGO
ENV["CGO_ENABLED"] = "1"
puts "[race] Race detection enabled: GOFLAGS=#{ENV["GOFLAGS"]} CGO_ENABLED=1"
end
begin
require "standard/rake" if Gem::Specification.find_all_by_name("standard").any?
require "rspec/core/rake_task" if Gem::Specification.find_all_by_name("rspec").any?
RSpec::Core::RakeTask.new(:spec) if defined?(RSpec)
rescue LoadError
end
Dir.glob(Plur.config.root_dir.join("lib", "tasks", "*.rake")).each { |file| load file }
PLUR_CORES = Plur.config.plur_cores
# Default task runs all checks
desc "Run all tests and linting"
task default: ["lint:all", "build", "test:all"]
desc "Build the plur Go binary"
task build: ["vendor:download:current"] do
puts "[build] Building plur"
sh %(go build -mod=mod .)
version = `./plur --version`.strip
puts "[build] Binary created at ./plur with version: #{version}"
end
namespace :build do
desc "Build binaries for all supported platforms"
task all: ["vendor:download:all"] do
puts "[build:all] Building plur for all platforms..."
sh "goreleaser build --snapshot --clean"
end
end
desc "Install plur globally to $GOBIN"
task :install do
gobin = ENV.fetch("GOBIN") { File.join(`go env GOPATH`.strip, "bin") }
FileUtils.mkdir_p(gobin)
final = File.join(gobin, "plur")
temp = File.join(gobin, "plur-new-#{Time.now.to_i}")
sh %(goreleaser build --snapshot --single-target --clean -o #{temp} > /dev/null 2>&1)
File.chmod(0o755, temp)
File.rename(temp, final)
puts "[install] Installed plur with version: #{`plur --version`.strip}"
end
namespace :test do
desc "Run all tests (Go, Default Ruby, and full Ruby suite)"
task all: ["test:go", "test:default_ruby", "test"]
desc "Run Go tests"
task go: ["build"] do
puts "[test:go] Running go tests..."
# Use -short in CI to skip slow complexity tests that are sensitive to system noise
short_flag = ENV["CI"] ? "-short" : ""
if ENV["VERBOSE"]
sh "go test -mod=mod -v #{short_flag} ./...".squeeze(" ")
else
sh "go test -mod=mod #{short_flag} ./...".squeeze(" ")
end
end
desc "Run plur against default-ruby fixture project"
task default_ruby: :install do
puts "[test:default_ruby] Running default-ruby specs with plur..."
sh "plur", "-C", Plur.config.default_ruby_dir.to_s, "-n", PLUR_CORES.to_s, err: "/dev/null"
end
desc "Run default-rails specs using plur"
task default_rails: :install do
puts "[test:default_rails] Running default-rails specs with plur..."
sh "plur", "-C", Plur.config.default_rails_dir.to_s, "-n", PLUR_CORES.to_s, err: "/dev/null"
end
desc "Run Ruby specs against all RSpec appraisals"
task appraisals: :install do
puts "[test:appraisals] Running specs against all RSpec appraisals..."
sh "bundle exec appraisal rake test"
end
desc "Run Ruby specs against a specific appraisal (e.g., bin/rake test:appraisal[rspec-3.13.1])"
task :appraisal, [:name] => :install do |_t, args|
name = args[:name] || abort("Usage: bin/rake test:appraisal[rspec-3.13.1]")
puts "[test:appraisal] Running specs with #{name}..."
sh "bundle exec appraisal #{name} rake test"
end
end
namespace :lint do
desc "Run all linting (Go, Ruby, and Shell)"
task all: %i[go ruby shell toolchain:check]
desc "Lint Go code"
task :go do
puts "[lint:go] Running go fmt and go vet"
sh "go", "fmt", "-mod=mod", "./..."
sh "go vet -mod=mod ./..."
end
desc "Lint Ruby code with Standard"
task :ruby do
puts "[lint:ruby] Running StandardRB linter"
Rake::Task["standard"].invoke
end
desc "Fix Ruby linting issues automatically"
task :ruby_fix do
Rake::Task["standard:fix"].invoke
end
desc "Lint shell scripts with shellcheck"
task :shell do
puts "[lint:shell] Running shellcheck"
scripts = Dir["install.sh", "script/*"].select { |f| File.file?(f) && File.read(f, 64).start_with?("#!/") && File.read(f, 64).include?("sh") }
sh "shellcheck", "--severity=warning", *scripts
end
end
# ========================================
# Convenience Tasks (top-level)
# ========================================
desc "Run all Ruby specs"
task test: :install do
puts "[test] Running all ruby specs with plur..."
sh "plur", "-n", PLUR_CORES.to_s
end
desc "Run all linting"
task lint: ["lint:all"]