Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CI #6

Merged
merged 1 commit into from
Dec 6, 2023
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
34 changes: 34 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: CI

on:
push:
pull_request:
types: [opened]

jobs:
sunstone:
name: Condenser/Rails Test
runs-on: ubuntu-22.04
strategy:
matrix:
rails-version:
- 6.1.7
- 7.0.8
- 7.1.2
ruby-version:
- 3.0
- 3.1
- 3.2

steps:
- uses: actions/checkout@v4

- run: |
echo 'gem "rails", "${{ matrix.rails-version }}"' >> Gemfile

- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically

- run: bundle exec rake test
2 changes: 1 addition & 1 deletion condenser-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Gem::Specification.new do |s|

s.required_ruby_version = '>= 2.5.0'

s.add_dependency "condenser", ">= 1.0.rc1"
s.add_dependency "condenser", ">= 1.3"
s.add_dependency "actionpack", ">= 6.0"
s.add_dependency "activesupport", ">= 6.0"
s.add_development_dependency "railties", ">= 6.0"
Expand Down
3 changes: 2 additions & 1 deletion lib/condenser/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def pipeline(&block)

config.assets = OrderedOptions.new
config.assets._blocks = []
config.assets._pipeline = nil
config.assets.path = []
config.assets.precompile = %w(application.css application.js **/*.jpg **/*.png **/*.gif)
config.assets.prefix = "/assets"
Expand Down Expand Up @@ -122,7 +123,7 @@ def build_environment(app, initialized = nil)
config = app.config

if config.assets._pipeline

config.assets._pipeline.call(env)
else
env.register_transformer 'text/scss', 'text/css', Condenser::ScssTransformer.new

Expand Down
43 changes: 43 additions & 0 deletions test/railtie_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,49 @@ def test_direct_build_environment_call
assert_includes env.path, @rails_root.join("stylesheets").to_s
end

def test_defining_an_empty_pipeline
FileUtils.mkdir_p(File.join(@rails_root, "javascripts"))
FileUtils.mkdir_p(File.join(@rails_root, "stylesheets"))

app.configure do
config.assets.pipeline do |condenser|
end
end
app.initialize!

assert env = app.assets
assert_equal env.templates, {"application/erb"=>Condenser::Erubi, "application/ejs"=>Condenser::EjsTemplate}
assert_equal env.preprocessors, {}
assert_equal env.transformers, {"text/scss"=>{"text/css"=>Condenser::ScssTransformer}, "application/jst"=>{"application/javascript"=>Condenser::JstTransformer}, "image/svg+xml"=>{"application/javascript"=>Condenser::SVGTransformer}}
assert_equal env.postprocessors, {}
assert_equal env.minifiers, {}
assert_equal env.exporters, {}
end

def test_defining_a_pipeline
FileUtils.mkdir_p(File.join(@rails_root, "javascripts"))
FileUtils.mkdir_p(File.join(@rails_root, "stylesheets"))

app.configure do
config.assets.pipeline do |condenser|
condenser.register_preprocessor('application/javascript', Condenser::JSAnalyzer)
condenser.register_postprocessor('text/css', ::Condenser::CSSMediaCombinerProcessor)
condenser.register_minifier('application/javascript', Condenser::TerserMinifier)
condenser.register_writer Condenser::ZlibWriter.new
end
end
app.initialize!

assert env = app.assets
assert_equal env.templates, {"application/erb"=>Condenser::Erubi, "application/ejs"=>Condenser::EjsTemplate}
assert_equal env.preprocessors, {"application/javascript"=>[Condenser::JSAnalyzer]}
assert_equal env.transformers, {"text/scss"=>{"text/css"=>Condenser::ScssTransformer}, "application/jst"=>{"application/javascript"=>Condenser::JstTransformer}, "image/svg+xml"=>{"application/javascript"=>Condenser::SVGTransformer}}
assert_equal env.postprocessors, {"text/css"=>[Condenser::CSSMediaCombinerProcessor]}
assert_equal env.minifiers, {"application/javascript"=>Condenser::TerserMinifier}
assert_equal env.exporters, {}
end


# def test_quiet_assets_defaults_to_off
# app.initialize!
# app.load_tasks
Expand Down