Skip to content

build(ruby): fix windows builds #445

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
28 changes: 21 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -478,25 +478,37 @@ jobs:
working-directory: ./bindings/python

test-ruby:
name: Ruby ${{ matrix.ruby-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, macos-13, windows-2022]
ruby-version: ["3.2", "3.3"]

name: Ruby ${{ matrix.ruby-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up Ruby & Rust
uses: oxidize-rb/actions/setup-ruby-and-rust@main

- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true
cargo-cache: true
cache-version: v1
working-directory: ./bindings/ruby

- name: Install MSYS2 UCRT64 DevKit
if: runner.os == 'Windows'
shell: powershell
run: ridk install 3

- uses: dtolnay/rust-toolchain@stable

- uses: Swatinem/rust-cache@v2
with:
cache-all-crates: "true"
key: ${{ matrix.os }}
workspaces: bindings/ruby

- uses: actions/setup-python@v5
with:
python-version: 3.11
Expand All @@ -506,11 +518,13 @@ jobs:
- name: Start background server
run: |
python -m pip install -r ./css-inline/tests/requirements-test.txt
# Starts the server in background
python ./css-inline/tests/server.py &
shell: bash

- run: bundle exec rake test
env:
BINDGEN_EXTRA_CLANG_ARGS_x64-mingw-ucrt: "-IC:/msys64/ucrt64/include"
BINDGEN_EXTRA_CLANG_ARGS_x86_64-pc-windows-msvc: "-IC:/msys64/ucrt64/include"
working-directory: ./bindings/ruby

test-wasm:
Expand Down
6 changes: 4 additions & 2 deletions 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.14.3)
rb_sys (~> 0.9.108)

GEM
remote: https://rubygems.org/
Expand All @@ -26,7 +27,9 @@ GEM
rake (13.0.6)
rake-compiler (1.2.3)
rake
rb_sys (0.9.79)
rake-compiler-dock (1.9.1)
rb_sys (0.9.115)
rake-compiler-dock (= 1.9.1)
rspec (3.12.0)
rspec-core (~> 3.12.0)
rspec-expectations (~> 3.12.0)
Expand All @@ -50,7 +53,6 @@ DEPENDENCIES
nokogiri (~> 1.15)
premailer (~> 1.21)
rake-compiler (~> 1.2.0)
rb_sys (~> 0.9)
rspec

BUNDLED WITH
Expand Down
11 changes: 3 additions & 8 deletions bindings/ruby/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

require "rake/extensiontask"
require 'rspec/core/rake_task'
require "rb_sys"
require "rb_sys/toolchain_info"

task default: :spec

Expand All @@ -15,14 +17,7 @@ spec.files -= Dir["ext/**/*"]
Rake::ExtensionTask.new("css_inline", spec) do |c|
c.lib_dir = "lib/css_inline"
c.cross_compile = true
c.cross_platform = [
"aarch64-linux",
"arm64-darwin",
"x64-mingw-ucrt",
"x64-mingw32",
"x86_64-darwin",
"x86_64-linux",
"x86_64-linux-musl"]
c.cross_platform = RbSys::ToolchainInfo.supported_ruby_platforms
end

task :dev do
Expand Down
3 changes: 2 additions & 1 deletion bindings/ruby/css_inline.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ Gem::Specification.new do |spec|
spec.required_ruby_version = ">= 3.2.0"
spec.required_rubygems_version = ">= 3.3.26"

spec.add_dependency 'rb_sys', '~> 0.9.108'

spec.add_development_dependency "rake-compiler", "~> 1.2.0"
spec.add_development_dependency "rb_sys", "~> 0.9"
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