Skip to content

Commit 2ec64bc

Browse files
committed
Introduce Sorbet
1 parent a7cb4fa commit 2ec64bc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+28842
-275
lines changed

Diff for: .dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
.gitignore
55
.rubocop.yml
66
deployment/
7+
sorbet/
78
state.json

Diff for: .github/scripts/tapioca-exclude-check.rb

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
require "bundler"
5+
require "psych"
6+
7+
RBI_ALLOWLIST = %w[
8+
addressable
9+
faraday
10+
jwt
11+
octokit
12+
rack-session
13+
rack
14+
sinatra
15+
].freeze
16+
17+
tapioca_config = Psych.safe_load_file("sorbet/tapioca/config.yml")
18+
tapioca_excludes = tapioca_config.dig("gem", "exclude")
19+
20+
gem_names = Bundler.locked_gems.specs.map(&:name).uniq
21+
gem_names.reject! { |name| name.match?(/\Asorbet(?:-(?:static(?:-.*)?|runtime))?\z/) } # Implicitly excluded
22+
23+
allowed_and_excluded = RBI_ALLOWLIST & tapioca_excludes
24+
unless allowed_and_excluded.empty?
25+
$stderr.puts "Tapioca excludes contains gems in the allowlist!"
26+
$stderr.puts "Gems affected: #{allowed_and_excluded.join(", ")}"
27+
exit(1)
28+
end
29+
30+
new_gems = gem_names - tapioca_excludes - RBI_ALLOWLIST
31+
unless new_gems.empty?
32+
$stderr.puts "New gems were added that may need to be added to the Tapioca exclude list."
33+
$stderr.puts "Gems affected: #{new_gems.join(", ")}"
34+
exit(1)
35+
end
36+
37+
extra_excludes = tapioca_excludes - gem_names
38+
unless new_gems.empty?
39+
$stderr.puts "Tapioca exclude list contains gems that are not in the Gemfile.lock"
40+
$stderr.puts "Gems affected: #{extra_excludes.join(", ")}"
41+
exit(1)
42+
end

Diff for: .github/workflows/main.yml

+9
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ jobs:
2626
with:
2727
bundler-cache: true
2828

29+
- name: Check Tapioca excludes
30+
run: bundle exec ./.github/scripts/tapioca-exclude-check.rb
31+
32+
- name: Check RBI shims
33+
run: bundle exec tapioca check-shims
34+
35+
- name: Run Sorbet typecheck
36+
run: bundle exec srb tc
37+
2938
- name: Run RuboCop
3039
run: bundle exec rubocop
3140

Diff for: .rubocop.yml

+24
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
require:
22
- rubocop-performance
3+
- rubocop-sorbet
34

45
AllCops:
56
TargetRubyVersion: 3.3
67
NewCops: enable
8+
inherit_mode:
9+
merge:
10+
- Include
11+
Include:
12+
- .*/*.rb
713

814
Layout/CaseIndentation:
915
EnforcedStyle: end
@@ -45,6 +51,24 @@ Metrics/MethodLength:
4551
Metrics/ParameterLists:
4652
CountKeywordArgs: false
4753

54+
# Incompatible with Sorbet
55+
Naming/BlockForwarding:
56+
Enabled: false
57+
58+
Sorbet/FalseSigil:
59+
Enabled: false
60+
Sorbet/StrictSigil:
61+
Enabled: true
62+
Include:
63+
- src/server.rb
64+
- src/github_client.rb
65+
Sorbet/StrongSigil:
66+
Enabled: true
67+
Exclude:
68+
- src/server.rb
69+
- src/github_client.rb
70+
- src/octokit/*.rb
71+
4872
Style/AndOr:
4973
EnforcedStyle: always
5074

Diff for: Gemfile

+4
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@ gem "orka_api_client", git: "https://github.com/Homebrew/orka_api_client"
1111
gem "puma"
1212
gem "rackup"
1313
gem "sinatra"
14+
gem "sorbet-runtime"
1415

1516
group :development, optional: true do
1617
gem "rubocop"
1718
gem "rubocop-performance"
19+
gem "rubocop-sorbet"
20+
gem "sorbet-static-and-runtime"
21+
gem "tapioca"
1822
end

Diff for: Gemfile.lock

+44-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ GEM
1313
public_suffix (>= 2.0.2, < 7.0)
1414
ast (2.4.2)
1515
base64 (0.2.0)
16+
erubi (1.13.0)
1617
faraday (2.12.0)
1718
faraday-net_http (>= 2.0, < 3.4)
1819
json
@@ -33,6 +34,7 @@ GEM
3334
ruby2_keywords (~> 0.0.1)
3435
net-http (0.4.1)
3536
uri
37+
netrc (0.11.0)
3638
nio4r (2.7.3)
3739
octokit (9.1.0)
3840
faraday (>= 1, < 3)
@@ -41,6 +43,7 @@ GEM
4143
parser (3.3.5.0)
4244
ast (~> 2.4.1)
4345
racc
46+
prism (1.0.0)
4447
public_suffix (6.0.1)
4548
puma (6.4.3)
4649
nio4r (~> 2.0)
@@ -55,6 +58,9 @@ GEM
5558
rack (>= 3)
5659
webrick (~> 1.8)
5760
rainbow (3.1.1)
61+
rbi (0.2.0)
62+
prism (~> 1.0)
63+
sorbet-runtime (>= 0.5.9204)
5864
regexp_parser (2.9.2)
5965
rubocop (1.66.1)
6066
json (~> 2.3)
@@ -71,6 +77,8 @@ GEM
7177
rubocop-performance (1.22.1)
7278
rubocop (>= 1.48.1, < 2.0)
7379
rubocop-ast (>= 1.31.1, < 2.0)
80+
rubocop-sorbet (0.8.5)
81+
rubocop (>= 1)
7482
ruby-progressbar (1.13.0)
7583
ruby2_keywords (0.0.5)
7684
sawyer (0.9.2)
@@ -82,13 +90,44 @@ GEM
8290
rack-protection (= 4.0.0)
8391
rack-session (>= 2.0.0, < 3)
8492
tilt (~> 2.0)
93+
sorbet (0.5.11581)
94+
sorbet-static (= 0.5.11581)
95+
sorbet-runtime (0.5.11581)
96+
sorbet-static (0.5.11581-aarch64-linux)
97+
sorbet-static (0.5.11581-universal-darwin)
98+
sorbet-static (0.5.11581-x86_64-linux)
99+
sorbet-static-and-runtime (0.5.11581)
100+
sorbet (= 0.5.11581)
101+
sorbet-runtime (= 0.5.11581)
102+
spoom (1.4.2)
103+
erubi (>= 1.10.0)
104+
prism (>= 0.28.0)
105+
sorbet-static-and-runtime (>= 0.5.10187)
106+
thor (>= 0.19.2)
107+
tapioca (0.16.2)
108+
bundler (>= 2.2.25)
109+
netrc (>= 0.11.0)
110+
parallel (>= 1.21.0)
111+
rbi (~> 0.2)
112+
sorbet-static-and-runtime (>= 0.5.11087)
113+
spoom (>= 1.2.0)
114+
thor (>= 1.2.0)
115+
yard-sorbet
116+
thor (1.3.2)
85117
tilt (2.4.0)
86118
unicode-display_width (2.6.0)
87119
uri (0.13.1)
88120
webrick (1.8.2)
121+
yard (0.9.37)
122+
yard-sorbet (0.9.0)
123+
sorbet-runtime
124+
yard
89125

90126
PLATFORMS
91-
ruby
127+
aarch64-linux
128+
arm64-darwin
129+
x86_64-darwin
130+
x86_64-linux
92131

93132
DEPENDENCIES
94133
faraday-retry
@@ -99,7 +138,11 @@ DEPENDENCIES
99138
rackup
100139
rubocop
101140
rubocop-performance
141+
rubocop-sorbet
102142
sinatra
143+
sorbet-runtime
144+
sorbet-static-and-runtime
145+
tapioca
103146

104147
RUBY VERSION
105148
ruby 3.3.4p94

Diff for: sorbet/config

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
--dir=.
2+
--allowed-extension=.rb,.rbi,.ru
3+
--ignore=tmp/,vendor/

Diff for: sorbet/rbi/annotations/.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/*.rbi linguist-vendored=true

Diff for: sorbet/rbi/annotations/faraday.rbi

+17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)