Skip to content

Commit

Permalink
improve Rakefile (#34)
Browse files Browse the repository at this point in the history
* everything in rakefile

* ignore

* run other ruby files through syntax tree

* explicitly use ruby version from tool versions file

* export ruby version

* just rake

* rake
  • Loading branch information
waymondo authored Dec 24, 2023
1 parent ce3d250 commit 2b9d284
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 22 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ jobs:
- "3.0"
- "3.1"
- "3.2"
rails:
rails:
- "7.0"
- "7.1"

steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
env:
env:
RAILS_VERSION: ${{ matrix.rails }}
with:
ruby-version: ${{ matrix.ruby }}
Expand All @@ -52,5 +52,4 @@ jobs:
PGPASSWORD: password
POSTGRES_PASSWORD: password
run: |
bundle exec stree check --ignore-files="vendor/**/*.rb" "**/*.rb"
bundle exec rake
1 change: 0 additions & 1 deletion .streerc

This file was deleted.

2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ruby 3.2.2
postgres 14.4
postgres 16.1
14 changes: 7 additions & 7 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# frozen_string_literal: true

source 'https://rubygems.org'
source "https://rubygems.org"

gem 'debug'
if (rails_version = ENV['RAILS_VERSION'])
gem 'rails', "~> #{rails_version}.0"
gem "debug"
if (rails_version = ENV["RAILS_VERSION"])
gem "rails", "~> #{rails_version}.0"
else
gem 'rails'
gem "rails"
end
gem 'syntax_tree'
gem 'typeprof'
gem "syntax_tree"
gem "typeprof"

gemspec
31 changes: 23 additions & 8 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
# frozen_string_literal: true

require 'bundler/gem_tasks'
require 'rake/testtask'
require "bundler/gem_tasks"
require "rake/testtask"
require "syntax_tree/rake_tasks"

Rake::TestTask.new(:test) do |t|
t.libs << 'test'
t.libs << 'lib'
t.test_files = FileList['test/**/test_*.rb']
t.libs << "test"
t.libs << "lib"
t.test_files = FileList["test/**/test_*.rb"]
end

task :pre_commit do
`typeprof lib/hoardable.rb && stree write "**/*.rb"`
SOURCE_FILES = %w[**/*.rb Rakefile Gemfile bin/console]

SyntaxTree::Rake::CheckTask.new(:check) do |t|
t.source_files = SOURCE_FILES
t.print_width = 100
t.ignore_files = "vendor/**/*.rb"
end

SyntaxTree::Rake::WriteTask.new(:write) do |t|
t.source_files = SOURCE_FILES
t.print_width = 100
end

task :typeprof do
`typeprof lib/hoardable.rb`
end

task default: %i[test]
task default: %i[check test]
task pre_commit: %i[write typeprof]
4 changes: 2 additions & 2 deletions bin/console
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require 'irb'
require_relative '../test/helper'
require "irb"
require_relative "../test/helper"

IRB.start(__FILE__)

0 comments on commit 2b9d284

Please sign in to comment.