Skip to content

Commit

Permalink
Merge pull request #286 from Shopify/ko/filter-version-in-test
Browse files Browse the repository at this point in the history
Filter versions while testing
  • Loading branch information
KaanOzkan authored Sep 30, 2024
2 parents ca8d726 + b5f3391 commit e7e03ce
Show file tree
Hide file tree
Showing 50 changed files with 59,509 additions and 56,577 deletions.
91 changes: 42 additions & 49 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ PATH
rbi-central (0.0.1)
bigdecimal (>= 3.0.0)
json-schema (>= 3.0.0)
rbi (>= 0.1.0)
rbi (>= 0.1.9)
rubocop (>= 1.29.1)
rubocop-shopify (>= 2.5.0)
rubocop-sorbet (>= 0.6.11)
Expand All @@ -16,80 +16,73 @@ PATH
GEM
remote: https://rubygems.org/
specs:
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
ast (2.4.2)
bigdecimal (3.1.8)
erubi (1.12.0)
json (2.7.1)
json-schema (4.1.1)
addressable (>= 2.8)
erubi (1.13.0)
json (2.7.2)
json-schema (5.0.0)
addressable (~> 2.8)
language_server-protocol (3.17.0.3)
netrc (0.11.0)
parallel (1.24.0)
parser (3.3.0.2)
parallel (1.26.3)
parser (3.3.5.0)
ast (~> 2.4.1)
racc
prettier_print (1.2.1)
prism (0.19.0)
public_suffix (5.0.4)
racc (1.7.3)
prism (1.0.0)
public_suffix (6.0.1)
racc (1.8.1)
rainbow (3.1.1)
rbi (0.1.6)
prism (>= 0.18.0, < 0.20)
rbi (0.2.0)
prism (~> 1.0)
sorbet-runtime (>= 0.5.9204)
regexp_parser (2.9.0)
rexml (3.3.6)
strscan
rubocop (1.59.0)
regexp_parser (2.9.2)
rubocop (1.66.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.2.2.4)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.30.0, < 2.0)
regexp_parser (>= 2.4, < 3.0)
rubocop-ast (>= 1.32.2, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.30.0)
parser (>= 3.2.1.0)
rubocop-shopify (2.14.0)
rubocop-ast (1.32.3)
parser (>= 3.3.1.0)
rubocop-shopify (2.15.1)
rubocop (~> 1.51)
rubocop-sorbet (0.8.5)
rubocop (>= 1)
ruby-progressbar (1.13.0)
sorbet (0.5.11221)
sorbet-static (= 0.5.11221)
sorbet-runtime (0.5.11221)
sorbet-static (0.5.11221-universal-darwin)
sorbet-static (0.5.11221-x86_64-linux)
sorbet-static-and-runtime (0.5.11221)
sorbet (= 0.5.11221)
sorbet-runtime (= 0.5.11221)
spoom (1.2.4)
sorbet (0.5.11585)
sorbet-static (= 0.5.11585)
sorbet-runtime (0.5.11585)
sorbet-static (0.5.11585-universal-darwin)
sorbet-static (0.5.11585-x86_64-linux)
sorbet-static-and-runtime (0.5.11585)
sorbet (= 0.5.11585)
sorbet-runtime (= 0.5.11585)
spoom (1.4.2)
erubi (>= 1.10.0)
prism (>= 0.28.0)
sorbet-static-and-runtime (>= 0.5.10187)
syntax_tree (>= 6.1.1)
thor (>= 0.19.2)
strscan (3.1.0)
syntax_tree (6.2.0)
prettier_print (>= 1.2.0)
tapioca (0.12.0)
tapioca (0.16.2)
bundler (>= 2.2.25)
netrc (>= 0.11.0)
parallel (>= 1.21.0)
rbi (>= 0.1.4, < 0.2)
sorbet-static-and-runtime (>= 0.5.10820)
spoom (~> 1.2.0, >= 1.2.0)
rbi (~> 0.2)
sorbet-static-and-runtime (>= 0.5.11087)
spoom (>= 1.2.0)
thor (>= 1.2.0)
yard-sorbet
thor (1.3.0)
unicode-display_width (2.5.0)
yard (0.9.36)
yard-sorbet (0.8.1)
sorbet-runtime (>= 0.5)
yard (>= 0.9)
thor (1.3.2)
unicode-display_width (2.6.0)
yard (0.9.37)
yard-sorbet (0.9.0)
sorbet-runtime
yard

PLATFORMS
arm64-darwin-21
Expand Down
2 changes: 1 addition & 1 deletion gem/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ PATH
rbi-central (0.0.1)
bigdecimal (>= 3.0.0)
json-schema (>= 3.0.0)
rbi (>= 0.1.0)
rbi (>= 0.1.9)
rubocop (>= 1.29.1)
rubocop-shopify (>= 2.5.0)
rubocop-sorbet (>= 0.6.11)
Expand Down
3 changes: 3 additions & 0 deletions gem/lib/rbi-central.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ module RBICentral
Sorbet/EnforceSignatures:
Enabled: true
Lint/DuplicateMethods:
Enabled: false
YML

class Error < StandardError; end
Expand Down
11 changes: 11 additions & 0 deletions gem/lib/rbi-central/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,16 @@ def add_gem_dependency(name, version: nil, github: nil, branch: nil, ref: nil, p
line << "\n"
write_gemfile!(line, append: true)
end

private

sig { params(gem_name: String, annotations_file: String).returns(String) }
def filter_versions_from_annotation(gem_name, annotations_file)
gem_version = ::Gem::Version.new(gem_version_from_gemfile_lock(gem_name))
rbi = RBI::Parser.parse_file(annotations_file)
rbi.filter_versions!(gem_version)

rbi.string
end
end
end
9 changes: 5 additions & 4 deletions gem/lib/rbi-central/static/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,17 @@ def run!
errors = super
return errors if errors.any?

filtered_rbi = filter_versions_from_annotation(@gem.name, @annotations_file)

# Write the filtered annotation to the context folder
write!(@annotations_file, filtered_rbi)

res = bundle_exec("tapioca gem --no-doc --post requires.rb")
unless res.status
errors << Error.new(T.must(res.err).lstrip)
return errors
end

# Copy annotations file inside the context so path look relative
FileUtils.mkdir_p("#{absolute_path}/rbi/annotations")
FileUtils.cp(@annotations_file, "#{absolute_path}/#{@annotations_file}")

res = bundle_exec("tapioca check-shims --no-payload " \
"--gem-rbi-dir=sorbet/rbi/gems " \
"--shim-rbi-dir=rbi/annotations " \
Expand Down
2 changes: 1 addition & 1 deletion gem/rbi-central.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Gem::Specification.new do |spec|

spec.add_dependency("bigdecimal", ">= 3.0.0")
spec.add_dependency("json-schema", ">= 3.0.0")
spec.add_dependency("rbi", ">= 0.1.0")
spec.add_dependency("rbi", ">= 0.1.9")
spec.add_dependency("rubocop", ">= 1.29.1")
spec.add_dependency("rubocop-shopify", ">= 2.5.0")
spec.add_dependency("rubocop-sorbet", ">= 0.6.11")
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions gem/sorbet/rbi/gems/[email protected]

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e7e03ce

Please sign in to comment.