mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
dev-cmd/typecheck: Delete old files from sorbet/files.yaml
- I was going through the `sorbet/files.yaml` moving various things to `true`, playing around locally, and happened upon some files that it was tracking that had been deleted. - We want to do some automation of new files, but I'm not sure we'd ever considered the possibility of code being removed. :-D - This adds a `--prune-files-list` switch and updates the Tapioca GitHub Actions workflow to use it. Any changes to the `sorbet/files.yaml` file will be committed as part of the scheduled Tapioca update job.
This commit is contained in:
parent
16f936a534
commit
3bf5136e82
2
.github/workflows/tapioca.yml
vendored
2
.github/workflows/tapioca.yml
vendored
@ -37,7 +37,7 @@ jobs:
|
|||||||
BRANCH_EXISTS="1"
|
BRANCH_EXISTS="1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if brew typecheck --update-definitions --fail-if-not-changed; then
|
if brew typecheck --prune-files-list --update-definitions --fail-if-not-changed; then
|
||||||
git add "$GITHUB_WORKSPACE/Library/Homebrew/sorbet"
|
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)."
|
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"
|
echo "::set-output name=committed::true"
|
||||||
|
@ -5,6 +5,8 @@ require "cli/parser"
|
|||||||
module Homebrew
|
module Homebrew
|
||||||
module_function
|
module_function
|
||||||
|
|
||||||
|
SORBET_FILES_YAML = "sorbet/files.yaml"
|
||||||
|
|
||||||
def typecheck_args
|
def typecheck_args
|
||||||
Homebrew::CLI::Parser.new do
|
Homebrew::CLI::Parser.new do
|
||||||
usage_banner <<~EOS
|
usage_banner <<~EOS
|
||||||
@ -16,6 +18,8 @@ module Homebrew
|
|||||||
description: "Silence all non-critical errors."
|
description: "Silence all non-critical errors."
|
||||||
switch "--update-definitions",
|
switch "--update-definitions",
|
||||||
description: "Update Tapioca gem definitions of recently bumped gems"
|
description: "Update Tapioca gem definitions of recently bumped gems"
|
||||||
|
switch "--prune-files-list",
|
||||||
|
description: "Remove deleted filepaths from #{SORBET_FILES_YAML}"
|
||||||
switch "--fail-if-not-changed",
|
switch "--fail-if-not-changed",
|
||||||
description: "Return a failing status code if all gems are up to date " \
|
description: "Return a failing status code if all gems are up to date " \
|
||||||
"and gem definitions do not need a tapioca update"
|
"and gem definitions do not need a tapioca update"
|
||||||
@ -37,6 +41,22 @@ module Homebrew
|
|||||||
Homebrew.install_bundler_gems!
|
Homebrew.install_bundler_gems!
|
||||||
|
|
||||||
HOMEBREW_LIBRARY_PATH.cd do
|
HOMEBREW_LIBRARY_PATH.cd do
|
||||||
|
if args.prune_files_list?
|
||||||
|
lines_to_keep = []
|
||||||
|
sorbet_keywords = ["true:", "false:", "strict:", "strong:"]
|
||||||
|
|
||||||
|
File.readlines(SORBET_FILES_YAML).map(&:chomp).each do |line|
|
||||||
|
if sorbet_keywords.include?(line) || line.blank?
|
||||||
|
lines_to_keep << line
|
||||||
|
elsif line.end_with?(".rb")
|
||||||
|
filepath = line.split(" ").last
|
||||||
|
lines_to_keep << line if File.exist?(filepath)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
File.write(SORBET_FILES_YAML, lines_to_keep.join("\n"))
|
||||||
|
end
|
||||||
|
|
||||||
if args.update_definitions?
|
if args.update_definitions?
|
||||||
system "bundle", "exec", "tapioca", "sync"
|
system "bundle", "exec", "tapioca", "sync"
|
||||||
system "bundle", "exec", "srb", "rbi", "hidden-definitions"
|
system "bundle", "exec", "srb", "rbi", "hidden-definitions"
|
||||||
@ -55,7 +75,7 @@ module Homebrew
|
|||||||
srb_exec += ["--file", "../#{args.file}"] if args.file
|
srb_exec += ["--file", "../#{args.file}"] if args.file
|
||||||
srb_exec += ["--dir", "../#{args.dir}"] if args.dir
|
srb_exec += ["--dir", "../#{args.dir}"] if args.dir
|
||||||
else
|
else
|
||||||
srb_exec += ["--typed-override", "sorbet/files.yaml"]
|
srb_exec += ["--typed-override", SORBET_FILES_YAML]
|
||||||
end
|
end
|
||||||
Homebrew.failed = !system(*srb_exec)
|
Homebrew.failed = !system(*srb_exec)
|
||||||
end
|
end
|
||||||
|
@ -1236,6 +1236,8 @@ Check for typechecking errors using Sorbet.
|
|||||||
Silence all non-critical errors.
|
Silence all non-critical errors.
|
||||||
* `--update-definitions`:
|
* `--update-definitions`:
|
||||||
Update Tapioca gem definitions of recently bumped gems
|
Update Tapioca gem definitions of recently bumped gems
|
||||||
|
* `--prune-files-list`:
|
||||||
|
Remove deleted filepaths from sorbet/files.yaml
|
||||||
* `--fail-if-not-changed`:
|
* `--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
|
Return a failing status code if all gems are up to date and gem definitions do not need a tapioca update
|
||||||
* `--dir`:
|
* `--dir`:
|
||||||
|
@ -1702,6 +1702,10 @@ Silence all non\-critical errors\.
|
|||||||
Update Tapioca gem definitions of recently bumped gems
|
Update Tapioca gem definitions of recently bumped gems
|
||||||
.
|
.
|
||||||
.TP
|
.TP
|
||||||
|
\fB\-\-prune\-files\-list\fR
|
||||||
|
Remove deleted filepaths from sorbet/files\.yaml
|
||||||
|
.
|
||||||
|
.TP
|
||||||
\fB\-\-fail\-if\-not\-changed\fR
|
\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
|
Return a failing status code if all gems are up to date and gem definitions do not need a tapioca update
|
||||||
.
|
.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user