|
14 | 14 |
|
15 | 15 | desc "Run CI checks" |
16 | 16 |
|
17 | | -TESTS = ["unit", "rubocop", "yardoc", "build", "examples", "conformance"] |
| 17 | +TESTS = ["unit", "dependencies", "rubocop", "yardoc", "build", "examples", "conformance"] |
18 | 18 |
|
19 | 19 | flag :only |
20 | 20 | TESTS.each do |name| |
|
26 | 26 |
|
27 | 27 | def handle_result result |
28 | 28 | if result.success? |
29 | | - puts "** #{result.name} passed\n\n", :green, :bold |
| 29 | + puts "** Passed: #{result.name}\n\n", :green, :bold |
30 | 30 | else |
31 | | - puts "** CI terminated: #{result.name} failed!", :red, :bold |
32 | | - exit 1 |
| 31 | + puts "** Failed: #{result.name}\n\n", :red, :bold |
| 32 | + @errors << result.name |
33 | 33 | end |
34 | 34 | end |
35 | 35 |
|
36 | 36 | def run |
| 37 | + @errors = [] |
37 | 38 | ::Dir.chdir context_directory |
38 | 39 | TESTS.each do |name| |
39 | 40 | key = "test_#{name}".to_sym |
40 | 41 | set key, !only if get(key).nil? |
41 | 42 | end |
42 | | - exec ["toys", "test"], name: "Unit tests" if test_unit |
43 | | - exec ["toys", "rubocop"], name: "Style checker" if test_rubocop |
44 | | - exec ["toys", "yardoc"], name: "Docs generation" if test_yardoc |
45 | | - exec ["toys", "build"], name: "Gem build" if test_build |
| 43 | + exec_separate_tool ["test"], name: "Unit tests" if test_unit |
| 44 | + exec_separate_tool ["ci", "deps-matrix"], name: "Dependency matrix tests" if test_dependencies |
| 45 | + exec_separate_tool ["rubocop"], name: "Style checker" if test_rubocop |
| 46 | + exec_separate_tool ["yardoc"], name: "Docs generation" if test_yardoc |
| 47 | + exec_separate_tool ["build"], name: "Gem build" if test_build |
46 | 48 | ::Dir.foreach "examples" do |dir| |
47 | 49 | next if dir =~ /^\.+$/ |
48 | | - exec ["toys", "test"], name: "Tests for #{dir} example", chdir: ::File.join("examples", dir) |
| 50 | + exec_separate_tool ["test"], name: "Tests for #{dir} example", chdir: ::File.join("examples", dir) |
49 | 51 | end if test_examples |
50 | | - exec ["toys", "conformance"], name: "Conformance tests" if test_conformance |
| 52 | + exec_separate_tool ["conformance"], name: "Conformance tests" if test_conformance |
| 53 | + @errors.each do |err| |
| 54 | + puts "Failed: #{err}", :red, :bold |
| 55 | + end |
| 56 | + exit 1 unless @errors.empty? |
| 57 | +end |
| 58 | + |
| 59 | +tool "deps-matrix" do |
| 60 | + static :puma_versions, ["4.0", "5.0", "6.0"] |
| 61 | + static :rack_versions, ["2.1", "3.0"] |
| 62 | + |
| 63 | + include :exec, result_callback: :handle_result |
| 64 | + include :terminal |
| 65 | + |
| 66 | + def handle_result result |
| 67 | + if result.success? |
| 68 | + puts "** Passed: #{result.name}\n\n", :green, :bold |
| 69 | + else |
| 70 | + puts "** Failed: #{result.name}\n\n", :red, :bold |
| 71 | + @errors << result.name |
| 72 | + end |
| 73 | + end |
| 74 | + |
| 75 | + def run |
| 76 | + @errors = [] |
| 77 | + ::Dir.chdir context_directory |
| 78 | + puma_versions.each do |puma_version| |
| 79 | + rack_versions.each do |rack_version| |
| 80 | + name = "Puma #{puma_version} / Rack #{rack_version}" |
| 81 | + env = { |
| 82 | + "FF_DEPENDENCY_TEST_PUMA" => "~> #{puma_version}", |
| 83 | + "FF_DEPENDENCY_TEST_RACK" => "~> #{rack_version}", |
| 84 | + } |
| 85 | + exec_separate_tool ["test", "test/test_server.rb"], env: env, name: name |
| 86 | + end |
| 87 | + end |
| 88 | + @errors.each do |err| |
| 89 | + puts "Failed: #{err}", :red, :bold |
| 90 | + end |
| 91 | + exit 1 unless @errors.empty? |
| 92 | + end |
51 | 93 | end |
0 commit comments