Skip to content

Commit

Permalink
Raise on ruby 2.7 deprecation warnings
Browse files Browse the repository at this point in the history
Break tests if we introduce any ruby 2.7 deprecation warnings.
  • Loading branch information
feelepxyz committed Jun 16, 2021
1 parent 5f53c97 commit 328b63a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ jobs:
run: |
docker run \
--env "CI=true" \
--env "RAISE_ON_WARNINGS=true" \
--env "DEPENDABOT_TEST_ACCESS_TOKEN=${{ secrets.GITHUB_TOKEN }}" \
--env "SUITE_NAME=${{ matrix.suite.name }}" \
--rm "$CORE_CI_IMAGE" bash -c \
Expand Down
1 change: 1 addition & 0 deletions common/spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

require "dependabot/dependency_file"
require_relative "dummy_package_manager/dummy"
require_relative "warning_monkey_patch"

if ENV["COVERAGE"]
SimpleCov::Formatter::Console.output_style = "block"
Expand Down
23 changes: 23 additions & 0 deletions common/spec/warning_monkey_patch.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

ALLOW_PATTERNS = [
# Ignore parser warnings for ruby 2.7 minor version mismatches
# TODO: Fix these by upgrading to ruby 2.7.3 (requires ubuntu upgrade)
%r{parser/current is loading parser/ruby27},
/2.7.\d-compliant syntax, but you are running 2.7.\d/,
%r{whitequark/parser}
].freeze

# Called internally by Ruby for all warnings
module Warning
def self.warn(message)
$stderr.print(message)

raise message if ENV["RAISE_ON_WARNINGS"].to_s == "true" && ALLOW_PATTERNS.none? { |pattern| pattern =~ message }

return unless ENV["DEBUG_WARNINGS"]

warn caller
$stderr.puts
end
end

0 comments on commit 328b63a

Please sign in to comment.