Merge pull request #8289 from vidusheeamoli/brew-typecheck
dev-cmd: add `brew typecheck` command
This commit is contained in:
commit
2f3fb6f3c2
19
.github/workflows/tapioca.yml
vendored
19
.github/workflows/tapioca.yml
vendored
@ -21,17 +21,6 @@ jobs:
|
||||
with:
|
||||
username: BrewTestBot
|
||||
|
||||
# TODO: remove with `brew typecheck`
|
||||
- name: Set up Ruby
|
||||
uses: actions/setup-ruby@main
|
||||
with:
|
||||
ruby-version: '2.6'
|
||||
- name: Install RubyGems
|
||||
run: |
|
||||
cd "$GITHUB_WORKSPACE/Library/Homebrew"
|
||||
gem install bundler -v "~>1"
|
||||
bundle install --jobs 4 --retry 3
|
||||
|
||||
- name: Update Tapioca definitions
|
||||
id: update
|
||||
run: |
|
||||
@ -48,13 +37,7 @@ jobs:
|
||||
BRANCH_EXISTS="1"
|
||||
fi
|
||||
|
||||
# TODO: replace with `brew typecheck`
|
||||
cd "$GITHUB_WORKSPACE/Library/Homebrew"
|
||||
bundle exec tapioca sync --exclude json
|
||||
bundle exec srb rbi hidden-definitions
|
||||
if ! git diff --no-patch --exit-code -- sorbet; then
|
||||
|
||||
# if brew typecheck --update --fail-if-not-changed; then
|
||||
if brew typecheck --update-definitions --fail-if-not-changed; then
|
||||
git add "$GITHUB_WORKSPACE/Library/Homebrew/sorbet"
|
||||
git commit -m "sorbet: update RBI files using Tapioca." -m "Autogenerated by [a scheduled GitHub Action](https://github.com/Homebrew/brew/blob/master/.github/workflows/tapioca.yml)."
|
||||
echo "::set-output name=committed::true"
|
||||
|
||||
3
.github/workflows/tests.yml
vendored
3
.github/workflows/tests.yml
vendored
@ -120,6 +120,9 @@ jobs:
|
||||
- name: Run brew audit --skip-style on all taps
|
||||
run: brew audit --skip-style
|
||||
|
||||
# TODO: remove --quiet when possible.
|
||||
- run: brew typecheck --quiet
|
||||
|
||||
- name: Run vale for docs linting
|
||||
run: |
|
||||
brew install vale
|
||||
|
||||
62
Library/Homebrew/dev-cmd/typecheck.rb
Normal file
62
Library/Homebrew/dev-cmd/typecheck.rb
Normal file
@ -0,0 +1,62 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "cli/parser"
|
||||
|
||||
module Homebrew
|
||||
module_function
|
||||
|
||||
def typecheck_args
|
||||
Homebrew::CLI::Parser.new do
|
||||
usage_banner <<~EOS
|
||||
`typecheck`
|
||||
|
||||
Check for typechecking errors using Sorbet.
|
||||
EOS
|
||||
switch "-q", "--quiet",
|
||||
description: "Silence all non-critical errors."
|
||||
switch "--update-definitions",
|
||||
description: "Update Tapioca gem definitions of recently bumped gems"
|
||||
switch "--fail-if-not-changed",
|
||||
description: "Return a failing status code if all gems are up to date " \
|
||||
"and gem definitions do not need a tapioca update"
|
||||
flag "--dir=",
|
||||
description: "Typecheck all files in a specific directory."
|
||||
flag "--file=",
|
||||
description: "Typecheck a single file."
|
||||
flag "--ignore=",
|
||||
description: "Ignores input files that contain the given string " \
|
||||
"in their paths (relative to the input path passed to Sorbet)."
|
||||
conflicts "--dir", "--file"
|
||||
max_named 0
|
||||
end
|
||||
end
|
||||
|
||||
def typecheck
|
||||
args = typecheck_args.parse
|
||||
|
||||
Homebrew.install_bundler_gems!
|
||||
|
||||
HOMEBREW_LIBRARY_PATH.cd do
|
||||
if args.update_definitions?
|
||||
system "bundle", "exec", "tapioca", "sync"
|
||||
system "bundle", "exec", "srb", "rbi", "hidden-definitions"
|
||||
|
||||
Homebrew.failed = system("git", "diff", "--stat", "--exit-code") if args.fail_if_not_changed?
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
srb_exec = %w[bundle exec srb tc]
|
||||
srb_exec << "--quiet" if args.quiet?
|
||||
srb_exec += ["--ignore", args.ignore] if args.ignore.present?
|
||||
if args.file.present? || args.dir.present?
|
||||
cd("sorbet")
|
||||
srb_exec += ["--file", "../#{args.file}"] if args.file
|
||||
srb_exec += ["--dir", "../#{args.dir}"] if args.dir
|
||||
else
|
||||
srb_exec += ["--typed-override", "sorbet/files.yaml"]
|
||||
end
|
||||
Homebrew.failed = !system(*srb_exec)
|
||||
end
|
||||
end
|
||||
end
|
||||
7
Library/Homebrew/test/dev-cmd/typecheck_spec.rb
Normal file
7
Library/Homebrew/test/dev-cmd/typecheck_spec.rb
Normal file
@ -0,0 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.typecheck_args" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
@ -81,6 +81,7 @@ tap-info
|
||||
tap-new
|
||||
test
|
||||
tests
|
||||
typecheck
|
||||
uninstal
|
||||
uninstall
|
||||
unlink
|
||||
|
||||
@ -1178,6 +1178,23 @@ Run Homebrew's unit and integration tests.
|
||||
* `--seed`:
|
||||
Randomise tests with the specified *`value`* instead of a random seed.
|
||||
|
||||
### `typecheck`
|
||||
|
||||
Check for typechecking errors using Sorbet.
|
||||
|
||||
* `-q`, `--quiet`:
|
||||
Silence all non-critical errors.
|
||||
* `--update-definitions`:
|
||||
Update Tapioca gem definitions of recently bumped gems
|
||||
* `--fail-if-not-changed`:
|
||||
Return a failing status code if all gems are up to date and gem definitions do not need a tapioca update
|
||||
* `--dir`:
|
||||
Typecheck all files in a specific directory.
|
||||
* `--file`:
|
||||
Typecheck a single file.
|
||||
* `--ignore`:
|
||||
Ignores input files that contain the given string in their paths (relative to the input path passed to Sorbet).
|
||||
|
||||
### `unpack` [*`options`*] *`formula`*
|
||||
|
||||
Unpack the source files for *`formula`* into subdirectories of the current
|
||||
|
||||
@ -1610,6 +1610,33 @@ Run only \fItest_script\fR\fB_spec\.rb\fR\. Appending \fB:\fR\fIline_number\fR w
|
||||
\fB\-\-seed\fR
|
||||
Randomise tests with the specified \fIvalue\fR instead of a random seed\.
|
||||
.
|
||||
.SS "\fBtypecheck\fR"
|
||||
Check for typechecking errors using Sorbet\.
|
||||
.
|
||||
.TP
|
||||
\fB\-q\fR, \fB\-\-quiet\fR
|
||||
Silence all non\-critical errors\.
|
||||
.
|
||||
.TP
|
||||
\fB\-\-update\-definitions\fR
|
||||
Update Tapioca gem definitions of recently bumped gems
|
||||
.
|
||||
.TP
|
||||
\fB\-\-fail\-if\-not\-changed\fR
|
||||
Return a failing status code if all gems are up to date and gem definitions do not need a tapioca update
|
||||
.
|
||||
.TP
|
||||
\fB\-\-dir\fR
|
||||
Typecheck all files in a specific directory\.
|
||||
.
|
||||
.TP
|
||||
\fB\-\-file\fR
|
||||
Typecheck a single file\.
|
||||
.
|
||||
.TP
|
||||
\fB\-\-ignore\fR
|
||||
Ignores input files that contain the given string in their paths (relative to the input path passed to Sorbet)\.
|
||||
.
|
||||
.SS "\fBunpack\fR [\fIoptions\fR] \fIformula\fR"
|
||||
Unpack the source files for \fIformula\fR into subdirectories of the current working directory\.
|
||||
.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user