-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathRakefile
More file actions
70 lines (57 loc) · 1.96 KB
/
Rakefile
File metadata and controls
70 lines (57 loc) · 1.96 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
# frozen_string_literal: true
require "bundler/gem_tasks"
require "rake/testtask"
# Main test task for gem's unit tests
Rake::TestTask.new(:unit_tests) do |t|
t.libs << "test"
t.test_files = FileList["test/**/*_test.rb"].exclude("test/dummy/**/*_test.rb")
end
# Simple task that runs everything in sequence
desc "Run all tests and quality checks"
task :ci do
failed = false
# Run unit tests
puts "\n== Running unit tests =="
Rake::Task["unit_tests"].invoke
# Run dummy app tests if they exist, but don't fail the build if they fail
if File.directory?("test/dummy/test/integration")
puts "\n== Running integration tests (optional) =="
unless system("cd test/dummy && bin/rails test test/integration 2>/dev/null")
puts "Integration tests failed or could not run. This is allowed in CI."
end
end
# Always run Rubocop and fail the build if there are issues
puts "\n== Running RuboCop (Rails Omakase style) =="
unless system("bundle exec rubocop")
puts "\nRuboCop found issues - failing the build"
failed = true
end
# Fail the build if any step failed
fail "CI task failed" if failed
end
# More strict version for CI environments
desc "Run all tests and quality checks strictly (for CI)"
task :ci_strict do
failed = false
# Run unit tests
puts "\n== Running unit tests =="
Rake::Task["unit_tests"].invoke
# Run dummy app tests if they exist
if File.directory?("test/dummy/test/integration")
puts "\n== Running integration tests =="
unless system("cd test/dummy && bin/rails test test/integration")
puts "Warning: Integration tests failed or could not run"
failed = true
end
end
# Run Rubocop if available
if system("which rubocop > /dev/null 2>&1")
puts "\n== Running RuboCop =="
system("rubocop --format simple")
failed = true unless $?.success?
end
# Fail the build if any step failed
raise "CI task failed" if failed
end
# Set default task to run everything
task default: :ci