ci: Add an Action to check RuboCop filepaths

- This will stop the `Style/Documentation` filepath includes getting out of
  sync with what we declare as a public API, thus ensuring that everything is
  documented.
- Maybe we could also add a job here to check that _all_ the paths in the
  RuboCop config still exist, but that's for another time.
This commit is contained in:
Issy Long 2023-02-27 23:38:34 +00:00
parent 9ec74fea2a
commit 93e2f86cf8
No known key found for this signature in database
GPG Key ID: 8247C390DADC67D4

29
.github/workflows/rubocop-filepaths.yml vendored Normal file
View File

@ -0,0 +1,29 @@
name: RuboCop filepaths
on:
push:
branches:
- master
pull_request:
jobs:
check:
runs-on: ubuntu-22.04
if: github.repository == 'Homebrew/brew'
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Check public API docs
working-directory: Library/Homebrew
run: |
public_apis=$(git grep -l "@api public" | wc -l | tr -d ' ')
rubocop_docs=$(yq '.Style/Documentation.Include' .rubocop.yml | wc -l | tr -d ' ')
if [[ public_apis -ne rubocop_docs ]]
then
echo "All public Homebrew APIs should be included in the Style/Documentation RuboCop."
echo "There were ${public_apis} '@api public' lines but ${rubocop_docs} filepaths for the 'Style/Documentation' RuboCop."
echo "Add or remove the filepaths from Library/Homebrew/.rubocop.yml as appropriate."
exit 1
fi