Skip to content

Commit

Permalink
actions/sync/shared-config: further improve docs rubocop sync.
Browse files Browse the repository at this point in the history
- filter out unnecessary cops from the docs rubocop config
- add a comment to the synced docs rubocop config file
  • Loading branch information
MikeMcQuaid committed Aug 23, 2024
1 parent f5942a3 commit 914118d
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions .github/actions/sync/shared-config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ def git(*args)
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
homebrew_docs_rubocop_config_yaml = YAML.load_file(
homebrew_repository_path/"docs/#{rubocop_yaml}",
permitted_classes: [Symbol, Regexp],
)
homebrew_docs_rubocop_config = homebrew_docs_rubocop_config_yaml.reject do |key, _|
key.match?(%r{\AFormulaAudit/|Sorbet/})
end.to_yaml
.sub('inherit_from: "../Library/.rubocop.yml"', 'inherit_from: "../.rubocop.yml"')
homebrew_docs_workflow_yaml = homebrew_repository_path/docs_workflow_yaml
homebrew_vale_ini = homebrew_repository_path/vale_ini

Expand Down Expand Up @@ -140,10 +148,11 @@ def git(*args)
FileUtils.ln_s "../#{docs_path_basename}", "."
end
elsif docs_path_basename == ".rubocop.yml"
docs_rubocop = docs_path.read
.sub("inherit_from: ../Library/.rubocop.yml",
"inherit_from: ../.rubocop.yml")
target_docs_path.write(docs_rubocop)
FileUtils.rm_f target_docs_path
target_docs_path.write(
"# This file is synced from `Homebrew/brew` by the `.github` repository, do not modify it directly.\n" \
"#{homebrew_docs_rubocop_config}\n",
)
else
FileUtils.cp docs_path, target_docs_path
end
Expand Down

0 comments on commit 914118d

Please sign in to comment.