Skip to content
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

Fix rustup automatic install #331

Merged
merged 8 commits into from
Feb 22, 2024
Merged
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
26 changes: 17 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
fail-fast: false
matrix:
# Test against all versions supported by rubygems
ruby_version: ["2.5", "2.6", "2.7", "3.0", "3.1", "3.2", "3.3", "head"]
ruby_version: ["2.5", "2.6", "2.7", "3.0", "3.1", "3.2", "3.3"]
sys:
- os: ubuntu-latest
rust_toolchain: ${{ needs.fetch_ci_data.outputs.minimum-supported-rust-version }}
Expand All @@ -45,19 +45,16 @@
- os: windows-2022
rust_toolchain: stable
include:
- ruby_version: mswin

Check warning on line 48 in .github/workflows/ci.yml

View workflow job for this annotation

GitHub Actions / 🧪 Test (mswin, windows-2022, stable-x86_64-pc-windows-msvc)

mswin builds use ruby-master, and which is unstable and may break your build at any time (see https://github.com/MSP-Greg/ruby-loco/issues/12)
sys:
os: windows-2022
rust_toolchain: stable-x86_64-pc-windows-msvc
exclude:
- ruby_version: 3.3 # remove this once Ruby 3.3 binaries are available for windows
sys:
os: windows-2022
rust_toolchain: stable
runs-on: ${{ matrix.sys.os }}
steps:
- uses: actions/checkout@v4

- uses: oxidize-rb/actions/upload-core-dumps@v1

- name: Setup debug info
shell: bash
run: script/ci/set-debug-env.sh
Expand Down Expand Up @@ -89,11 +86,16 @@
shell: bash
env:
RB_SYS_CARGO_PROFILE: "release"
run: script/ci/upload-on-failure.sh "bundle exec rake test:examples" "examples-test" "./examples"
run: |
ulimit -c unlimited
script/ci/upload-on-failure.sh "bundle exec rake test:examples" "examples-test" "./examples"

- name: 🧪 Cargo test
shell: bash
run: bundle exec rake test:cargo
if: matrix.ruby_version != 'mswin'

Check warning on line 95 in .github/workflows/ci.yml

View workflow job for this annotation

GitHub Actions / 🧪 Test (mswin, windows-2022, stable-x86_64-pc-windows-msvc)

mswin builds use ruby-master, and which is unstable and may break your build at any time (see https://github.com/MSP-Greg/ruby-loco/issues/12)
run: |
ulimit -c unlimited
bundle exec rake test:cargo

- name: 💎 Gem test
run: bundle exec rake test:gem
Expand All @@ -102,6 +104,7 @@
shell: bash
run: |
set -ex
ulimit -c unlimited
gem update --system 3.3.22 > /dev/null
export RUBYOPT="-I$PWD/gem/lib"
pushd examples/rust_reverse
Expand Down Expand Up @@ -149,6 +152,8 @@
steps:
- uses: actions/checkout@v4

- uses: oxidize-rb/actions/upload-core-dumps@v1

- uses: oxidize-rb/actions/setup-ruby-and-rust@v1
with:
ruby-version: none
Expand Down Expand Up @@ -185,4 +190,7 @@
run: bundle install -j3

- name: 🧪 Run tests
run: bundle exec rake test
shell: bash
run: |
ulimit -c unlimited
bundle exec rake test
41 changes: 40 additions & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
run: cargo test
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
rust: ["stable"]
ruby: ["2.7", "3.2", "3.3", "ruby-head"]
ruby: ["2.7", "3.2", "3.3"]
exclude:
- os: windows-latest
ruby: '3.3' # remove this once 3.3 binaries are available for windows
Expand Down Expand Up @@ -87,3 +87,42 @@ jobs:
run: |
cd ./repo
${{ matrix.repo.run }}
dockerfile:
name: Bundle install in Dockerfile
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
repository: ${{ matrix.repo.name }}
ref: ${{ matrix.repo.ref }}
path: repo

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Generate Dockerfile
run: |
echo 'FROM ruby:3.3' > Dockerfile.issue
echo 'FROM ruby:3.3' > Dockerfile.issue
echo 'WORKDIR /app' >> Dockerfile.issue
echo 'RUN apt-get update -qq && \' >> Dockerfile.issue
echo ' apt-get install -y libclang-dev' >> Dockerfile.issue
echo 'COPY Gemfile.issue /app/Gemfile' >> Dockerfile.issue
echo "ADD ./repo/ /rb_sys" >> Dockerfile.issue
echo 'ENV RUBYOPT=-I/rb_sys/gem/lib' >> Dockerfile.issue
echo 'RUN bundle install --verbose --retry=3' >> Dockerfile.issue
cat Dockerfile.issue

- name: Generate Gemfile
run: |
echo 'source "https://rubygems.org"' > Gemfile.issue
echo "gem('rb_sys', path: '/rb_sys/gem')" >> Gemfile.issue
echo "gem('oxi-test', git: 'https://github.com/oxidize-rb/oxi-test', branch: :main)" >> Gemfile.issue
cat Gemfile.issue

- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile.issue
push: false
14 changes: 7 additions & 7 deletions crates/rb-sys-tests/src/memory_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,26 @@ fn test_rb_gc_guarded_ptr_vec() {
let mut vec_of_values: Vec<VALUE> = Default::default();

let s1 = rb_str_new_cstr(format!("hello world{i}\0").as_ptr() as _);
let s1 = rb_gc_guard!(s1);
vec_of_values.push(s1);

let s2 = rb_str_new_cstr(format!("hello world{i}\0").as_ptr() as _);
let s2 = rb_gc_guard!(s2);
vec_of_values.push(s2);

let s3 = rb_str_new_cstr(format!("hello world{i}\0").as_ptr() as _);
let s3 = rb_gc_guard!(s3);
vec_of_values.push(s3);

let ptr = &vec_of_values.as_ptr();
let len = &vec_of_values.len();

let rarray = rb_sys::rb_ary_new_from_values(*len as _, *ptr);
let mut inspected = rb_sys::rb_inspect(rarray);
let result = rstring_to_string!(inspected);
let rarray = rb_gc_guard!(rarray);

let _ = rb_gc_guard!(s1);
let _ = rb_gc_guard!(s2);
let _ = rb_gc_guard!(s3);
let _ = rb_gc_guard!(rarray);
let _ = rb_gc_guard!(inspected);
let inspected = rb_sys::rb_inspect(rarray);
let mut inspected = rb_gc_guard!(inspected);
let result = rstring_to_string!(inspected);

assert_eq!(
result,
Expand Down
2 changes: 1 addition & 1 deletion gem/lib/rb_sys/cargo_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ def profile_target_directory
end

def rubygems_invoked?
ENV.key?("SOURCE_DATE_EPOCH") && !ENV["RB_SYS_TEST"] == "1"
ENV.key?("SOURCE_DATE_EPOCH") && ENV["RB_SYS_TEST"] != "1"
end

# Error raised when no cdylib artifact was created
Expand Down
2 changes: 1 addition & 1 deletion gem/lib/rb_sys/mkmf/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def respond_to_missing?(name, include_private = false)
# install, to remove bloat.
# @api private
def rubygems_invoked?
ENV.key?("SOURCE_DATE_EPOCH") && !ENV["RB_SYS_TEST"] == "1"
ENV.key?("SOURCE_DATE_EPOCH") && ENV["RB_SYS_TEST"] != "1"
end

def use_stable_api_compiled_fallback?
Expand Down
Loading