Skip to content

Commit ea87e35

Browse files
Build fat gems for all supported Ruby versions and platforms on CI (#360)
* Build fat gems for all supported Ruby versions and platforms on CI * Specify gemspec to RbSys::ExtensionTask to define `native:*` tasks which are used by `rb-sys-dock` * Specify rb_sys dependency in gemspec * bundle exec to load gems specified in gemspec * Sync rb-sys version with the one in gemspec * Revert "Specify rb_sys dependency in gemspec" This reverts commit f7f8d24. * Pin rb_sys version exactly to use the same version with Cargo.toml * Don't need to setup rust in host machine * Exclude arm-linux from supported ruby platforms * Check gem build for all platforms * Don't install gems in host machine * Hardcode rb-sys version to remove the need of bundle install * Sync workflow with wasmtime-rb
1 parent d2d5f88 commit ea87e35

File tree

4 files changed

+59
-4
lines changed

4 files changed

+59
-4
lines changed

.github/workflows/build-gems.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Build gems
2+
on:
3+
push:
4+
branches: [main]
5+
tags: ["*"]
6+
paths-ignore:
7+
- "*.md"
8+
- "docs/**"
9+
pull_request:
10+
11+
jobs:
12+
ci-data:
13+
runs-on: ubuntu-latest
14+
outputs:
15+
result: ${{ steps.fetch.outputs.result }}
16+
steps:
17+
- uses: oxidize-rb/actions/fetch-ci-data@v1
18+
id: fetch
19+
with:
20+
supported-ruby-platforms: |
21+
exclude: [arm-linux]
22+
stable-ruby-versions: |
23+
exclude: [head]
24+
25+
cross-gem:
26+
name: Compile native gem for ${{ matrix.ruby-platform }}
27+
runs-on: ubuntu-latest
28+
needs: ci-data
29+
strategy:
30+
fail-fast: false
31+
matrix:
32+
ruby-platform: ${{ fromJSON(needs.ci-data.outputs.result).supported-ruby-platforms }}
33+
steps:
34+
- uses: actions/checkout@v4
35+
36+
- uses: oxidize-rb/actions/setup-ruby-and-rust@v1
37+
with:
38+
ruby-version: "3.2"
39+
bundler-cache: true
40+
cargo-cache: true
41+
cargo-vendor: true
42+
cache-version: v2-${{ matrix.ruby-platform }}
43+
44+
- name: Set vars
45+
id: vars
46+
run: |
47+
echo "rb-sys-version=$(bundle exec ruby -rrb_sys -e 'puts RbSys::VERSION')" >> $GITHUB_OUTPUT
48+
- uses: oxidize-rb/cross-gem-action@main
49+
with:
50+
version: ${{ steps.vars.outputs.rb-sys-version }}
51+
platform: ${{ matrix.ruby-platform }}
52+
ruby-versions: ${{ join(fromJSON(needs.ci-data.outputs.result).stable-ruby-versions, ', ') }}

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ jobs:
3434
ruby-version: "3.2"
3535
bundler-cache: true
3636
- run: ./bin/setup
37-
- run: rake check:type
37+
- run: bundle exec rake check:type
3838
- run: sudo apt-get install clang-format
3939
- run: ./tools/clang-format-diff.sh
40-
- run: rake check:bindgen
40+
- run: bundle exec rake check:bindgen
4141
- run: git diff --exit-code
4242

4343
build-builder-image:

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ gemspec
77
group :development do
88
gem "rake"
99
gem "rake-compiler"
10-
gem "rb_sys", "~> 0.9.63"
10+
gem "rb_sys", "0.9.85"
1111
end
1212

1313
group :check do

tasks/gem.rake

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ end
1010
begin
1111
require "rb_sys/extensiontask"
1212

13-
RbSys::ExtensionTask.new("ruby_wasm") { |ext| ext.lib_dir = "lib/ruby_wasm" }
13+
gemspec = Gem::Specification.load("ruby_wasm.gemspec")
14+
RbSys::ExtensionTask.new("ruby_wasm", gemspec) do |ext|
15+
ext.lib_dir = "lib/ruby_wasm"
16+
end
1417
rescue LoadError => e
1518
task :compile do
1619
$stderr.puts "Skipping compilation of ruby_wasm extension: #{e.message}"

0 commit comments

Comments
 (0)