-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[rust gem] Major improvements for gem scaffolding (rebased) #8455
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
base: master
Are you sure you want to change the base?
Changes from 11 commits
38be055
958f84d
54939ed
f2111de
d97b7a1
866a856
e777e1e
fe8d611
7ad416d
f87f370
e7d262f
637e6dc
a606c3c
d48434c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| pub fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
| let _ = rb_sys_env::activate()?; | ||
|
|
||
| Ok(()) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| --- | ||
| name: Build gems | ||
|
|
||
| on: | ||
| push: | ||
| tags: | ||
| - "v*" | ||
| - "cross-gem/*" | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| ci-data: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| result: ${{ steps.fetch.outputs.result }} | ||
| steps: | ||
| - uses: oxidize-rb/actions/fetch-ci-data@v1 | ||
| id: fetch | ||
| with: | ||
| supported-ruby-platforms: | | ||
| exclude: ["arm-linux", "x64-mingw32"] | ||
| stable-ruby-versions: | | ||
| exclude: ["2.5", "2.6", "2.7", "head"] | ||
gjtorikian marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| source-gem: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: ruby/setup-ruby@v1 | ||
| with: | ||
| bundler-cache: true | ||
|
|
||
| - name: Build gem | ||
| run: bundle exec rake build | ||
|
|
||
| - uses: actions/upload-artifact@v3 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| with: | ||
| name: source-gem | ||
| path: pkg/*.gem | ||
|
|
||
| cross-gem: | ||
| name: Compile native gem for ${{ matrix.platform }} | ||
| runs-on: ubuntu-latest | ||
| needs: ci-data | ||
| strategy: | ||
| matrix: | ||
| platform: ${{ fromJSON(needs.ci-data.outputs.result).supported-ruby-platforms }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: ruby/setup-ruby@v1 | ||
| with: | ||
| bundler-cache: true | ||
|
|
||
| - uses: oxidize-rb/actions/cross-gem@v1 | ||
| id: cross-gem | ||
| with: | ||
| platform: ${{ matrix.platform }} | ||
| ruby-versions: ${{ join(fromJSON(needs.ci-data.outputs.result).stable-ruby-versions, ',') }} | ||
|
|
||
| - uses: actions/upload-artifact@v3 | ||
| with: | ||
| name: cross-gem | ||
| path: ${{ steps.cross-gem.outputs.gem-path }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,10 +15,6 @@ Gem::Specification.new do |spec| | |
| spec.license = "MIT" | ||
| <%- end -%> | ||
| spec.required_ruby_version = ">= <%= config[:required_ruby_version] %>" | ||
| <%- if config[:ext] == 'rust' -%> | ||
| spec.required_rubygems_version = ">= <%= config[:rust_builder_required_rubygems_version] %>" | ||
| <%- end -%> | ||
|
|
||
| spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'" | ||
|
|
||
| spec.metadata["homepage_uri"] = spec.homepage | ||
|
|
@@ -41,12 +37,6 @@ Gem::Specification.new do |spec| | |
| spec.extensions = ["ext/<%= config[:underscored_name] %>/extconf.rb"] | ||
| <%- end -%> | ||
|
|
||
| # Uncomment to register a new dependency of your gem | ||
| # spec.add_dependency "example-gem", "~> 1.0" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please restore these lines. They are not related Rust gem. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can maybe move it to an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should be....but it's nice to do. :) I'll restore it. |
||
| <%- if config[:ext] == 'rust' -%> | ||
| spec.add_dependency "rb_sys", "~> 0.9.91" | ||
| <%- end -%> | ||
|
|
||
| # For more information and examples about making a new gem, check out our | ||
| # guide at: https://bundler.io/guides/creating_gem.html | ||
| end | ||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,7 +5,15 @@ RSpec.describe <%= config[:constant_name] %> do | |||||||||
| expect(<%= config[:constant_name] %>::VERSION).not_to be nil | ||||||||||
| end | ||||||||||
|
|
||||||||||
| <%- if config[:ext] == 'rust' -%> | ||||||||||
| it "can call into Rust" do | ||||||||||
| result = <%= config[:constant_name] %>.hello("world") | ||||||||||
|
|
||||||||||
| expect(result).to be("Hello earth, from Rust!") | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs Failure/Error: expect(result).to be("Hello earth, from Rust!")
expected #<String:1640> => "Hello earth, from Rust!"
got #<String:1648> => "Hello earth, from Rust!"
Compared using equal?, which compares object identity,
but expected and actual are not the same object. Use
`expect(actual).to eq(expected)` if you don't care about
object identity in this example.
Suggested change
Suggested change
|
||||||||||
| end | ||||||||||
| <%- else -%> | ||||||||||
| it "does something useful" do | ||||||||||
| expect(false).to eq(true) | ||||||||||
| end | ||||||||||
| <%- end -%> | ||||||||||
| end | ||||||||||
Uh oh!
There was an error while loading. Please reload this page.