Skip to content

Commit 082a605

Browse files
Merge pull request #635 from ruby/fix-nightly-js-gem-checksum-20260402
packaging: allow local js gem installs in nightly npm builds
2 parents 4a11dba + adac5a5 commit 082a605

File tree

2 files changed

+33
-6
lines changed

2 files changed

+33
-6
lines changed

.github/workflows/build-gems.yml

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,33 @@ jobs:
4646
with:
4747
ruby-version: "3.4"
4848

49-
- uses: oxidize-rb/actions/cross-gem@v1
49+
- name: Detect rb-sys version from Cargo.lock
50+
id: rb-sys
51+
run: |
52+
version="$(awk '/name = "rb-sys"/{flag=1; next} flag && /version = / {gsub(/"/, "", $3); print $3; exit}' Cargo.lock)"
53+
if [ -z "$version" ]; then
54+
echo "Failed to detect rb-sys version from Cargo.lock" >&2
55+
exit 1
56+
fi
57+
echo "version=$version" >> "$GITHUB_OUTPUT"
58+
59+
- name: Build native gem with rb-sys-dock
5060
id: cross-gem
51-
with:
52-
platform: ${{ matrix.ruby-platform }}
53-
ruby-versions: ${{ join(fromJSON(needs.ci-data.outputs.result).stable-ruby-versions, ',') }}
61+
env:
62+
PLATFORM: ${{ matrix.ruby-platform }}
63+
RUBY_VERSIONS: ${{ join(fromJSON(needs.ci-data.outputs.result).stable-ruby-versions, ',') }}
64+
RB_SYS_VERSION: ${{ steps.rb-sys.outputs.version }}
65+
run: |
66+
gem install rb_sys -v "$RB_SYS_VERSION"
67+
rb-sys-dock --platform "$PLATFORM" --directory . --ruby-versions "$RUBY_VERSIONS" --tag "$RB_SYS_VERSION" --build
68+
69+
gem_path="$(find ./pkg -name "*-${PLATFORM}.gem" | head -n1)"
70+
if [ -z "$gem_path" ]; then
71+
echo "Failed to find built gem for ${PLATFORM}" >&2
72+
ls -la ./pkg || true
73+
exit 1
74+
fi
75+
echo "gem-path=$gem_path" >> "$GITHUB_OUTPUT"
5476
5577
- uses: actions/upload-artifact@v7
5678
with:

rakelib/packaging.rake

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ def build_ruby(pkg, base_dir, pkg_dir, binaryen, clean: false)
6262
# Share ./build and ./rubies in the same workspace
6363
"RUBY_WASM_ROOT" => base_dir
6464
}
65+
# We vendor a freshly built js gem in package workspaces. Bundler checksum
66+
# validation against rubygems.org can fail for the same version.
67+
env["BUNDLE_DISABLE_CHECKSUM_VALIDATION"] = "true" if pkg[:gemfile]
6568
cwd = base_dir
6669
if gemfile_path = pkg[:gemfile]
6770
cwd = File.dirname(gemfile_path)
@@ -94,8 +97,10 @@ def build_ruby(pkg, base_dir, pkg_dir, binaryen, clean: false)
9497
Dir.chdir(cwd) do
9598
# uninstall js gem to re-install just-built js gem
9699
sh "gem", "uninstall", "js", "-v", js_gem_version, "--force"
97-
# install gems including js gem
98-
sh "bundle", "install"
100+
# install gems including js gem. Bundler may compare checksums with
101+
# rubygems.org for the same version and reject our just-built local gem.
102+
# Disable checksum validation only for this install command.
103+
sh({ "BUNDLE_DISABLE_CHECKSUM_VALIDATION" => "true" }, "bundle", "install")
99104

100105
sh env,
101106
"bundle", "exec",

0 commit comments

Comments
 (0)