Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync/shared-config: tweak rubocop. #111

Merged
merged 1 commit into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions .github/actions/sync/shared-config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
require "fileutils"
require "open3"
require "pathname"
require "yaml"

# This makes sense for a standalone script.
# rubocop:disable Style/TopLevelMethodDefinition
Expand All @@ -26,8 +27,16 @@ def git(*args)
rubocop_yml = ".rubocop.yml"

homebrew_ruby_version =
(homebrew_repository_path/"Library/Homebrew/vendor/portable-ruby-version").read.chomp.sub(/_\d+$/, "")
homebrew_rubocop_config = homebrew_repository_path/"Library/Homebrew/#{rubocop_yml}"
(homebrew_repository_path/"Library/Homebrew/vendor/portable-ruby-version").read
.chomp
.sub(/_\d+$/, "")
homebrew_rubocop_config_yaml = YAML.load_file(
homebrew_repository_path/"Library/#{rubocop_yml}",
permitted_classes: [Symbol, Regexp],
)
homebrew_rubocop_config = homebrew_rubocop_config_yaml.reject do |key, _|
key.match?(%r{\Arequire|inherit_from|inherit_mode|Cask/|Formula|Homebrew/|Performance/|RSpec|Sorbet/})
end.to_yaml

puts "Detecting changes…"
[
Expand All @@ -43,7 +52,7 @@ def git(*args)
when ruby_version
target_path.write("#{homebrew_ruby_version}\n")
when rubocop_yml
FileUtils.cp homebrew_rubocop_config, target_path
target_path.write("#{homebrew_rubocop_config}\n")
else
FileUtils.cp file, target_path
end
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/sync-shared-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ jobs:
with:
signing_key: ${{ secrets.BREWTESTBOT_GPG_SIGNING_SUBKEY }}

- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true

- name: Detect changes
id: detect_changes
env:
Expand Down