Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ jobs:
uses: ruby/setup-ruby@e34163cd15f4bb403dcd72d98e295997e6a55798 # v1.238.0
with:
ruby-version: ${{ matrix.ruby }}
- uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
bundler-cache: true
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line will do the following, so the lines below were removed

  1. Installs bundler
  2. Runs bundle install
  3. Caches the gems in vendor/bundle

- name: Cache RBS collection
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
path: .gem_rbs_collection
key: ${{ runner.os }}-rbs-${{ hashFiles('rbs_collection.lock.yaml') }}
restore-keys: |
${{ runner.os }}-gems-
- name: Install dependencies
run: |
gem install bundler
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
${{ runner.os }}-rbs-
- name: Run tests
run: |
bundle exec rake
bundle exec rake spec
- name: Run typecheck
run: |
bundle exec rake typecheck
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,6 @@ pkg

.rspec_status
.DS_Store

# RBS collection (installed via rbs collection install)
.gem_rbs_collection
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ gem "rubocop-shopify", ">=2.8.0", require: false
gem "rubocop-performance", require: false

gemspec

gem "steep", "~> 1.10"
40 changes: 40 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ GEM
concurrent-ruby (1.3.5)
connection_pool (2.5.0)
crass (1.0.6)
csv (3.3.5)
database_cleaner (2.0.2)
database_cleaner-active_record (>= 2, < 3)
database_cleaner-active_record (2.2.0)
Expand All @@ -99,6 +100,13 @@ GEM
docile (1.4.1)
drb (2.2.1)
erubi (1.13.1)
ffi (1.17.3-aarch64-linux-gnu)
ffi (1.17.3-arm-linux-gnu)
ffi (1.17.3-arm64-darwin)
ffi (1.17.3-x86-linux-gnu)
ffi (1.17.3-x86_64-darwin)
ffi (1.17.3-x86_64-linux-gnu)
fileutils (1.7.3)
globalid (1.2.1)
activesupport (>= 6.1)
i18n (1.14.7)
Expand All @@ -111,6 +119,9 @@ GEM
json (2.13.2)
language_server-protocol (3.17.0.5)
lint_roller (1.1.0)
listen (3.9.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
logger (1.7.0)
loofah (2.24.0)
crass (~> 1.0.2)
Expand All @@ -125,6 +136,7 @@ GEM
mini_mime (1.1.5)
mini_portile2 (2.8.8)
minitest (5.25.5)
mutex_m (0.3.0)
net-imap (0.5.7)
date
net-protocol
Expand Down Expand Up @@ -206,6 +218,11 @@ GEM
zeitwerk (~> 2.6)
rainbow (3.1.1)
rake (13.2.1)
rb-fsevent (0.11.2)
rb-inotify (0.11.1)
ffi (~> 1.0)
rbs (3.9.5)
logger
rdoc (6.13.1)
psych (>= 4.0.0)
regexp_parser (2.11.0)
Expand Down Expand Up @@ -258,14 +275,35 @@ GEM
sqlite3 (2.6.0-x86-linux-gnu)
sqlite3 (2.6.0-x86_64-darwin)
sqlite3 (2.6.0-x86_64-linux-gnu)
steep (1.10.0)
activesupport (>= 5.1)
concurrent-ruby (>= 1.1.10)
csv (>= 3.0.9)
fileutils (>= 1.1.0)
json (>= 2.1.0)
language_server-protocol (>= 3.17.0.4, < 4.0)
listen (~> 3.0)
logger (>= 1.3.0)
mutex_m (>= 0.3.0)
parser (>= 3.1)
rainbow (>= 2.2.2, < 4.0)
rbs (~> 3.9)
securerandom (>= 0.1)
strscan (>= 1.0.0)
terminal-table (>= 2, < 5)
uri (>= 0.12.0)
stringio (3.1.6)
strscan (3.1.5)
terminal-table (4.0.0)
unicode-display_width (>= 1.1.1, < 4)
thor (1.3.2)
timeout (0.4.3)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (3.1.4)
unicode-emoji (~> 4.0, >= 4.0.4)
unicode-emoji (4.0.4)
uri (1.0.4)
useragent (0.16.11)
websocket-driver (0.7.7)
base64
Expand All @@ -287,13 +325,15 @@ DEPENDENCIES
ostruct
pry-byebug
rails (~> 7.2)
rbs (~> 3.0)
rspec (~> 3.2)
rubocop
rubocop-performance
rubocop-shopify (>= 2.8.0)
shopify-money!
simplecov
sqlite3
steep (~> 1.10)

BUNDLED WITH
2.6.7
29 changes: 28 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,34 @@ RSpec::Core::RakeTask.new(:rcov) do |spec|
spec.rcov = true
end

task default: :spec
namespace :rbs do
desc "Install RBS collection"
task :install do
sh "rbs collection install > /dev/null"
end

desc "Validate RBS type signatures"
task validate: :install do
sh "rbs -I sig validate"
end

desc "List RBS files"
task :list do
sh "find sig -name '*.rbs'"
end
end

namespace :steep do
desc "Type check Ruby code against RBS signatures"
task check: "rbs:install" do
sh "steep check --jobs 2"
end
end

desc "Run all type checks (RBS validation + Steep type checking)"
task typecheck: ["rbs:validate", "steep:check"]

task default: [:spec, :typecheck]

require 'rake/task'
RDoc::Task.new do |rdoc|
Expand Down
20 changes: 20 additions & 0 deletions Steepfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

target :lib do
signature "sig"

check "lib"
ignore "lib/rubocop/**/*.rb" # RuboCop cops use metaprogramming DSL
ignore "lib/money/railtie.rb" # Rails types
ignore "lib/money/deprecations.rb" # Uses class_eval
ignore "lib/money/rails/**/*.rb" # Rails-specific code
ignore "lib/money_column/railtie.rb" # Rails types
ignore "lib/money_column/active_record_hooks.rb" # Heavy metaprogramming with define_method

library "bigdecimal"
library "json"
library "forwardable"
library "yaml"

configure_code_diagnostics(Steep::Diagnostic::Ruby.lenient)
end
2 changes: 1 addition & 1 deletion dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ up:
- ruby
- bundler
commands:
test: bundle exec rspec
test: bundle exec rake
2 changes: 1 addition & 1 deletion lib/money/currency/loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class Money
class Currency
module Loader
CURRENCY_DATA_PATH = File.expand_path("../../../config", __dir__)
CURRENCY_DATA_PATH = File.expand_path("../../../config", __dir__ || raise("__dir__ is nil"))

class << self
def load_currencies
Expand Down
2 changes: 2 additions & 0 deletions money.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ Gem::Specification.new do |s|
s.summary = "Shopify's money gem"

s.metadata['allowed_push_host'] = "https://rubygems.org"
s.metadata['rbs_types'] = "sig"

s.add_dependency("bigdecimal", ">= 3.0")

s.add_development_dependency("bundler")
s.add_development_dependency("database_cleaner", "~> 2.0")
s.add_development_dependency("ostruct")
s.add_development_dependency("rails", "~> 7.2")
s.add_development_dependency("rbs", "~> 3.0")
s.add_development_dependency("rspec", "~> 3.2")
s.add_development_dependency("simplecov", ">= 0")
s.add_development_dependency("sqlite3")
Expand Down
Loading