diff --git a/.github/workflows/easy-compile.yaml b/.github/workflows/easy-compile.yaml new file mode 100644 index 000000000..655424b0d --- /dev/null +++ b/.github/workflows/easy-compile.yaml @@ -0,0 +1,82 @@ +name: "Release gems with precompiled binaries" +on: + 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 +jobs: + compile: + timeout-minutes: 20 + name: "Cross compile the gem on different ruby versions" + strategy: + matrix: + os: ["macos-latest", "shopify-ubuntu-20.04"] + runs-on: "${{ matrix.os }}" + steps: + - name: "Checkout code" + uses: "actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd" + - name: "Setup Ruby" + uses: "ruby/setup-ruby@8aeb6ff8030dd539317f8e1769a044873b56ea71" + with: + ruby-version: "3.2.9" + bundler-cache: true + - name: "Run easy compile" + uses: "shopify-playground/edouard-playground/.github/actions/easy_compile@main" + with: + step: "compile" + test: + timeout-minutes: 20 + name: "Run the test suite" + needs: compile + strategy: + matrix: + os: ["macos-latest", "shopify-ubuntu-20.04"] + rubies: ["3.2", "3.3", "3.4"] + type: ["cross", "native"] + runs-on: "${{ matrix.os }}" + steps: + - name: "Checkout code" + uses: "actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd" + - name: "Setup Ruby" + uses: "ruby/setup-ruby@8aeb6ff8030dd539317f8e1769a044873b56ea71" + with: + ruby-version: "${{ matrix.rubies }}" + bundler-cache: true + - name: "Run easy compile" + uses: "shopify-playground/edouard-playground/.github/actions/easy_compile@main" + with: + step: "test_${{ matrix.type }}" + install: + timeout-minutes: 5 + name: "Verify the gem can be installed" + needs: test + strategy: + matrix: + os: ["macos-latest", "shopify-ubuntu-20.04"] + runs-on: "${{ matrix.os }}" + steps: + - name: "Setup Ruby" + uses: "ruby/setup-ruby@8aeb6ff8030dd539317f8e1769a044873b56ea71" + - name: "Run easy compile" + uses: "shopify-playground/edouard-playground/.github/actions/easy_compile@main" + with: + step: "install" + release: + permissions: + id-token: write + contents: read + timeout-minutes: 5 + if: ${{ inputs.release }} + name: "Release all gems with RubyGems" + needs: install + runs-on: "shopify-ubuntu-latest" + steps: + - name: "Setup Ruby" + uses: "ruby/setup-ruby@8aeb6ff8030dd539317f8e1769a044873b56ea71" + - name: "Run easy compile" + uses: "shopify-playground/edouard-playground/.github/actions/easy_compile@main" + with: + step: "release" diff --git a/lib/saturn.rb b/lib/saturn.rb index 65f5ca073..09db8d525 100644 --- a/lib/saturn.rb +++ b/lib/saturn.rb @@ -4,7 +4,15 @@ require "uri" require "saturn/version" -require "saturn/saturn" +begin + # Load the precompiled version of the library + ruby_version = /(\d+\.\d+)/.match(RUBY_VERSION) + require "saturn/#{ruby_version}/saturn" +rescue LoadError + # It's important to leave for users that can not or don't want to use the gem with precompiled binaries. + require "saturn/saturn" +end + require "saturn/location" require "saturn/comment" require "saturn/graph"