Skip to content

Commit

Permalink
Introduce Sorbet
Browse files Browse the repository at this point in the history
  • Loading branch information
Bo98 committed Sep 27, 2024
1 parent a2fb915 commit 7ae2b5f
Show file tree
Hide file tree
Showing 49 changed files with 28,842 additions and 275 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
.gitignore
.rubocop.yml
deployment/
sorbet/
state.json
42 changes: 42 additions & 0 deletions .github/scripts/tapioca-exclude-check.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require "bundler"
require "psych"

RBI_ALLOWLIST = %w[
addressable
faraday
jwt
octokit
rack-session
rack
sinatra
].freeze

tapioca_config = Psych.safe_load_file("sorbet/tapioca/config.yml")
tapioca_excludes = tapioca_config.dig("gem", "exclude")

gem_names = Bundler.locked_gems.specs.map(&:name).uniq
gem_names.reject! { |name| name.match?(/\Asorbet(?:-(?:static(?:-.*)?|runtime))?\z/) } # Implicitly excluded

allowed_and_excluded = RBI_ALLOWLIST & tapioca_excludes
unless allowed_and_excluded.empty?
$stderr.puts "Tapioca excludes contains gems in the allowlist!"
$stderr.puts "Gems affected: #{allowed_and_excluded.join(", ")}"
exit(1)
end

new_gems = gem_names - tapioca_excludes - RBI_ALLOWLIST
unless new_gems.empty?
$stderr.puts "New gems were added that may need to be added to the Tapioca exclude list."
$stderr.puts "Gems affected: #{new_gems.join(", ")}"
exit(1)
end

extra_excludes = tapioca_excludes - gem_names
unless new_gems.empty?
$stderr.puts "Tapioca exclude list contains gems that are not in the Gemfile.lock"
$stderr.puts "Gems affected: #{extra_excludes.join(", ")}"
exit(1)
end
9 changes: 9 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ jobs:
with:
bundler-cache: true

- name: Check Tapioca excludes
run: bundle exec ./.github/scripts/tapioca-exclude-check.rb

- name: Check RBI shims
run: bundle exec tapioca check-shims

- name: Run Sorbet typecheck
run: bundle exec srb tc

- name: Run RuboCop
run: bundle exec rubocop

Expand Down
24 changes: 24 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
require:
- rubocop-performance
- rubocop-sorbet

AllCops:
TargetRubyVersion: 3.3
NewCops: enable
inherit_mode:
merge:
- Include
Include:
- .*/*.rb

Layout/CaseIndentation:
EnforcedStyle: end
Expand Down Expand Up @@ -45,6 +51,24 @@ Metrics/MethodLength:
Metrics/ParameterLists:
CountKeywordArgs: false

# Incompatible with Sorbet
Naming/BlockForwarding:
Enabled: false

Sorbet/FalseSigil:
Enabled: false
Sorbet/StrictSigil:
Enabled: true
Include:
- src/server.rb
- src/github_client.rb
Sorbet/StrongSigil:
Enabled: true
Exclude:
- src/server.rb
- src/github_client.rb
- src/octokit/*.rb

Style/AndOr:
EnforcedStyle: always

Expand Down
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ gem "orka_api_client", git: "https://github.com/Homebrew/orka_api_client"
gem "puma"
gem "rackup"
gem "sinatra"
gem "sorbet-runtime"

group :development, optional: true do
gem "rubocop"
gem "rubocop-performance"
gem "rubocop-sorbet"
gem "sorbet-static-and-runtime"
gem "tapioca"
end
45 changes: 44 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ GEM
public_suffix (>= 2.0.2, < 7.0)
ast (2.4.2)
base64 (0.2.0)
erubi (1.13.0)
faraday (2.12.0)
faraday-net_http (>= 2.0, < 3.4)
json
Expand All @@ -33,6 +34,7 @@ GEM
ruby2_keywords (~> 0.0.1)
net-http (0.4.1)
uri
netrc (0.11.0)
nio4r (2.7.3)
octokit (9.1.0)
faraday (>= 1, < 3)
Expand All @@ -41,6 +43,7 @@ GEM
parser (3.3.5.0)
ast (~> 2.4.1)
racc
prism (1.0.0)
public_suffix (6.0.1)
puma (6.4.3)
nio4r (~> 2.0)
Expand All @@ -55,6 +58,9 @@ GEM
rack (>= 3)
webrick (~> 1.8)
rainbow (3.1.1)
rbi (0.2.0)
prism (~> 1.0)
sorbet-runtime (>= 0.5.9204)
regexp_parser (2.9.2)
rubocop (1.66.1)
json (~> 2.3)
Expand All @@ -71,6 +77,8 @@ GEM
rubocop-performance (1.22.1)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-sorbet (0.8.5)
rubocop (>= 1)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
sawyer (0.9.2)
Expand All @@ -82,13 +90,44 @@ GEM
rack-protection (= 4.0.0)
rack-session (>= 2.0.0, < 3)
tilt (~> 2.0)
sorbet (0.5.11582)
sorbet-static (= 0.5.11582)
sorbet-runtime (0.5.11582)
sorbet-static (0.5.11582-aarch64-linux)
sorbet-static (0.5.11582-universal-darwin)
sorbet-static (0.5.11582-x86_64-linux)
sorbet-static-and-runtime (0.5.11582)
sorbet (= 0.5.11582)
sorbet-runtime (= 0.5.11582)
spoom (1.4.2)
erubi (>= 1.10.0)
prism (>= 0.28.0)
sorbet-static-and-runtime (>= 0.5.10187)
thor (>= 0.19.2)
tapioca (0.16.2)
bundler (>= 2.2.25)
netrc (>= 0.11.0)
parallel (>= 1.21.0)
rbi (~> 0.2)
sorbet-static-and-runtime (>= 0.5.11087)
spoom (>= 1.2.0)
thor (>= 1.2.0)
yard-sorbet
thor (1.3.2)
tilt (2.4.0)
unicode-display_width (2.6.0)
uri (0.13.1)
webrick (1.8.2)
yard (0.9.37)
yard-sorbet (0.9.0)
sorbet-runtime
yard

PLATFORMS
ruby
aarch64-linux
arm64-darwin
x86_64-darwin
x86_64-linux

DEPENDENCIES
faraday-retry
Expand All @@ -99,7 +138,11 @@ DEPENDENCIES
rackup
rubocop
rubocop-performance
rubocop-sorbet
sinatra
sorbet-runtime
sorbet-static-and-runtime
tapioca

RUBY VERSION
ruby 3.3.4p94
Expand Down
3 changes: 3 additions & 0 deletions sorbet/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--dir=.
--allowed-extension=.rb,.rbi,.ru
--ignore=tmp/,vendor/
1 change: 1 addition & 0 deletions sorbet/rbi/annotations/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/*.rbi linguist-vendored=true
17 changes: 17 additions & 0 deletions sorbet/rbi/annotations/faraday.rbi

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

Loading

0 comments on commit 7ae2b5f

Please sign in to comment.