From 91246b149aa6a5a419d4a1b37bf5ff3eb82c77f8 Mon Sep 17 00:00:00 2001 From: Peter Cai <222655+pcai@users.noreply.github.com> Date: Sat, 28 Sep 2024 16:28:01 +0000 Subject: [PATCH] get tests working again maybe --- .devcontainer/devcontainer.json | 22 ++++++ .github/workflows/ci.yml | 81 +++++++++++++---------- Gemfile | 2 +- derailed_benchmarks.gemspec | 15 ++++- gemfiles/rails_6_0.gemfile | 3 +- gemfiles/rails_6_1.gemfile | 2 +- gemfiles/rails_7_0.gemfile | 4 +- lib/derailed_benchmarks/stats_from_dir.rb | 7 +- test/integration/tasks_test.rb | 10 +-- 9 files changed, 97 insertions(+), 49 deletions(-) create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..6c6df7e --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,22 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/ruby +{ + "name": "Ruby", + // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile + "image": "mcr.microsoft.com/devcontainers/ruby:1-3.3-bullseye" + + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "ruby --version", + + // Configure tool-specific properties. + // "customizations": {}, + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3ba0385..153b739 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,42 +10,51 @@ jobs: strategy: fail-fast: false matrix: - ruby: - - '2.5.8' - - '2.7.2' - - '3.0.0' - - '3.1.2' - - 'head' - gemfile: - - gemfiles/rails_5_1.gemfile - - gemfiles/rails_5_2.gemfile - - gemfiles/rails_6_0.gemfile - - gemfiles/rails_6_1.gemfile - - gemfiles/rails_7_0.gemfile - - gemfiles/rails_head.gemfile - exclude: - - ruby: "2.5.8" - gemfile: gemfiles/rails_7_0.gemfile - - ruby: "2.5.8" - gemfile: gemfiles/rails_head.gemfile - - ruby: "2.7.2" - gemfile: gemfiles/rails_head.gemfile - - ruby: "3.0.0" - gemfile: gemfiles/rails_5_1.gemfile - - ruby: "3.0.0" - gemfile: gemfiles/rails_5_2.gemfile - - ruby: "3.1.2" - gemfile: gemfiles/rails_5_1.gemfile - - ruby: "3.1.2" - gemfile: gemfiles/rails_5_2.gemfile - - ruby: "3.1.2" - gemfile: gemfiles/rails_6_0.gemfile - - ruby: "head" - gemfile: gemfiles/rails_5_1.gemfile - - ruby: "head" - gemfile: gemfiles/rails_5_2.gemfile - - ruby: "head" - gemfile: gemfiles/rails_6_0.gemfile + include: + - ruby: "2.5" + gemfile: gemfiles/rails_5_1.gemfile + - ruby: "2.5" + gemfile: gemfiles/rails_5_2.gemfile + - ruby: "2.5" + gemfile: gemfiles/rails_6_0.gemfile + - ruby: "2.5" + gemfile: gemfiles/rails_6_1.gemfile + - ruby: "2.7" + gemfile: gemfiles/rails_5_1.gemfile + - ruby: "2.7" + gemfile: gemfiles/rails_5_2.gemfile + - ruby: "2.7" + gemfile: gemfiles/rails_6_0.gemfile + - ruby: "2.7" + gemfile: gemfiles/rails_6_1.gemfile + - ruby: "2.7" + gemfile: gemfiles/rails_7_0.gemfile + - ruby: "3.0" + gemfile: gemfiles/rails_6_0.gemfile + - ruby: "3.0" + gemfile: gemfiles/rails_6_1.gemfile + - ruby: "3.0" + gemfile: gemfiles/rails_7_0.gemfile + - ruby: "3.1" + gemfile: gemfiles/rails_6_0.gemfile + - ruby: "3.1" + gemfile: gemfiles/rails_6_1.gemfile + - ruby: "3.1" + gemfile: gemfiles/rails_7_0.gemfile + - ruby: "3.2" + gemfile: gemfiles/rails_6_0.gemfile + - ruby: "3.2" + gemfile: gemfiles/rails_6_1.gemfile + - ruby: "3.2" + gemfile: gemfiles/rails_7_0.gemfile + - ruby: "3.3" + gemfile: gemfiles/rails_6_0.gemfile + - ruby: "3.3" + gemfile: gemfiles/rails_6_1.gemfile + - ruby: "3.3" + gemfile: gemfiles/rails_7_0.gemfile + - ruby: "head" + gemfile: gemfiles/rails_head.gemfile env: BUNDLE_GEMFILE: ${{ github.workspace }}/${{ matrix.gemfile }} steps: diff --git a/Gemfile b/Gemfile index 4aa1cf6..b0799e1 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ source 'https://rubygems.org' gemspec group :development, :test do - gem "sqlite3", :platform => [:ruby, :mswin, :mingw] + gem "sqlite3", '~> 1.4', :platform => [:ruby, :mswin, :mingw] gem "activerecord-jdbcsqlite3-adapter", '~> 1.3.13', :platform => :jruby gem "test-unit", "~> 3.0" end diff --git a/derailed_benchmarks.gemspec b/derailed_benchmarks.gemspec index ba3ebb6..592d7ff 100644 --- a/derailed_benchmarks.gemspec +++ b/derailed_benchmarks.gemspec @@ -29,15 +29,26 @@ Gem::Specification.new do |gem| gem.add_dependency "rack", ">= 1" gem.add_dependency "rake", "> 10", "< 14" gem.add_dependency "thor", ">= 0.19", "< 2" - gem.add_dependency "ruby-statistics", ">= 2.1" + if RUBY_VERSION >= '3.0' + gem.add_dependency "ruby-statistics", ">= 4.0" + else + gem.add_dependency "ruby-statistics", ">= 2.1" + end gem.add_dependency "mini_histogram", ">= 0.3.0" gem.add_dependency "dead_end", ">= 0" gem.add_dependency "rack-test", ">= 0" + gem.add_dependency "base64", ">= 0" + gem.add_dependency "mutex_m", ">= 0" + gem.add_dependency "bigdecimal", ">= 0" + gem.add_dependency "drb", ">= 0" + gem.add_dependency "logger", ">= 0" + gem.add_dependency "ostruct", ">= 0" + gem.add_dependency "ruby2_keywords", ">= 0" gem.add_development_dependency "appraisal" gem.add_development_dependency "webrick", ">= 0" gem.add_development_dependency "capybara", "~> 2" gem.add_development_dependency "m" - gem.add_development_dependency "rails", "> 3", "<= 7" + gem.add_development_dependency "rails", "> 3", "< 7.1" gem.add_development_dependency "devise", "> 3", "< 6" end diff --git a/gemfiles/rails_6_0.gemfile b/gemfiles/rails_6_0.gemfile index ebadaec..d3cb625 100644 --- a/gemfiles/rails_6_0.gemfile +++ b/gemfiles/rails_6_0.gemfile @@ -5,9 +5,10 @@ source "https://rubygems.org" gem "rails", "~> 6.0.0" group :development, :test do - gem "sqlite3", platform: [:ruby, :mswin, :mingw] + gem "sqlite3", '~> 1.4', platform: [:ruby, :mswin, :mingw] gem "activerecord-jdbcsqlite3-adapter", "~> 1.3.13", platform: :jruby gem "test-unit", "~> 3.0" + gem "psych", "~> 3.0" end gemspec path: "../" diff --git a/gemfiles/rails_6_1.gemfile b/gemfiles/rails_6_1.gemfile index 0535ff7..296d544 100644 --- a/gemfiles/rails_6_1.gemfile +++ b/gemfiles/rails_6_1.gemfile @@ -8,7 +8,7 @@ gem "net-imap", require: false gem "net-pop", require: false group :development, :test do - gem "sqlite3", platform: [:ruby, :mswin, :mingw] + gem "sqlite3", '~> 1.4', platform: [:ruby, :mswin, :mingw] gem "activerecord-jdbcsqlite3-adapter", "~> 1.3.13", platform: :jruby gem "test-unit", "~> 3.0" end diff --git a/gemfiles/rails_7_0.gemfile b/gemfiles/rails_7_0.gemfile index 642d3e2..c872899 100644 --- a/gemfiles/rails_7_0.gemfile +++ b/gemfiles/rails_7_0.gemfile @@ -2,10 +2,10 @@ source "https://rubygems.org" -gem "rails", "~> 7.0" +gem "rails", "~> 7.0.0" group :development, :test do - gem "sqlite3", platform: [:ruby, :mswin, :mingw] + gem "sqlite3", '~> 1.4', platform: [:ruby, :mswin, :mingw] gem "activerecord-jdbcsqlite3-adapter", "~> 1.3.13", platform: :jruby gem "test-unit", "~> 3.0" end diff --git a/lib/derailed_benchmarks/stats_from_dir.rb b/lib/derailed_benchmarks/stats_from_dir.rb index 5c107e3..885917c 100644 --- a/lib/derailed_benchmarks/stats_from_dir.rb +++ b/lib/derailed_benchmarks/stats_from_dir.rb @@ -1,7 +1,12 @@ # frozen_string_literal: true require 'bigdecimal' -require 'statistics' +# keep this in sync with gemspec +if RUBY_VERSION >= '3.0' + require 'ruby-statistics' +else + require 'statistics' +end require 'stringio' require 'mini_histogram' require 'mini_histogram/plot' diff --git a/test/integration/tasks_test.rb b/test/integration/tasks_test.rb index efad807..faa902f 100644 --- a/test/integration/tasks_test.rb +++ b/test/integration/tasks_test.rb @@ -120,18 +120,18 @@ def rake(cmd, options = {}) env = { "PATH_TO_HIT" => 'foo_secret', "TEST_COUNT" => "2", - "HTTP_AUTHORIZATION" => "Basic #{Base64.encode64("admin:secret")}", + "HTTP_AUTHORIZATION" => "Basic #{Base64.strict_encode64("admin:secret")}", "HTTP_CACHE_CONTROL" => "no-cache" } result = rake "perf:test", env: env assert_match 'Endpoint: "foo_secret"', result - assert_match /"Authorization"=>"Basic YWRtaW46c2VjcmV0\\n"/ , result - assert_match /"Cache-Control"=>"no-cache"/ , result + assert_match (/"Authorization"=>"Basic YWRtaW46c2VjcmV0"/), result + assert_match (/"Cache-Control"=>"no-cache"/), result env["USE_SERVER"] = "webrick" result = rake "perf:test", env: env - assert_match /"Authorization"=>"Basic YWRtaW46c2VjcmV0\\n"/ , result - assert_match /"Cache-Control"=>"no-cache"/ , result + assert_match (/"Authorization"=>"Basic YWRtaW46c2VjcmV0"/), result + assert_match (/"Cache-Control"=>"no-cache"/), result end test 'USE_SERVER' do