Skip to content

Commit 60ad260

Browse files
committed
build(ruby): fix windows builds
Signed-off-by: Dmitry Dygalo <[email protected]>
1 parent 2e78d79 commit 60ad260

File tree

4 files changed

+30
-18
lines changed

4 files changed

+30
-18
lines changed

.github/workflows/build.yml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -478,25 +478,37 @@ jobs:
478478
working-directory: ./bindings/python
479479

480480
test-ruby:
481+
name: Ruby ${{ matrix.ruby-version }} on ${{ matrix.os }}
482+
runs-on: ${{ matrix.os }}
481483
strategy:
482484
fail-fast: false
483485
matrix:
484486
os: [ubuntu-22.04, macos-13, windows-2022]
485487
ruby-version: ["3.2", "3.3"]
486488

487-
name: Ruby ${{ matrix.ruby-version }} on ${{ matrix.os }}
488-
runs-on: ${{ matrix.os }}
489489
steps:
490490
- uses: actions/checkout@v4
491-
- name: Set up Ruby & Rust
492-
uses: oxidize-rb/actions/setup-ruby-and-rust@main
491+
492+
- name: Install Ruby
493+
uses: ruby/setup-ruby@v1
493494
with:
494495
ruby-version: ${{ matrix.ruby-version }}
495496
bundler-cache: true
496-
cargo-cache: true
497-
cache-version: v1
498497
working-directory: ./bindings/ruby
499498

499+
- name: Install MSYS2 UCRT64 DevKit
500+
if: runner.os == 'Windows'
501+
shell: powershell
502+
run: ridk install 3
503+
504+
- uses: dtolnay/rust-toolchain@stable
505+
506+
- uses: Swatinem/rust-cache@v2
507+
with:
508+
cache-all-crates: "true"
509+
key: ${{ matrix.os }}
510+
workspaces: bindings/ruby
511+
500512
- uses: actions/setup-python@v5
501513
with:
502514
python-version: 3.11
@@ -506,11 +518,13 @@ jobs:
506518
- name: Start background server
507519
run: |
508520
python -m pip install -r ./css-inline/tests/requirements-test.txt
509-
# Starts the server in background
510521
python ./css-inline/tests/server.py &
511522
shell: bash
512523

513524
- run: bundle exec rake test
525+
env:
526+
BINDGEN_EXTRA_CLANG_ARGS_x64-mingw-ucrt: "-IC:/msys64/ucrt64/include"
527+
BINDGEN_EXTRA_CLANG_ARGS_x86_64-pc-windows-msvc: "-IC:/msys64/ucrt64/include"
514528
working-directory: ./bindings/ruby
515529

516530
test-wasm:

bindings/ruby/Gemfile.lock

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

67
GEM
78
remote: https://rubygems.org/
@@ -26,7 +27,9 @@ GEM
2627
rake (13.0.6)
2728
rake-compiler (1.2.3)
2829
rake
29-
rb_sys (0.9.79)
30+
rake-compiler-dock (1.9.1)
31+
rb_sys (0.9.115)
32+
rake-compiler-dock (= 1.9.1)
3033
rspec (3.12.0)
3134
rspec-core (~> 3.12.0)
3235
rspec-expectations (~> 3.12.0)
@@ -50,7 +53,6 @@ DEPENDENCIES
5053
nokogiri (~> 1.15)
5154
premailer (~> 1.21)
5255
rake-compiler (~> 1.2.0)
53-
rb_sys (~> 0.9)
5456
rspec
5557

5658
BUNDLED WITH

bindings/ruby/Rakefile

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
require "rake/extensiontask"
44
require 'rspec/core/rake_task'
5+
require "rb_sys"
6+
require "rb_sys/toolchain_info"
57

68
task default: :spec
79

@@ -15,14 +17,7 @@ spec.files -= Dir["ext/**/*"]
1517
Rake::ExtensionTask.new("css_inline", spec) do |c|
1618
c.lib_dir = "lib/css_inline"
1719
c.cross_compile = true
18-
c.cross_platform = [
19-
"aarch64-linux",
20-
"arm64-darwin",
21-
"x64-mingw-ucrt",
22-
"x64-mingw32",
23-
"x86_64-darwin",
24-
"x86_64-linux",
25-
"x86_64-linux-musl"]
20+
c.cross_platform = RbSys::ToolchainInfo.supported_ruby_platforms
2621
end
2722

2823
task :dev do

bindings/ruby/css_inline.gemspec

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ Gem::Specification.new do |spec|
2525
spec.required_ruby_version = ">= 3.2.0"
2626
spec.required_rubygems_version = ">= 3.3.26"
2727

28+
spec.add_dependency 'rb_sys', '~> 0.9.108'
29+
2830
spec.add_development_dependency "rake-compiler", "~> 1.2.0"
29-
spec.add_development_dependency "rb_sys", "~> 0.9"
3031
spec.add_development_dependency "benchmark-ips", "~> 2.10"
3132
spec.add_development_dependency "premailer", "~> 1.21"
3233
spec.add_development_dependency "nokogiri", "~> 1.15"

0 commit comments

Comments
 (0)