Skip to content

Commit 7175204

Browse files
committed
Skip config tests on minimum Rubocop version
While we want to ensure we're always compatible with the minimum Rubocop version we declare in our gemspec, the config checks are specific to the Rubocop version listed in Gemfile.lock. As such, we skip these tests when checking against the minimum Rubocop version. Rubocop is still invoked against the repository's own code during these runs, which allows us to catch incompatible config (e.g. cops only available in new versions, deprecated config keys).
1 parent f5122f5 commit 7175204

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

.github/workflows/ruby.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ jobs:
2828
run: bundle info rubocop | head -1
2929
- name: RuboCop and Tests
3030
run: bundle exec rake
31+
env:
32+
CHECKING_RUBOCOP_VERSION_COMPATIBILITY: ${{ matrix.gemfile == 'gemfiles/minimum_rubocop.gemfile' }}

test/config_test.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
class ConfigTest < Minitest::Test
99
def test_config_is_unchanged
10+
skip if checking_rubocop_version_compatibility?
11+
1012
Rake.application.load_rakefile
1113

1214
original_config = "test/fixtures/full_config.yml"
@@ -32,6 +34,8 @@ def test_config_is_unchanged
3234
end
3335

3436
def test_config_has_no_redundant_entries
37+
skip if checking_rubocop_version_compatibility?
38+
3539
config = RuboCop::ConfigLoader.load_file("rubocop.yml")
3640
default_config = RuboCop::ConfigLoader.default_configuration
3741
redundant_config = Hash.new { |hash, key| hash[key] = {} }
@@ -57,4 +61,10 @@ def test_config_has_no_redundant_entries
5761

5862
assert(redundant_config.empty?, error_message)
5963
end
64+
65+
private
66+
67+
def checking_rubocop_version_compatibility?
68+
ENV.fetch("CHECKING_RUBOCOP_VERSION_COMPATIBILITY", "") == "true"
69+
end
6070
end

0 commit comments

Comments
 (0)