Skip to content

build(ruby): Verify Ruby gem #480

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

Merged
merged 1 commit into from
Jun 24, 2025
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
79 changes: 79 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,85 @@ jobs:
- run: bundle exec rake test
working-directory: ./bindings/ruby

test-ruby-gem-install:
name: Ruby Gem Build & Install Test
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, macos-13, windows-2022]
ruby-version: ["3.2", "3.3", "3.4"]

steps:
- uses: actions/checkout@v4

- name: Set up Ruby & Rust
uses: oxidize-rb/actions/setup-ruby-and-rust@main
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: false
cargo-cache: true
cache-version: v1
working-directory: ./bindings/ruby

- name: Build gem
run: |
gem build css_inline.gemspec
working-directory: ./bindings/ruby

- name: Install rb_sys
run: gem install rb_sys -v '~> 0.9.116' --no-document
working-directory: ./bindings/ruby

- name: Install gem from built file
run: |
GEM_FILE=$(ls css_inline-*.gem | head -1)
echo "Installing gem: $GEM_FILE"
gem install "./$GEM_FILE" --local --no-document
working-directory: ./bindings/ruby
shell: bash

- name: Test gem installation
run: |
ruby -e "
require 'css_inline'

html = '<html><head><style>h1 { color: red; }</style></head><body><h1>Test</h1></body></html>'
result = CSSInline.inline(html)
"

- name: Test gem in clean environment
run: |
ruby -e "require 'css_inline'; puts 'SUCCESS: Gem accessible from clean environment'"
env:
BUNDLE_GEMFILE: ""

test-ruby-gem-install-musl:
name: Ruby Gem Build & Install Test (Alpine/musl)
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4

- name: Test gem install on Alpine/musl
run: |
docker run --rm \
-v ${{ github.workspace }}:/workspace \
-w /workspace \
public.ecr.aws/docker/library/ruby:3.3-alpine3.19 \
sh -c '
set -e
apk add --no-cache alpine-sdk curl gcompat clang clang-dev llvm-dev
curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain 1.82.0
source ~/.cargo/env
gem update --system
cd bindings/ruby
gem install rb_sys -v "~> 0.9" --no-document
gem build css_inline.gemspec
gem install css_inline-*.gem --local --no-document
ruby -e "require \"css_inline\"; puts CSSInline.inline(\"<style>h1{color:red}</style><h1>test</h1>\")"
'

test-wasm:
name: WASM module tests
runs-on: ubuntu-22.04
Expand Down
9 changes: 9 additions & 0 deletions bindings/ruby/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

## [Unreleased]

### Changed

- Bump MSRV to `1.82`.

### Fixed

- Packaging issue.
- Installation on Alpine. [#394](https://github.com/Stranger6667/css-inline/pull/394)

## [0.15.1] - 2025-06-21

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions bindings/ruby/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions bindings/ruby/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ source "https://rubygems.org"
gemspec

gem 'rspec'
gem 'rb_sys'
3 changes: 2 additions & 1 deletion bindings/ruby/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ PATH
remote: .
specs:
css_inline (0.15.1)
rb_sys (~> 0.9.116)

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -52,7 +53,7 @@ DEPENDENCIES
nokogiri (~> 1.15)
premailer (~> 1.21)
rake-compiler (~> 1.3.0)
rb_sys (~> 0.9.116)
rb_sys
rspec

BUNDLED WITH
Expand Down
18 changes: 14 additions & 4 deletions bindings/ruby/css_inline.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,17 @@ Gem::Specification.new do |spec|
`css_inline` inlines CSS into HTML documents, using components from Mozilla's Servo project.
This process is essential for sending HTML emails as you need to use "style" attributes instead of "style" tags.
EOF
spec.files = Dir["lib/**/*.rb"].concat(Dir["ext/css_inline/src/**/*.rs"]) << "ext/css_inline/Cargo.toml" << "Cargo.lock" << "README.md"
spec.extensions = ["ext/css_inline/Cargo.toml"]
spec.files = [
*Dir["lib/**/*.rb"],
*Dir["ext/css_inline/src/**/*.rs"],
"ext/css_inline/Cargo.toml",
"ext/css_inline/Cargo.lock",
"ext/css_inline/extconf.rb",
"README.md",
"Cargo.toml",
"Cargo.lock",
].compact
spec.extensions = ["ext/css_inline/extconf.rb"]
spec.rdoc_options = ["--main", "README.rdoc", "--charset", "utf-8", "--exclude", "ext/"]
spec.authors = ["Dmitry Dygalo"]
spec.email = ["[email protected]"]
Expand All @@ -22,12 +31,13 @@ Gem::Specification.new do |spec|
"funding_uri" => "https://github.com/sponsors/Stranger6667/",
}

spec.requirements = ["Rust >= 1.71.1"]
spec.requirements = ["Rust >= 1.82"]
spec.required_ruby_version = ">= 3.2.0"
spec.required_rubygems_version = ">= 3.3.26"

spec.add_dependency "rb_sys", "~> 0.9.116"

spec.add_development_dependency "rake-compiler", "~> 1.3.0"
spec.add_development_dependency "rb_sys", "~> 0.9.116"
spec.add_development_dependency "benchmark-ips", "~> 2.10"
spec.add_development_dependency "premailer", "~> 1.21"
spec.add_development_dependency "nokogiri", "~> 1.15"
Expand Down
Loading
Loading