Skip to content

Commit

Permalink
Add typecheck with Steep (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyCTHsu authored May 25, 2024
2 parents 2c7590d + 7eecd7c commit 1c90649
Show file tree
Hide file tree
Showing 16 changed files with 99 additions and 14 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ jobs:
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.2.4"
ruby-version: "3.3.1"
bundler-cache: true
- name: Lint with standardrb
run: bundle exec rake standard
- name: Typecheck with steep
run: bundle exec steep check
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ jobs:
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: '3.2.4'
ruby-version: '3.3.1'
- uses: rubygems/release-gem@v1
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.3.1
10 changes: 3 additions & 7 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# frozen_string_literal: true

require "bundler/gem_tasks"
require "rspec/core/rake_task"
# load rake tasks from tasks directory
Dir.glob(File.join(__dir__ || Dir.pwd, "tasks", "**", "*.rake")) { |f| import f }

RSpec::Core::RakeTask.new(:spec)

require "standard/rake"

task default: %i[standard spec]
task default: %i[spec]
27 changes: 27 additions & 0 deletions Steepfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
D = Steep::Diagnostic

target :lib do
signature "sig"

check "lib" # Directory name
# ignore "lib/templates/*.rb"

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

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

# target :test do
# signature "sig", "sig-private"
#
# check "test"
#
# # library "pathname" # Standard libraries
# end
1 change: 0 additions & 1 deletion gemfiles/ruby-2.7.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ source "https://rubygems.org"
gemspec path: ".."

gem "rake", "~> 13.0"
gem "standard", "~> 1.0", require: false

group :test do
gem "rspec", "~> 3.0", require: false
Expand Down
1 change: 0 additions & 1 deletion gemfiles/ruby-3.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ source "https://rubygems.org"
gemspec path: ".."

gem "rake", "~> 13.0"
gem "standard", "~> 1.0", require: false

group :test do
gem "rspec", "~> 3.0", require: false
Expand Down
1 change: 0 additions & 1 deletion gemfiles/ruby-3.1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ source "https://rubygems.org"
gemspec path: ".."

gem "rake", "~> 13.0"
gem "standard", "~> 1.0", require: false

group :test do
gem "rspec", "~> 3.0", require: false
Expand Down
1 change: 0 additions & 1 deletion gemfiles/ruby-3.2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ source "https://rubygems.org"
gemspec path: ".."

gem "rake", "~> 13.0"
gem "standard", "~> 1.0", require: false

group :test do
gem "rspec", "~> 3.0", require: false
Expand Down
6 changes: 5 additions & 1 deletion gemfiles/ruby-3.3.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ source "https://rubygems.org"
gemspec path: ".."

gem "rake", "~> 13.0"
gem "standard", "~> 1.0", require: false

group :test do
gem "rspec", "~> 3.0", require: false
gem "datadog-ci", "~> 1.0.0.beta5", require: false
end

group :check do
gem "standard", "~> 1.0", require: false
gem "steep", "~> 1.6", require: false
end
3 changes: 3 additions & 0 deletions sig/leash.rbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
module Leash
VERSION: String
# See the writing guide of rbs: https://github.com/ruby/rbs#guides

class Error < StandardError
end
end
25 changes: 25 additions & 0 deletions sig/leash/procedure.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module Leash
class Procedure
@title: String

@options: Hash[untyped, untyped]

@steps: Array[Step]

attr_reader title: String

attr_reader options: Hash[untyped, untyped]

attr_reader steps: Array[Step]

def initialize: (String title, ?Hash[untyped, untyped] options) ?{ (self)[self: self] -> void } -> void

def step: (String description, ?untyped? action) { () -> untyped } -> untyped

def run: () -> void

def render: () -> String

def length: () -> Integer
end
end
15 changes: 15 additions & 0 deletions sig/leash/step.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module Leash
class Step
@description: String

@action: untyped

attr_reader description: String

attr_reader action: untyped

def initialize: (description: String, action: untyped) -> void

def run: () -> void
end
end
3 changes: 3 additions & 0 deletions tasks/bundler.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# frozen_string_literal: true

require "bundler/gem_tasks"
5 changes: 5 additions & 0 deletions tasks/rspec.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

require "rspec/core/rake_task"

RSpec::Core::RakeTask.new(:spec)
8 changes: 8 additions & 0 deletions tasks/standard.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true

begin
require "standard/rake"
rescue LoadError
warn "'standard' gem not loaded: skipping tasks..."
return
end

0 comments on commit 1c90649

Please sign in to comment.