Skip to content
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
6 changes: 5 additions & 1 deletion .github/actions/easy_compile/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ inputs:
token:
description: "TODO this is needed to install the Easy Compile gem from the GitHub repo. Can be removed "
required: false
test-command:
description: "The command to run the test suite. By default Easy Compile will run either `bundle exec rake test` or `bundle exec rake spec` depending on the test framework used."
required: false
default: "easy_compile test"

runs:
using: "composite"
Expand Down Expand Up @@ -70,7 +74,7 @@ runs:
if: "${{ startsWith(inputs.step, 'test') }}"
working-directory: ${{ inputs.working-directory }}
shell: bash
run: easy_compile test # TODO This should be configurable
run: ${{ inputs.test-command }}
- name: "Download tarball for platform"
if: "${{ inputs.step == 'install' }}"
uses: actions/download-artifact@v5
Expand Down
1 change: 1 addition & 0 deletions lib/easy_compile/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def clobber
and determine what Ruby versions needs to be used for precompiling a "fat gem".
MSG
method_option "working-directory", type: "string", required: false, desc: "If your gem lives outside of the repository root, specify where."
method_option "test-command", type: "string", required: false, desc: "The test command to run. Defaults to running `bundle exec rake test` and `bundle exec rake spec`."
def ci_template
# os = ["macos-latest", "macos-15-intel", "ubuntu-latest", "windows-latest"]
os = ["macos-latest", "ubuntu-latest"] # Just this for now because the CI takes too long otherwise.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ jobs:
<%- if options['working-directory'] -%>
working-directory: "<%= options['working-directory'] %>"
<%- end -%>
<%- if options['test-command'] -%>
test-command: "<%= options['test-command'] %>"
<%- end -%>
install:
timeout-minutes: 5
name: "Verify the gem can be installed"
Expand Down
32 changes: 32 additions & 0 deletions test/cli_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,38 @@ def test_ci_template_when_passed_a_working_directory
FileUtils.rm_rf("test/fixtures/dummy_gem/.github")
end

def test_ci_template_when_passed_a_test_command
workflow_path = "test/fixtures/dummy_gem/.github/workflows/easy-compile.yaml"

expected_workflow = File.read("test/fixtures/expected_github_workflow_test_command.yml")
Dir.chdir("test/fixtures/dummy_gem") do
capture_subprocess_io do
CLI.start(["ci_template", "--test-command", "bundle exec something"])
end
end

assert(File.exist?(workflow_path))
assert_equal(expected_workflow, File.read(workflow_path))
ensure
FileUtils.rm_rf("test/fixtures/dummy_gem/.github")
end

def test_ci_template_when_passed_a_test_command_and_workdir
workflow_path = "test/fixtures/dummy_gem/.github/workflows/easy-compile.yaml"

expected_workflow = File.read("test/fixtures/expected_github_workflow_test_and_workdir.yml")
Dir.chdir("test/fixtures/dummy_gem") do
capture_subprocess_io do
CLI.start(["ci_template", "--test-command", "bundle exec something", "--working-directory", "foo/bar"])
end
end

assert(File.exist?(workflow_path))
assert_equal(expected_workflow, File.read(workflow_path))
ensure
FileUtils.rm_rf("test/fixtures/dummy_gem/.github")
end

def test_release
FileUtils.touch("tmp/foo.gem")
FileUtils.touch("tmp/bar.gem")
Expand Down
95 changes: 95 additions & 0 deletions test/fixtures/expected_github_workflow_test_and_workdir.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: "Package 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", "ubuntu-latest"]
runs-on: "${{ matrix.os }}"
steps:
- name: "Checkout code"
uses: "actions/checkout@v5"
- name: "Setup Ruby"
uses: "ruby/setup-ruby@v1"
with:
ruby-version: "3.1.7"
bundler-cache: true
working-directory: "foo/bar"
- name: "Run easy compile"
uses: "shopify-playground/edouard-playground/.github/actions/easy_compile@main"
with:
step: "compile"
token: ${{ secrets.EASY_COMPILE }} # TODO Remove this before publishing the gem
working-directory: "foo/bar"
test:
timeout-minutes: 20
name: "Run the test suite"
needs: compile
strategy:
matrix:
os: ["macos-latest", "ubuntu-latest"]
rubies: ["3.4.7", "3.3.9", "3.2.9", "3.1.7"]
type: ["cross", "native"]
runs-on: "${{ matrix.os }}"
steps:
- name: "Checkout code"
uses: "actions/checkout@v5"
- name: "Setup Ruby"
uses: "ruby/setup-ruby@v1"
with:
ruby-version: "${{ matrix.rubies }}"
bundler-cache: true
working-directory: "foo/bar"
- name: "Run easy compile"
uses: "shopify-playground/edouard-playground/.github/actions/easy_compile@main"
with:
step: "test_${{ matrix.type }}"
token: ${{ secrets.EASY_COMPILE }} # TODO Remove this before publishing the gem
working-directory: "foo/bar"
test-command: "bundle exec something"
install:
timeout-minutes: 5
name: "Verify the gem can be installed"
needs: test
strategy:
matrix:
os: ["macos-latest", "ubuntu-latest"]
runs-on: "${{ matrix.os }}"
steps:
- name: "Setup Ruby"
uses: "ruby/setup-ruby@v1"
with:
ruby-version: "3.4.7"
- name: "Run easy compile"
uses: "shopify-playground/edouard-playground/.github/actions/easy_compile@main"
with:
token: ${{ secrets.EASY_COMPILE }} # TODO Remove this before publishing the gem
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: "ubuntu-latest"
steps:
- name: "Setup Ruby"
uses: "ruby/setup-ruby@v1"
with:
ruby-version: "3.4.7"
- name: "Run easy compile"
uses: "shopify-playground/edouard-playground/.github/actions/easy_compile@main"
with:
step: "release"
token: ${{ secrets.GITHUB_TOKEN }}
91 changes: 91 additions & 0 deletions test/fixtures/expected_github_workflow_test_command.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: "Package 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", "ubuntu-latest"]
runs-on: "${{ matrix.os }}"
steps:
- name: "Checkout code"
uses: "actions/checkout@v5"
- name: "Setup Ruby"
uses: "ruby/setup-ruby@v1"
with:
ruby-version: "3.1.7"
bundler-cache: true
- name: "Run easy compile"
uses: "shopify-playground/edouard-playground/.github/actions/easy_compile@main"
with:
step: "compile"
token: ${{ secrets.EASY_COMPILE }} # TODO Remove this before publishing the gem
test:
timeout-minutes: 20
name: "Run the test suite"
needs: compile
strategy:
matrix:
os: ["macos-latest", "ubuntu-latest"]
rubies: ["3.4.7", "3.3.9", "3.2.9", "3.1.7"]
type: ["cross", "native"]
runs-on: "${{ matrix.os }}"
steps:
- name: "Checkout code"
uses: "actions/checkout@v5"
- name: "Setup Ruby"
uses: "ruby/setup-ruby@v1"
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 }}"
token: ${{ secrets.EASY_COMPILE }} # TODO Remove this before publishing the gem
test-command: "bundle exec something"
install:
timeout-minutes: 5
name: "Verify the gem can be installed"
needs: test
strategy:
matrix:
os: ["macos-latest", "ubuntu-latest"]
runs-on: "${{ matrix.os }}"
steps:
- name: "Setup Ruby"
uses: "ruby/setup-ruby@v1"
with:
ruby-version: "3.4.7"
- name: "Run easy compile"
uses: "shopify-playground/edouard-playground/.github/actions/easy_compile@main"
with:
token: ${{ secrets.EASY_COMPILE }} # TODO Remove this before publishing the gem
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: "ubuntu-latest"
steps:
- name: "Setup Ruby"
uses: "ruby/setup-ruby@v1"
with:
ruby-version: "3.4.7"
- name: "Run easy compile"
uses: "shopify-playground/edouard-playground/.github/actions/easy_compile@main"
with:
step: "release"
token: ${{ secrets.GITHUB_TOKEN }}