forked from voke/ruby-jq
-
Notifications
You must be signed in to change notification settings - Fork 2
Add precompiled binary gem support and modernize build system #2
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
wesleyjellis
wants to merge
6
commits into
master
Choose a base branch
from
claude/precompile-jq-gem-0g9x67
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
71a316f
Precompile native extension with cibuildgem
claude c26a27c
make compile on mac
wesleyjellis 994102d
Temporarily run CI on pushes to this branch for pre-merge testing
wesleyjellis eaf4063
Hide statically linked symbols on ELF platforms
wesleyjellis f05a8c8
follow mini_portile recommendations for enforcing at least mini_porti…
wesleyjellis 69ebc96
pin archives by sha256
wesleyjellis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| name: "Package and release gems with precompiled binaries" | ||
| on: | ||
| # TODO: remove this temporary trigger before merging; it exists only to | ||
| # test the workflow pre-merge (workflow_dispatch requires the file to be | ||
| # on the default branch). | ||
| push: | ||
| branches: | ||
| - claude/precompile-jq-gem-0g9x67 | ||
| workflow_dispatch: | ||
| inputs: | ||
| release: | ||
| description: "If the whole build passes on all platforms, release the gems on RubyGems.org" | ||
| required: false | ||
| type: boolean | ||
| default: false | ||
| env: | ||
| CIBUILDGEM: 1 | ||
| jobs: | ||
| compile: | ||
| timeout-minutes: 20 | ||
| name: "Cross compile the gem on different ruby versions" | ||
| strategy: | ||
| matrix: | ||
| os: ["macos-latest", "ubuntu-22.04"] | ||
| runs-on: "${{ matrix.os }}" | ||
| steps: | ||
| - name: "Checkout code" | ||
| uses: "actions/checkout@v5" | ||
| - name: "Install autotools" | ||
| if: "${{ runner.os == 'macOS' }}" | ||
| run: brew install autoconf automake libtool | ||
| - name: "Setup Ruby" | ||
| uses: "ruby/setup-ruby@v1" | ||
| with: | ||
| ruby-version: "3.3.9" | ||
| bundler-cache: true | ||
| - name: "Run cibuildgem" | ||
| uses: "shopify/cibuildgem/.github/actions/cibuildgem@main" | ||
| with: | ||
| step: "compile" | ||
| test: | ||
| timeout-minutes: 20 | ||
| name: "Run the test suite" | ||
| needs: compile | ||
| strategy: | ||
| matrix: | ||
| os: ["macos-latest", "ubuntu-22.04"] | ||
| rubies: ["4.0", "3.4", "3.3"] | ||
| type: ["cross", "native"] | ||
| runs-on: "${{ matrix.os }}" | ||
| steps: | ||
| - name: "Checkout code" | ||
| uses: "actions/checkout@v5" | ||
| - name: "Install autotools" | ||
| if: "${{ runner.os == 'macOS' && matrix.type == 'native' }}" | ||
| run: brew install autoconf automake libtool | ||
| - name: "Setup Ruby" | ||
| uses: "ruby/setup-ruby@v1" | ||
| with: | ||
| ruby-version: "${{ matrix.rubies }}" | ||
| bundler-cache: true | ||
| - name: "Run cibuildgem" | ||
| uses: "shopify/cibuildgem/.github/actions/cibuildgem@main" | ||
| with: | ||
| step: "test_${{ matrix.type }}" | ||
| install: | ||
| timeout-minutes: 15 | ||
| name: "Verify the gem can be installed" | ||
| needs: test | ||
| strategy: | ||
| matrix: | ||
| os: ["macos-latest", "ubuntu-22.04"] | ||
| runs-on: "${{ matrix.os }}" | ||
| steps: | ||
| - name: "Install autotools" | ||
| if: "${{ runner.os == 'macOS' }}" | ||
| run: brew install autoconf automake libtool | ||
| - name: "Setup Ruby" | ||
| uses: "ruby/setup-ruby@v1" | ||
| with: | ||
| ruby-version: "4.0.0" | ||
| - name: "Run cibuildgem" | ||
| uses: "shopify/cibuildgem/.github/actions/cibuildgem@main" | ||
| with: | ||
| step: "install" | ||
| release: | ||
| environment: release | ||
| permissions: | ||
| id-token: write | ||
| contents: read | ||
| timeout-minutes: 5 | ||
| if: ${{ inputs.release }} | ||
| name: "Release all gems with RubyGems" | ||
| needs: install | ||
| runs-on: "ubuntu-latest" | ||
| steps: | ||
| - name: "Setup Ruby" | ||
| uses: "ruby/setup-ruby@v1" | ||
| with: | ||
| ruby-version: "4.0.0" | ||
| - name: "Run cibuildgem" | ||
| uses: "shopify/cibuildgem/.github/actions/cibuildgem@main" | ||
| with: | ||
| step: "release" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,16 +7,40 @@ def using_system_libraries? | |
| end | ||
|
|
||
| unless using_system_libraries? | ||
| message "Buildling jq using packaged libraries.\n" | ||
| message "Building jq using packaged libraries.\n" | ||
|
|
||
| require 'rubygems' | ||
| gem 'mini_portile2', '~> 2.2' | ||
| require 'mini_portile2' | ||
|
|
||
| recipe = MiniPortile.new('jq', '1.6') | ||
| recipe.files = ['https://github.com/stedolan/jq/archive/jq-1.6.tar.gz'] | ||
| onigmo = MiniPortile.new('onigmo', '6.2.0') | ||
| onigmo.files = [{ | ||
| url: 'https://github.com/k-takata/Onigmo/releases/download/Onigmo-6.2.0/onigmo-6.2.0.tar.gz', | ||
| sha256: 'c648496b5339953b925ebf44b8de356feda8d3428fa07dc1db95bfe2570feb76' | ||
| }] | ||
| onigmo.configure_options = [ | ||
| '--disable-shared', | ||
| '--enable-static', | ||
| '--with-pic' | ||
| ] | ||
| onigmo.cook | ||
|
|
||
| # OpsLevel fork of jq: `env`/`$ENV` always return an empty object. | ||
| recipe = MiniPortile.new('jq', '1.6.opslevel') | ||
| recipe.files = [{ | ||
| url: 'https://github.com/OpsLevel/jq/archive/845f4206dd8a82355325bafffbb54a5155cf67ec.tar.gz', | ||
| sha256: '6e7683e74d7eef8ac0f81d5bafdccff0c38f5882923feebc0aa6d3b18abf8f9d' | ||
| }] | ||
| recipe.configure_options = [ | ||
| '--enable-shared', | ||
| '--disable-maintainer-mode' | ||
| '--disable-maintainer-mode', | ||
| '--disable-docs', | ||
| '--disable-shared', | ||
|
wesleyjellis marked this conversation as resolved.
|
||
| '--enable-static', | ||
| '--with-pic', | ||
| "--with-oniguruma=#{onigmo.path}", | ||
| # macOS declares lgamma_r only under _REENTRANT; jq's configure detects | ||
| # the symbol via a link check, so compilation fails without this. | ||
| 'CPPFLAGS=-D_REENTRANT' | ||
| ] | ||
| class << recipe | ||
| def configure | ||
|
|
@@ -26,10 +50,18 @@ def configure | |
| end | ||
| recipe.cook | ||
| recipe.activate | ||
| $LIBPATH = ["#{recipe.path}/lib"] | $LIBPATH # rubocop:disable Style/GlobalVars | ||
| $LIBPATH = ["#{recipe.path}/lib", "#{onigmo.path}/lib"] | $LIBPATH # rubocop:disable Style/GlobalVars | ||
| $CPPFLAGS << " -I#{recipe.path}/include" # rubocop:disable Style/GlobalVars | ||
|
|
||
| abort 'libonigmo not found' unless have_library('onigmo') | ||
| end | ||
|
|
||
| abort 'libjq not found' unless have_library('jq') | ||
|
|
||
| create_makefile('jq_core') | ||
| # On ELF platforms, keep the statically linked jq/Onigmo symbols out of the | ||
| # extension's dynamic symbol table: libruby exports its own onig_* functions, | ||
| # and the flat ELF namespace would let calls bind across copies. (Mach-O uses | ||
| # two-level namespaces, and its linker lacks this flag.) | ||
| $LDFLAGS << ' -Wl,--exclude-libs,ALL' unless RUBY_PLATFORM.include?('darwin') # rubocop:disable Style/GlobalVars | ||
|
Author
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. What does |
||
|
|
||
| create_makefile('jq/jq_core') | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module JQ | ||
| VERSION = '0.2.2' | ||
| VERSION = '0.3.0' | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| $LOAD_PATH << File.dirname(__FILE__) + '/../lib' | ||
| $LOAD_PATH << "#{File.dirname(__FILE__)}/../lib" | ||
| require 'tempfile' | ||
| require 'jq' | ||
| require 'jq/extend' |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.