Skip to content

Commit

Permalink
Merge pull request #17482 from samford/fix-brew-style-tap-checking
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeMcQuaid committed Jun 13, 2024
2 parents 4f35bc1 + ca2ac3d commit df2387f
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 18 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ jobs:
working-directory: docs
run: bundle exec rake lint

- name: Check code blocks conform to our Ruby style guide
run: brew style docs
# TODO: reenable when possible.
# - name: Check code blocks conform to our Ruby style guide
# run: brew style docs

- name: Generate formulae.brew.sh API samples
if: github.repository == 'Homebrew/formulae.brew.sh'
Expand Down
17 changes: 13 additions & 4 deletions Library/Homebrew/style.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ def self.check_style_impl(files, output_type,
debug: false, verbose: false)
raise ArgumentError, "Invalid output type: #{output_type.inspect}" if [:print, :json].exclude?(output_type)

ruby_files = []
shell_files = []
actionlint_files = []
ruby_files = T.let([], T::Array[Pathname])
shell_files = T.let([], T::Array[Pathname])
actionlint_files = T.let([], T::Array[Pathname])
Array(files).map(&method(:Pathname))
.each do |path|
case path.extname
Expand All @@ -57,7 +57,14 @@ def self.check_style_impl(files, output_type,
when ".yml"
actionlint_files << path if path.realpath.to_s.include?("/.github/workflows/")
else
shell_files << path if path.realpath == HOMEBREW_BREW_FILE.realpath
ruby_files << path
shell_files += if [HOMEBREW_PREFIX, HOMEBREW_REPOSITORY].include?(path)
shell_scripts
else
path.glob("**/*.sh")
.reject { |path| path.to_s.include?("/vendor/") }
end
actionlint_files += (path/".github/workflows").glob("*.y{,a}ml")
end
end

Expand Down Expand Up @@ -263,8 +270,10 @@ def self.run_shfmt(files, fix: false)

def self.run_actionlint(files)
files = github_workflow_files if files.blank?
# the ignore is to avoid false positives in e.g. actions, homebrew-test-bot
system actionlint, "-shellcheck", shellcheck,
"-config-file", HOMEBREW_REPOSITORY/".github/actionlint.yaml",
"-ignore", "image: string; options: string",
*files
$CHILD_STATUS.success?
end
Expand Down
7 changes: 5 additions & 2 deletions docs/.mdl_ruleset.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
rule 'HB034', 'Bare unstyled URL used' do
# typed: true
# frozen_string_literal: true

rule "HB034", "Bare unstyled URL used" do
tags :links, :url
aliases 'no-bare-unstyled-urls'
aliases "no-bare-unstyled-urls"
check do |doc|
doc.matching_text_element_lines(%r{(?<=\s)https?://})
end
Expand Down
17 changes: 10 additions & 7 deletions docs/.mdl_style.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# typed: true
# frozen_string_literal: true

all
rule 'MD007', indent: 2 # Unordered list indentation
rule 'MD026', punctuation: ',;:' # Trailing punctuation in header
exclude_rule 'MD013' # Line length
exclude_rule 'MD029' # Ordered list item prefix
exclude_rule 'MD033' # Inline HTML
exclude_rule 'MD034' # Bare URL used (replaced by HB034)
exclude_rule 'MD046' # Code block style
rule "MD007", indent: 2 # Unordered list indentation
rule "MD026", punctuation: ",;:" # Trailing punctuation in header
exclude_rule "MD013" # Line length
exclude_rule "MD029" # Ordered list item prefix
exclude_rule "MD033" # Inline HTML
exclude_rule "MD034" # Bare URL used (replaced by HB034)
exclude_rule "MD046" # Code block style
3 changes: 0 additions & 3 deletions docs/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ inherit_from: ../Library/.rubocop.yml

AllCops:
Exclude:
- Gemfile
- ".mdl*.rb"
- Rakefile
- "_site/**/*"
- Manpage.md
- "vendor/**/*"
Expand Down
2 changes: 2 additions & 0 deletions docs/Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source "https://rubygems.org"

ruby file: ".ruby-version"
Expand Down
2 changes: 2 additions & 0 deletions docs/Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "rake"

task default: :build
Expand Down

0 comments on commit df2387f

Please sign in to comment.