Skip to content

Commit

Permalink
Add steep infrastructure for testing type signatures
Browse files Browse the repository at this point in the history
- added steep and rbs to gemspec
- added type signature tests to github actions
- updated Steepfile
  • Loading branch information
rarruda committed Jan 8, 2023
1 parent 89bc0c3 commit 72cc9d2
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 20 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ jobs:
bundler-cache: true
- name: Run RuboCop
run: bundle exec rubocop
- name: Run Steep / RBS Type signature verification
run: |
steep check --steepfile=./Steepfile --severity-level=error | ruby -pe 'sub(/^(.+):(\d+):(\d+): (.+)$/, %q{::error file=\1,line=\2,col=\3::\4})'
shell: bash

test:
runs-on: ${{ matrix.os }}-latest
Expand Down
41 changes: 22 additions & 19 deletions Steepfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
# D = Steep::Diagnostic
#
D = Steep::Diagnostic

target :lib do
signature "sig"
signature "*.rbs"

check "lib/unleash/client.rb"
check "lib/unleash/context.rb"
check "lib/unleash/scheduled_executor.rb"

# check "lib/unleash/client.rbs" # Directory name
check "lib" # Directory name
# check "Gemfile" # File name
# check "app/models/**/*.rb" # Glob
# ignore "lib/templates/*.rb"
ignore "lib/unleash/bootstrap"
ignore "lib/unleash/strategy/*.rb"
ignore "lib/unleash/util"

ignore "lib/unleash/constraint.rb"
ignore "lib/unleash/feature_toggle.rb"
ignore "lib/unleash/metrics.rb"
ignore "lib/unleash/metrics_reporter.rb"
ignore "lib/unleash/toggle_fetcher.rb"
ignore "lib/unleash/variant_definition.rb"
ignore "lib/unleash/variant_override.rb"

# library "pathname", "set" # Standard libraries
# library "strong_json" # Gems

# configure_code_diagnostics(D::Ruby.strict) # `strict` diagnostics setting
# configure_code_diagnostics(D::Ruby.lenient) # `lenient` diagnostics setting
# configure_code_diagnostics do |hash| # You can setup everything yourself
# hash[D::Ruby::NoMethod] = :information
# end
configure_code_diagnostics do |hash| # You can setup everything yourself
hash[D::Ruby::NoMethod] = :information
hash[D::Ruby::UnsupportedSyntax] = :information
end
end

# target :test do
# # signature "sig", "sig-private"
# #
# check "spec"
# #
# # # library "pathname", "set" # Standard libraries
# end
2 changes: 1 addition & 1 deletion lib/unleash/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def register
end

def disabled_variant
@disabled_variant ||= Unleash::FeatureToggle.disabled_variant
Unleash::FeatureToggle.disabled_variant
end

def first_fetch_is_eager
Expand Down
3 changes: 3 additions & 0 deletions unleash-client.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "rubocop", "~> 1.28.2"
spec.add_development_dependency "simplecov", "~> 0.21.2"
spec.add_development_dependency "simplecov-lcov", "~> 0.8.0"

spec.add_development_dependency "rbs", "~> 2.7"
spec.add_development_dependency "steep", "~> 1.2"
end

0 comments on commit 72cc9d2

Please sign in to comment.