Skip to content

Commit

Permalink
Drop old rubies (#19)
Browse files Browse the repository at this point in the history
- Drop support for Ruby prior to 3.1
- Bump version to 4.0.0
- Fix tests and Rubocop
  • Loading branch information
johnnyshields authored Dec 31, 2023
1 parent 9e8a1d7 commit 8489654
Show file tree
Hide file tree
Showing 34 changed files with 565 additions and 508 deletions.
164 changes: 81 additions & 83 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,97 +4,95 @@ on: [push, pull_request]

jobs:
lint:

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ruby
bundler-cache: true

- name: Lint
run: bundle exec rake rubocop
- name: Checkout
uses: actions/checkout@v3
- name: Setup ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ruby
bundler-cache: true
bundler: 2
- name: Lint
run: bundle exec rubocop

test:

runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
ruby-version: ['2.6', '2.7', '3.0', '3.1', '3.2', 'ruby', 'jruby']
os:
- macos-latest
- ubuntu-latest
- windows-latest
ruby:
- '3.1'
- '3.2'
- '3.3'
- ruby
- jruby
- truffleruby
gemfile:
- gemfiles/rails_6_1.gemfile
- gemfiles/rails_7_0.gemfile
- gemfiles/rails_7_1.gemfile
exclude:
- os: windows-latest
ruby-version: jruby

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true

- name: Test
run: bundle exec rake test

test-vendor:

runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
ruby-version: ['2.6', '2.7', '3.0', '3.1', '3.2', 'ruby', 'jruby']
submodule:
- vendor/github.com/sass/sassc-rails
- vendor/github.com/twbs/bootstrap
exclude:
ruby: jruby
- os: windows-latest
ruby-version: jruby

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true

- name: Test
run: bundle exec rake git:submodule:test[${{matrix.submodule}}]

release:

if: github.event.repository.fork == false && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)

needs: [lint, test, test-vendor]

runs-on: ubuntu-latest

ruby: truffleruby
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
ssh-key: ${{ secrets.DEPLOY_KEY }}

- name: Setup ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ruby

- name: Release
run: |
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
git config user.name github-actions[bot]
rake -f -r bundler/gem_tasks release gem_push=no
- name: Checkout
uses: actions/checkout@v3
env:
BUNDLE_GEMFILE: "${{matrix.gemfile}}"
- name: Setup ruby
uses: ruby/setup-ruby@v1
env:
BUNDLE_GEMFILE: "${{matrix.gemfile}}"
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
bundler: 2
- name: Test
run: bundle exec rake test
env:
BUNDLE_GEMFILE: "${{matrix.gemfile}}"

# test-vendor:
# runs-on: ${{ matrix.os }}
# strategy:
# fail-fast: false
# matrix:
# os:
# - macos-latest
# - ubuntu-latest
# - windows-latest
# ruby:
# - '3.3'
# - jruby
# gemfile:
# - Gemfile
# submodule:
# - vendor/github.com/twbs/bootstrap
# exclude:
# - os: windows-latest
# ruby: jruby
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# env:
# BUNDLE_GEMFILE: "${{matrix.gemfile}}"
# - name: Setup ruby
# uses: ruby/setup-ruby@v1
# env:
# BUNDLE_GEMFILE: "${{matrix.gemfile}}"
# with:
# ruby-version: ${{ matrix.ruby }}
# bundler-cache: true
# bundler: 2
# - name: Test
# run: bundle exec rake git:submodule:test[${{matrix.submodule}}]
# env:
# BUNDLE_GEMFILE: "${{matrix.gemfile}}"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/.bundle/
/.idea/
/.yardoc
/Gemfile.lock
/gemfiles/*.lock
Expand Down
27 changes: 27 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
inherit_from: .rubocop_todo.yml

AllCops:
NewCops: enable
SuggestExtensions: false
TargetRubyVersion: 3.1
Exclude:
- vendor/**/*

Layout/LineLength:
Max: 120
Exclude:
- test/**/*

Metrics:
Exclude:
- test/**/*

Naming/BlockForwarding:
Enabled: false

Naming/FileName:
Exclude:
- 'lib/dartsass-sprockets.rb'

Style/HashSyntax:
EnforcedShorthandSyntax: never
44 changes: 44 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2023-12-31 06:58:36 UTC using RuboCop version 1.59.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 3
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 33

# Offense count: 1
# Configuration parameters: AllowedMethods, AllowedPatterns.
Metrics/CyclomaticComplexity:
Max: 9

# Offense count: 3
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
Metrics/MethodLength:
Max: 29

# Offense count: 1
# Configuration parameters: AllowedMethods, AllowedPatterns.
Metrics/PerceivedComplexity:
Max: 9

# Offense count: 17
# Configuration parameters: AllowedConstants.
Style/Documentation:
Exclude:
- 'spec/**/*'
- 'test/**/*'
- 'lib/rails/generators/sass/assets/assets_generator.rb'
- 'lib/rails/generators/sass/scaffold/scaffold_generator.rb'
- 'lib/rails/generators/sass_scaffold.rb'
- 'lib/rails/generators/scss/assets/assets_generator.rb'
- 'lib/rails/generators/scss/scaffold/scaffold_generator.rb'
- 'lib/sassc/rails/compressor.rb'
- 'lib/sassc/rails/functions.rb'
- 'lib/sassc/rails/importer.rb'
- 'lib/sassc/rails/railtie.rb'
- 'lib/sassc/rails/template.rb'
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
- **3.1.0**
- Change dependency from dartsass-ruby to sassc-embedded.
- Drop support for Ruby prior to 3.1.
- Add Rubocop and fix all issues.

- **3.0.0**
- [Release as dartsass-sprockets gem](https://github.com/tablecheck/dartsass-sprockets/pull/1)

Expand Down
8 changes: 5 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# frozen_string_literal: true

source 'https://rubygems.org'

platforms :windows do
gem 'tzinfo-data'
end

# for working locally
# gem "sassc", :path => "../sassc"
gem 'mocha'
gem 'rake'
gem 'rubocop'

# Specify your gem's dependencies in sassc-rails.gemspec
gemspec
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Use [Dart Sass](https://sass-lang.com/dart-sass) with Sprockets and the Ruby on

This gem is a fork of [sass/sassc-rails](https://github.com/sass/sassc-rails)
which maintains API compatibility but delegates to the
[dartsass-ruby](https://github.com/tablecheck/dartsass-ruby) gem
[sass-embedded](https://github.com/sass-contrib/sass-embedded-host-ruby) gem
which uses Dart Sass instead of the libsass C implmentation.

For ease of upgrading, the root namespace `::SassC` is still used by this gem,
Expand All @@ -25,6 +25,14 @@ gem 'dartsass-sprockets'
This will automatically configure your default Rails
`config.assets.css_compressor` to use `:sass`.

### Version Support

The current version of `dartsass-sprockets` supports:
- Ruby 3.1+
- Rails 6.1+

For older versions of Ruby and Rails may be supported with earlier versions of this gem.

### Upgrading to Dart Sass

This gem is a drop-in replacement to [sass-rails](https://github.com/rails/sass-rails).
Expand Down Expand Up @@ -59,10 +67,11 @@ Note these source maps are *inline* and will be appended to the compiled
## Credits

* This gem is maintained and used in production by [TableCheck](https://www.tablecheck.com/en/join). (We'd be very glad if the Sass organization could take over maintainership in the future!)
* Thank you to [Natsuki](https://ntk.me) for the [sass-embedded](https://github.com/sass-contrib/sass-embedded-host-ruby) gem.
* Credit to [Ryan Boland](https://ryanboland.com) and the authors of the original
[sass/sassc-rails](https://github.com/sass/sassc-rails) and
[sass-rails](https://github.com/rails/sass-rails) gems.
* See our [awesome contributors](https://github.com/tablecheck/sassc-ruby/graphs/contributors).
* See our [awesome contributors](https://github.com/tablecheck/dartsass-sprockets/graphs/contributors).

### Contributing

Expand Down
19 changes: 7 additions & 12 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
require "bundler/gem_tasks"
# frozen_string_literal: true

require 'bundler/gem_tasks'

task :test do
$LOAD_PATH.unshift('lib', 'test')
Dir.glob('./test/**/*_test.rb') { |f| require f }
Dir.glob('./test/**/*_test.rb').each { |f| require f }
end
task :default => [:test]
task default: [:test]

namespace :tests do
gemfiles = %w[
sprockets-rails_3_0
sprockets-rails_2_3
sprockets_3_0
sprockets_4_0
rails_4_2
rails_5_2
]
gemfiles = Dir['gemfiles/*.gemfile'].map { |f| File.basename(f, '.gemfile') }.freeze

gemfiles.each do |gemfile|
desc "Run tests against #{gemfile}"
Expand All @@ -24,7 +19,7 @@ namespace :tests do
end
end

desc "Run tests against all common asset pipeline setups"
desc 'Run tests against all common asset pipeline setups'
task :all do
gemfiles.each do |gemfile|
Rake::Task["tests:#{gemfile}"].invoke
Expand Down
Loading

0 comments on commit 8489654

Please sign in to comment.