Skip to content

Commit

Permalink
Merge pull request #21 from Edouard-chin/ec-ruby-33-matrix
Browse files Browse the repository at this point in the history
Add Ruby 3.3 to the matrix
  • Loading branch information
Edouard-chin authored Jan 4, 2024
2 parents 756c042 + 9a2168c commit 4942584
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 32 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ['2.7', '3.0', '3.1', '3.2', 'head']
ruby-version: ['2.7', '3.0', '3.1', '3.2', '3.3', 'head']

steps:
- uses: actions/checkout@v3
- name: Remove lockfile
run: rm Gemfile.lock
- name: Set up Ruby
uses: ruby/setup-ruby@77fe3b48b7ef9e181c0ecc9f05478ba7818b1b5c
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
Expand Down
3 changes: 2 additions & 1 deletion lib/ci_runner/runners/minitest_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def start!
t.libs << "#{rake_load_path}"
t.libs << "#{minitest_plugin_path}"
t.test_files = #{failures.map(&:path)}
t.ruby_opts = ["-W0"] if ENV["NO_WARNING"]
end
Rake::Task[:__ci_runner_test].invoke
Expand All @@ -89,7 +90,7 @@ def start!
env["RUBY"] = ruby_path.to_s if ruby_path&.exist?
env["BUNDLE_GEMFILE"] = gemfile_path.to_s if gemfile_path&.exist?

execute_within_frame(env, "bundle exec ruby -r'rake/testtask' #{rakefile_path}")
execute_within_frame(env, "bundle exec ruby -I'#{rake_load_path}' -r'rake/testtask' #{rakefile_path}")

DRb.stop_service
end
Expand Down
4 changes: 2 additions & 2 deletions test/check/buildkite_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def setup

def test_download_log_when_the_pipeline_is_public
stub_request(:get, "https://buildkite.com/katana/test/builds/1")
.to_return_json(status: 200, body: read_fixture("buildkite/public_build.json"))
.to_return_json(status: 200, body: fixture_path("buildkite/public_build.json").read)

stub_request(:get, "https://buildkite.com/organizations/katana/pipelines/test/builds/7/jobs/abc/raw_log")
.to_return(status: 302, headers: { "Location" => "https://example.com/log1" })
Expand Down Expand Up @@ -50,7 +50,7 @@ def test_download_log_when_the_pipeline_is_private
.to_return_json(status: 403)

stub_request(:get, "https://api.buildkite.com/v2/organizations/katana/pipelines/test/builds/1")
.to_return_json(status: 200, body: read_fixture("buildkite/private_build.json"))
.to_return_json(status: 200, body: fixture_path("buildkite/private_build.json").read)

stub_request(:get, "https://api.buildkite.com/v2/organizations/katana/pipelines/private-build/builds/1/jobs/abc/log.txt")
.to_return(status: 200, body: "abc")
Expand Down
6 changes: 3 additions & 3 deletions test/check/circle_ci_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_download_log_makes_an_api_call_to_the_right_url

def test_download_log_downloads_the_log_output_for_each_step
stub_request(:get, "https://circleci.com/api/v1.1/project/github/owner/repo/3230")
.to_return_json(status: 200, body: read_fixture("circleci/job.json"))
.to_return_json(status: 200, body: fixture_path("circleci/job.json").read)

stub_request(:get, "https://circle-production-action-output.s3.amazonaws.com/1")
.to_return(status: 200, body: JSON.dump([message: "abc"]))
Expand Down Expand Up @@ -59,7 +59,7 @@ def test_download_log_downloads_the_log_output_for_each_step

def test_download_log_skip_steps_without_output
stub_request(:get, "https://circleci.com/api/v1.1/project/github/owner/repo/3230")
.to_return_json(status: 200, body: read_fixture("circleci/job_step_no_output.json"))
.to_return_json(status: 200, body: fixture_path("circleci/job_step_no_output.json").read)

stub_request(:get, "https://circle-production-action-output.s3.amazonaws.com/1")
.to_return(status: 200, body: JSON.dump([message: "abc"]))
Expand Down Expand Up @@ -88,7 +88,7 @@ def test_download_log_skip_steps_without_output

def test_download_log_when_steps_run_in_parallel
stub_request(:get, "https://circleci.com/api/v1.1/project/github/owner/repo/3230")
.to_return_json(status: 200, body: read_fixture("circleci/job_parallel.json"))
.to_return_json(status: 200, body: fixture_path("circleci/job_parallel.json").read)

stub_request(:get, "https://circle-production-action-output.s3.amazonaws.com/1")
.to_return(status: 200, body: JSON.dump([message: "abc"]))
Expand Down
3 changes: 2 additions & 1 deletion test/fixtures/Gemfile_dummy.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ GEM

PLATFORMS
x86_64-darwin-20
x86_64-darwin-22

DEPENDENCIES
minitest
warning

BUNDLED WITH
2.3.17
2.4.1
12 changes: 6 additions & 6 deletions test/integration/cli_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,16 @@ def test_rerun_fetch_log_from_circleci
)

stub_request(:get, "https://circleci.com/api/v1.1/project/github/foo/bar/956")
.to_return_json(status: 200, body: read_fixture("circleci/job2.json"))
.to_return_json(status: 200, body: fixture_path("circleci/job2.json").read)

stub_request(:get, "https://circle-production-action-output.s3.amazonaws.com/1")
.to_return_json(status: 200, body: read_fixture("circleci/job_setup_output.json"))
.to_return_json(status: 200, body: fixture_path("circleci/job_setup_output.json").read)

stub_request(:get, "https://circle-production-action-output.s3.amazonaws.com/2")
.to_return_json(status: 200, body: read_fixture("circleci/job_container_output.json"))
.to_return_json(status: 200, body: fixture_path("circleci/job_container_output.json").read)

stub_request(:get, "https://circle-production-action-output.s3.amazonaws.com/3")
.to_return_json(status: 200, body: read_fixture("circleci/job_test_output.json"))
.to_return_json(status: 200, body: fixture_path("circleci/job_test_output.json").read)

stdout, _ = capture_io do
CLI.start(["--commit", "abc", "--repository", "foo/bar", "--run-name", "ci/circleci: ruby-27"])
Expand Down Expand Up @@ -219,15 +219,15 @@ def test_rerun_fetch_log_from_buildkite
)

stub_request(:get, "https://buildkite.com/foo/bar/builds/956")
.to_return_json(status: 200, body: read_fixture("buildkite/public_build.json"))
.to_return_json(status: 200, body: fixture_path("buildkite/public_build.json").read)

stub_request(:get, "https://buildkite.com/organizations/katana/pipelines/test/builds/7/jobs/abc/raw_log")
.to_return(status: 302, headers: { "Location" => "https://example.com/log1" })

stub_request(:get, "https://buildkite.com/organizations/katana/pipelines/test/builds/7/jobs/def/raw_log")
.to_return(status: 302, headers: { "Location" => "https://example.com/log2" })

stub_request(:get, "https://example.com/log1").to_return(status: 200, body: read_fixture("rails.log"))
stub_request(:get, "https://example.com/log1").to_return(status: 200, body: fixture_path("rails.log").read)
stub_request(:get, "https://example.com/log2").to_return(status: 200, body: "def")

stdout, _ = capture_io do
Expand Down
18 changes: 9 additions & 9 deletions test/runners/minitest_runner_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def teardown
end

def test_parse_raw_minitest_log_failures
log = read_fixture("raw_minitest_failures.log")
log = fixture_path("raw_minitest_failures.log")
parser = MinitestRunner.new(log)

parser.parse!
Expand All @@ -41,7 +41,7 @@ def test_parse_raw_minitest_log_failures
end

def test_parse_raw_minitest_log_errors
log = read_fixture("raw_minitest_error.log")
log = fixture_path("raw_minitest_error.log")
parser = MinitestRunner.new(log)

parser.parse!
Expand All @@ -64,7 +64,7 @@ def test_parse_raw_minitest_log_errors
end

def test_parse_rails_log
log = read_fixture("rails.log")
log = fixture_path("rails.log")
parser = MinitestRunner.new(log)

parser.parse!
Expand Down Expand Up @@ -103,7 +103,7 @@ def test_parse_rails_log
# In this test, the test suite name "I18nBackendPluralizationFallbackTest", doesn't
# map to a file called `i18n_backend_pluralization...`.
def test_parse_log_with_inconsistent_class_and_file_name
log = read_fixture("i18n.log")
log = fixture_path("i18n.log")
parser = MinitestRunner.new(log)

parser.parse!
Expand All @@ -126,7 +126,7 @@ def test_parse_log_with_inconsistent_class_and_file_name
end

def test_when_projet_uses_custom_regexes
log = read_fixture("custom_regexes.log")
log = fixture_path("custom_regexes.log")
runner = MinitestRunner.new(log)

Dir.chdir(Dir.home) do
Expand All @@ -151,7 +151,7 @@ def test_when_projet_uses_custom_regexes
end

def test_when_projet_uses_different_buffer_starts_regex
log = read_fixture("custom_buffer_starts.log")
log = fixture_path("custom_buffer_starts.log")
runner = MinitestRunner.new(log)

Dir.chdir(Dir.home) do
Expand Down Expand Up @@ -191,7 +191,7 @@ def test_when_projet_uses_different_buffer_starts_regex
end

def test_when_projet_uses_custom_failure_regex
log = read_fixture("custom_failures.log")
log = fixture_path("custom_failures.log")
runner = MinitestRunner.new(log)

Dir.chdir(Dir.home) do
Expand Down Expand Up @@ -223,7 +223,7 @@ def test_when_projet_uses_custom_failure_regex
end

def test_when_projet_uses_custom_invalid_failure_regex
log = read_fixture("custom_failures.log")
log = fixture_path("custom_failures.log")
runner = MinitestRunner.new(log)

Dir.chdir(Dir.home) do
Expand Down Expand Up @@ -251,7 +251,7 @@ def test_when_projet_uses_custom_invalid_failure_regex
end

def test_parse_namespaced_class_location_infer_from_stacktrace
log = read_fixture("minitest_namespace.log")
log = fixture_path("minitest_namespace.log")
parser = MinitestRunner.new(log)

parser.parse!
Expand Down
4 changes: 2 additions & 2 deletions test/runners/rspec_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module CIRunner
module Runners
class RSpecTest < Minitest::Test
def test_parse_return_failures
runner = RSpec.new(read_fixture("rspec.log"))
runner = RSpec.new(fixture_path("rspec.log"))
runner.parse!

expected_test_name = "Octokit::Client::Repositories.edit_repository is_template is passed in params gets"
Expand All @@ -19,7 +19,7 @@ def test_parse_return_failures
end

def test_parse_return_failures_when_output_is_colored
runner = RSpec.new(read_fixture("rspec_colored.log"))
runner = RSpec.new(fixture_path("rspec_colored.log"))
runner.parse!

expected_test_name = "customer edit page displays selectable strings as dropdowns"
Expand Down
3 changes: 2 additions & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def before_setup
@home_dir = Dir.mktmpdir
ENV["HOME"] = @home_dir
ENV["TMPDIR"] = @home_dir
ENV["NO_WARNING"] = "1"

super
end
Expand All @@ -23,7 +24,7 @@ def after_teardown
FileUtils.rm_rf(@home_dir) if @home_dir
end

def read_fixture(file)
def fixture_path(file)
fixture_folder = Pathname(File.expand_path("fixtures", __dir__))
fixture_path = fixture_folder.join(file)

Expand Down
10 changes: 5 additions & 5 deletions test/test_run_finder_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -265,39 +265,39 @@ def test_find_when_there_are_no_checks
end

def test_detect_runner_minitest_1
log = read_fixture("raw_minitest_error.log")
log = fixture_path("raw_minitest_error.log")

runner = TestRunFinder.detect_runner(log.read)

assert_instance_of(Runners::MinitestRunner, runner)
end

def test_detect_runner_minitest_2
log = read_fixture("raw_minitest_failures.log")
log = fixture_path("raw_minitest_failures.log")

runner = TestRunFinder.detect_runner(log.read)

assert_instance_of(Runners::MinitestRunner, runner)
end

def test_detect_runner_minitest_3
log = read_fixture("rails.log")
log = fixture_path("rails.log")

runner = TestRunFinder.detect_runner(log.read)

assert_instance_of(Runners::MinitestRunner, runner)
end

def test_detect_runner_minitest_4
log = read_fixture("i18n.log")
log = fixture_path("i18n.log")

runner = TestRunFinder.detect_runner(log.read)

assert_instance_of(Runners::MinitestRunner, runner)
end

def test_detect_runner_rspec
log = read_fixture("rspec.log")
log = fixture_path("rspec.log")

runner = TestRunFinder.detect_runner(log.read)

Expand Down

0 comments on commit 4942584

Please sign in to comment.