Skip to content

Commit 68f2e36

Browse files
committed
build(ruby): Verify Ruby gem
Signed-off-by: Dmitry Dygalo <[email protected]>
1 parent 6a78db6 commit 68f2e36

File tree

9 files changed

+2210
-10
lines changed

9 files changed

+2210
-10
lines changed

.github/workflows/build.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,85 @@ jobs:
535535
- run: bundle exec rake test
536536
working-directory: ./bindings/ruby
537537

538+
test-ruby-gem-install:
539+
name: Ruby Gem Build & Install Test
540+
runs-on: ${{ matrix.os }}
541+
strategy:
542+
fail-fast: false
543+
matrix:
544+
os: [ubuntu-22.04, macos-13, windows-2022]
545+
ruby-version: ["3.2", "3.3", "3.4"]
546+
547+
steps:
548+
- uses: actions/checkout@v4
549+
550+
- name: Set up Ruby & Rust
551+
uses: oxidize-rb/actions/setup-ruby-and-rust@main
552+
with:
553+
ruby-version: ${{ matrix.ruby-version }}
554+
bundler-cache: false
555+
cargo-cache: true
556+
cache-version: v1
557+
working-directory: ./bindings/ruby
558+
559+
- name: Build gem
560+
run: |
561+
gem build css_inline.gemspec
562+
working-directory: ./bindings/ruby
563+
564+
- name: Install rb_sys
565+
run: gem install rb_sys -v '~> 0.9.116' --no-document
566+
working-directory: ./bindings/ruby
567+
568+
- name: Install gem from built file
569+
run: |
570+
GEM_FILE=$(ls css_inline-*.gem | head -1)
571+
echo "Installing gem: $GEM_FILE"
572+
gem install "./$GEM_FILE" --local --no-document
573+
working-directory: ./bindings/ruby
574+
shell: bash
575+
576+
- name: Test gem installation
577+
run: |
578+
ruby -e "
579+
require 'css_inline'
580+
581+
html = '<html><head><style>h1 { color: red; }</style></head><body><h1>Test</h1></body></html>'
582+
result = CSSInline.inline(html)
583+
"
584+
585+
- name: Test gem in clean environment
586+
run: |
587+
ruby -e "require 'css_inline'; puts 'SUCCESS: Gem accessible from clean environment'"
588+
env:
589+
BUNDLE_GEMFILE: ""
590+
591+
test-ruby-gem-install-musl:
592+
name: Ruby Gem Build & Install Test (Alpine/musl)
593+
runs-on: ubuntu-22.04
594+
595+
steps:
596+
- uses: actions/checkout@v4
597+
598+
- name: Test gem install on Alpine/musl
599+
run: |
600+
docker run --rm \
601+
-v ${{ github.workspace }}:/workspace \
602+
-w /workspace \
603+
public.ecr.aws/docker/library/ruby:3.3-alpine3.19 \
604+
sh -c '
605+
set -e
606+
apk add --no-cache alpine-sdk curl gcompat clang clang-dev llvm-dev
607+
curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain 1.82.0
608+
source ~/.cargo/env
609+
gem update --system
610+
cd bindings/ruby
611+
gem install rb_sys -v "~> 0.9" --no-document
612+
gem build css_inline.gemspec
613+
gem install css_inline-*.gem --local --no-document
614+
ruby -e "require \"css_inline\"; puts CSSInline.inline(\"<style>h1{color:red}</style><h1>test</h1>\")"
615+
'
616+
538617
test-wasm:
539618
name: WASM module tests
540619
runs-on: ubuntu-22.04

bindings/ruby/CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
## [Unreleased]
44

5+
### Changed
6+
7+
- Bump MSRV to `1.82`.
8+
9+
### Fixed
10+
11+
- Packaging issue.
12+
- Installation on Alpine. [#394](https://github.com/Stranger6667/css-inline/pull/394)
13+
514
## [0.15.1] - 2025-06-21
615

716
### Fixed

bindings/ruby/Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindings/ruby/Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ source "https://rubygems.org"
55
gemspec
66

77
gem 'rspec'
8+
gem 'rb_sys'

bindings/ruby/Gemfile.lock

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ PATH
22
remote: .
33
specs:
44
css_inline (0.15.1)
5+
rb_sys (~> 0.9.116)
56

67
GEM
78
remote: https://rubygems.org/
@@ -52,7 +53,7 @@ DEPENDENCIES
5253
nokogiri (~> 1.15)
5354
premailer (~> 1.21)
5455
rake-compiler (~> 1.3.0)
55-
rb_sys (~> 0.9.116)
56+
rb_sys
5657
rspec
5758

5859
BUNDLED WITH

bindings/ruby/css_inline.gemspec

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,17 @@ Gem::Specification.new do |spec|
88
`css_inline` inlines CSS into HTML documents, using components from Mozilla's Servo project.
99
This process is essential for sending HTML emails as you need to use "style" attributes instead of "style" tags.
1010
EOF
11-
spec.files = Dir["lib/**/*.rb"].concat(Dir["ext/css_inline/src/**/*.rs"]) << "ext/css_inline/Cargo.toml" << "Cargo.lock" << "README.md"
12-
spec.extensions = ["ext/css_inline/Cargo.toml"]
11+
spec.files = [
12+
*Dir["lib/**/*.rb"],
13+
*Dir["ext/css_inline/src/**/*.rs"],
14+
"ext/css_inline/Cargo.toml",
15+
"ext/css_inline/Cargo.lock",
16+
"ext/css_inline/extconf.rb",
17+
"README.md",
18+
"Cargo.toml",
19+
"Cargo.lock",
20+
].compact
21+
spec.extensions = ["ext/css_inline/extconf.rb"]
1322
spec.rdoc_options = ["--main", "README.rdoc", "--charset", "utf-8", "--exclude", "ext/"]
1423
spec.authors = ["Dmitry Dygalo"]
1524
spec.email = ["[email protected]"]
@@ -22,12 +31,13 @@ Gem::Specification.new do |spec|
2231
"funding_uri" => "https://github.com/sponsors/Stranger6667/",
2332
}
2433

25-
spec.requirements = ["Rust >= 1.71.1"]
34+
spec.requirements = ["Rust >= 1.82"]
2635
spec.required_ruby_version = ">= 3.2.0"
2736
spec.required_rubygems_version = ">= 3.3.26"
2837

38+
spec.add_dependency "rb_sys", "~> 0.9.116"
39+
2940
spec.add_development_dependency "rake-compiler", "~> 1.3.0"
30-
spec.add_development_dependency "rb_sys", "~> 0.9.116"
3141
spec.add_development_dependency "benchmark-ips", "~> 2.10"
3242
spec.add_development_dependency "premailer", "~> 1.21"
3343
spec.add_development_dependency "nokogiri", "~> 1.15"

0 commit comments

Comments
 (0)