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
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ inputs:
description: "The step to run"
required: true
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."
description: "The command to run the test suite. By default cibuildgem will run either `bundle exec rake test` or `bundle exec rake spec` depending on the test framework used."
required: false
default: "easy_compile test"
default: "cibuildgem test"

runs:
using: "composite"
steps:
- name: Install easy compile # TODO this can be removed once this tool is pusblished on RubyGems
- name: Install cibuildgem # TODO this can be removed once this tool is pusblished on RubyGems
shell: bash
run: "rake install"
working-directory: "${{ github.action_path }}"
Expand All @@ -33,7 +33,7 @@ runs:
if: "${{ inputs.step == 'compile' }}"
working-directory: ${{ inputs.working-directory }}
shell: bash
run: easy_compile package
run: cibuildgem package
- name: Upload artifacts
if: "${{ inputs.step == 'compile' }}"
uses: actions/upload-artifact@v4
Expand All @@ -55,12 +55,12 @@ runs:
if: "${{ inputs.step == 'test_cross' }}"
working-directory: ${{ inputs.working-directory }}
shell: bash
run: easy_compile copy_from_staging_to_lib
run: cibuildgem copy_from_staging_to_lib
- name: "Compile native"
if: "${{ inputs.step == 'test_native' }}"
working-directory: ${{ inputs.working-directory }}
shell: bash
run: easy_compile compile
run: cibuildgem compile
- name: "Execute the tests"
if: "${{ startsWith(inputs.step, 'test') }}"
working-directory: ${{ inputs.working-directory }}
Expand All @@ -86,7 +86,7 @@ runs:
- name: "Push the gems to RubyGems"
if: "${{ inputs.step == 'release' }}"
shell: bash
run: easy_compile release --glob "pkg/*"
run: cibuildgem release --glob "pkg/*"
- name: "Waiting for RubyGems to fully index the new gems"
if: "${{ inputs.step == 'release' }}"
shell: bash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28208,7 +28208,7 @@ const os = __nccwpck_require__(857);
const path = __nccwpck_require__(6928);

async function run(workingDirectory) {
let ccRubies = cp.execSync('easy_compile print_ruby_cc_version', { cwd: workingDirectory, encoding: 'utf-8' })
let ccRubies = cp.execSync('cibuildgem print_ruby_cc_version', { cwd: workingDirectory, encoding: 'utf-8' })

await downloadRubies(ccRubies.split(':'))
setupRakeCompilerConfig(workingDirectory)
Expand All @@ -28231,7 +28231,7 @@ function setupRakeCompilerConfig(workingDirectory) {
let rubiesRbConfig = fs.globSync(`${rubiesPath()}/*/*/lib/ruby/*/*/rbconfig.rb`)
let currentRubyVersion = cp.execSync('ruby -v', { encoding: 'utf-8' }).match(/^ruby (\d\.\d\.\d)/)[1]
let rbConfigPath = path.join(os.homedir(), ".rake-compiler", "config.yml")
let rubyPlatform = cp.execSync('easy_compile print_normalized_platform', { cwd: workingDirectory, encoding: 'utf-8' })
let rubyPlatform = cp.execSync('cibuildgem print_normalized_platform', { cwd: workingDirectory, encoding: 'utf-8' })

fs.mkdirSync(`${os.homedir()}/.rake-compiler`)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "easy_compile",
"name": "cibuildgem",
"version": "1.0.0",
"description": "A companion GitHub action for easy_compile.",
"description": "A companion GitHub action for the cibuildgem ruby tool.",
"main": "index.js",
"repository": "https://github.com/rails/cool-stuff-fun-time",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const os = require('os');
const path = require('path');

async function run(workingDirectory) {
let ccRubies = cp.execSync('easy_compile print_ruby_cc_version', { cwd: workingDirectory, encoding: 'utf-8' })
let ccRubies = cp.execSync('cibuildgem print_ruby_cc_version', { cwd: workingDirectory, encoding: 'utf-8' })

await downloadRubies(ccRubies.split(':'))
setupRakeCompilerConfig(workingDirectory)
Expand All @@ -30,7 +30,7 @@ function setupRakeCompilerConfig(workingDirectory) {
let rubiesRbConfig = fs.globSync(`${rubiesPath()}/*/*/lib/ruby/*/*/rbconfig.rb`)
let currentRubyVersion = cp.execSync('ruby -v', { encoding: 'utf-8' }).match(/^ruby (\d\.\d\.\d)/)[1]
let rbConfigPath = path.join(os.homedir(), ".rake-compiler", "config.yml")
let rubyPlatform = cp.execSync('easy_compile print_normalized_platform', { cwd: workingDirectory, encoding: 'utf-8' })
let rubyPlatform = cp.execSync('cibuildgem print_normalized_platform', { cwd: workingDirectory, encoding: 'utf-8' })

fs.mkdirSync(`${os.homedir()}/.rake-compiler`)

Expand Down
9 changes: 0 additions & 9 deletions .github/actions/easy_compile/__tests__/index.test.js

This file was deleted.

12 changes: 6 additions & 6 deletions .github/workflows/e2e-dummy-gem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ jobs:
ruby-version: "3.1.7"
bundler-cache: true
working-directory: "test/fixtures/dummy_gem"
- name: "Run easy compile"
uses: "./.github/actions/easy_compile"
- name: "Run cibuildgem"
uses: "./.github/actions/cibuildgem"
with:
step: "compile"
working-directory: "test/fixtures/dummy_gem"
Expand All @@ -41,8 +41,8 @@ jobs:
ruby-version: "${{ matrix.rubies }}"
bundler-cache: true
working-directory: "test/fixtures/dummy_gem"
- name: "Run easy compile"
uses: "./.github/actions/easy_compile"
- name: "Run cibuildgem"
uses: "./.github/actions/cibuildgem"
with:
step: "test_${{ matrix.type }}"
working-directory: "test/fixtures/dummy_gem"
Expand All @@ -61,7 +61,7 @@ jobs:
uses: "ruby/setup-ruby@v1"
with:
ruby-version: "3.4.7"
- name: "Run easy compile"
uses: "./.github/actions/easy_compile"
- name: "Run cibuildgem"
uses: "./.github/actions/cibuildgem"
with:
step: "install"
16 changes: 8 additions & 8 deletions .github/workflows/gem-compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ jobs:
ruby-version: "3.1.7"
bundler-cache: true
working-directory: "test/fixtures/date"
- name: "Run easy compile"
uses: "shopify-playground/edouard-playground/.github/actions/easy_compile@main"
- name: "Run cibuildgem"
uses: "shopify-playground/edouard-playground/.github/actions/cibuildgem@main"
with:
step: "compile"
token: ${{ secrets.GITHUB_TOKEN }} # TODO Remove this before publishing the gem
Expand All @@ -56,8 +56,8 @@ jobs:
ruby-version: "${{ matrix.rubies }}"
bundler-cache: true
working-directory: "test/fixtures/date"
- name: "Run easy compile"
uses: "shopify-playground/edouard-playground/.github/actions/easy_compile@main"
- name: "Run cibuildgem"
uses: "shopify-playground/edouard-playground/.github/actions/cibuildgem@main"
with:
step: "test_${{ matrix.type }}"
token: ${{ secrets.GITHUB_TOKEN }} # TODO Remove this before publishing the gem
Expand All @@ -75,8 +75,8 @@ jobs:
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"
- name: "Run cibuildgem"
uses: "shopify-playground/edouard-playground/.github/actions/cibuildgem@main"
with:
token: ${{ secrets.GITHUB_TOKEN }} # TODO Remove this before publishing the gem
step: "install"
Expand All @@ -94,8 +94,8 @@ jobs:
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"
- name: "Run cibuildgem"
uses: "shopify-playground/edouard-playground/.github/actions/cibuildgem@main"
with:
step: "release"
token: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ jobs:
run: "bundle install"
- name: "Compile when target has rake as dependency"
working-directory: "test/fixtures/dummy_gem"
run: "easy_compile compile"
run: "cibuildgem compile"
- name: "Bundle install on target gem"
working-directory: "test/fixtures/dummy_gem"
run: "bundle install"
env:
BUNDLE_GEMFILE: "Gemfile_no_rake"
- name: "Compile when target gem doesn't have rake as dependency"
working-directory: "test/fixtures/dummy_gem"
run: "easy_compile compile"
run: "cibuildgem compile"
env:
BUNDLE_GEMFILE: "Gemfile_no_rake"
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
/doc/
/pkg/
/spec/reports/
/.github/actions/easy_compile/node_modules
/.github/actions/cibuildgem/node_modules
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

source "https://rubygems.org"

# Specify your gem's dependencies in easy_compile.gemspec
# Specify your gem's dependencies in cibuildgem.gemspec
gemspec

gem "rake", "~> 13.0"
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
easy_compile (0.1.1)
cibuildgem (0.1.1)
prism
rake-compiler
thor
Expand All @@ -21,7 +21,7 @@ PLATFORMS
ruby

DEPENDENCIES
easy_compile!
cibuildgem!
minitest (~> 5.16)
rake (~> 13.0)

Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ It uses a cross compilation approach by periodically building docker images for

As noted by @flavorjoes, this toolchain works great but it's complex and brittle compared to the more simple process of compiling on the target platform.

## 💻 Easy Compile
## 💻 cibuildgem

> [!NOTE]
> Easy Compile is for now not able to compile projects that needs to link on external libraries. Unless the project vendors those libraries or uses [mini_portile](https://github.com/flavorjones/mini_portile).
> cibuildgem is for now not able to compile projects that needs to link on external libraries. Unless the project vendors those libraries or uses [mini_portile](https://github.com/flavorjones/mini_portile).

> [!IMPORTANT]
> Repositories hosted on GitHub organization that don't belong to Shopify can't be tested at the moment. This is a temporary limitation that will be lifted
Expand All @@ -34,10 +34,10 @@ As noted by @flavorjoes, this toolchain works great but it's complex and brittle

### How to use it

While Easy Compile is generally **not** meant to be used locally, it provides a command to generate the right GitHub workflow for your project:
While cibuildgem is generally **not** meant to be used locally, it provides a command to generate the right GitHub workflow for your project:

1. Install Easy Compile: `git clone https://github.com/shopify-playground/edouard-playground`, `cd edouard-playground && rake install`
2. Generate the workflow: `cd` in your gem's folder and run `easy_compile ci_template`
1. Install cibuildgem: `git clone https://github.com/shopify-playground/edouard-playground`, `cd edouard-playground && rake install`
2. Generate the workflow: `cd` in your gem's folder and run `cibuildgem ci_template`
3. Commit the `.github/gem-compile.yaml` file.

### Triggering the workflow
Expand All @@ -52,7 +52,7 @@ Once pushed in your repository **default** branch, the workflow that we just gen

### Changes to make in your gem to support precompiled binaries

Due to the RubyGems specification, we can't release a gem with precompiled binaries for a specific Ruby version. Because the Ruby ABI is incompatible between minor versions, Rake Compiler (the tool underneath Easy Compile), compiles the binary for every minor Ruby versions your gem supports. All those binaries will be packaged in the gem (called a fat gem) in different folder such as `3.0/date.so`, `3.1/date.so` etc...
Due to the RubyGems specification, we can't release a gem with precompiled binaries for a specific Ruby version. Because the Ruby ABI is incompatible between minor versions, Rake Compiler (the tool underneath cibuildgem), compiles the binary for every minor Ruby versions your gem supports. All those binaries will be packaged in the gem (called a fat gem) in different folder such as `3.0/date.so`, `3.1/date.so` etc...
At runtime, your gem need to require the right binary based on the running ruby version.

```ruby
Expand Down
2 changes: 1 addition & 1 deletion bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# frozen_string_literal: true

require "bundler/setup"
require "easy_compile"
require "cibuildgem"

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.
Expand Down
8 changes: 4 additions & 4 deletions easy_compile.gemspec → cibuildgem.gemspec
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# frozen_string_literal: true

require_relative "lib/easy_compile/version"
require_relative "lib/cibuildgem/version"

Gem::Specification.new do |spec|
spec.name = "easy_compile"
spec.version = EasyCompile::VERSION
spec.name = "cibuildgem"
spec.version = Cibuildgem::VERSION
spec.authors = ["Edouard CHIN"]
spec.email = ["[email protected]"]

Expand All @@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["source_code_uri"] = "https://github.com"

spec.files = Dir["{exe,lib,scripts}/**/*", "LICENSE.md", "README.md", "lib/easy_compile/templates/.github/**/*"]
spec.files = Dir["{exe,lib,scripts}/**/*", "LICENSE.md", "README.md", "lib/cibuildgem/templates/.github/**/*"]
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]
Expand Down
4 changes: 2 additions & 2 deletions exe/easy_compile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
# frozen_string_literal: true

$LOAD_PATH.unshift("#{__dir__}/../lib")
require "easy_compile"
require "cibuildgem"

EasyCompile::CLI.start(ARGV)
Cibuildgem::CLI.start(ARGV)
10 changes: 10 additions & 0 deletions lib/cibuildgem.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

require_relative "cibuildgem/version"
require_relative "cibuildgem/errors"

module Cibuildgem
autoload :CLI, "cibuildgem/cli"
autoload :CompilationTasks, "cibuildgem/compilation_tasks"
autoload :RubySeries, "cibuildgem/ruby_series"
end
16 changes: 8 additions & 8 deletions lib/easy_compile/cli.rb → lib/cibuildgem/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require "thor"
require "rake/extensiontask"

module EasyCompile
module Cibuildgem
class CLI < Thor
include Thor::Actions

Expand All @@ -25,12 +25,12 @@ def self.exit_on_failure?
to the compilation.
MSG
def compile
run_rake_tasks!("easy_compile:setup", :compile)
run_rake_tasks!("cibuildgem:setup", :compile)
end

desc "package", "Compile and package a 'fat gem'.", hide: true
long_desc <<~MSG
This command should normally run on CI, using the EasyCompile workflow. It will not work locally unless
This command should normally run on CI, using the cibuildgem workflow. It will not work locally unless
the environment is properly setup.

Based on a gem's gemspec, create a tailored-made Rake Compiler task to create two gems:
Expand All @@ -44,20 +44,20 @@ def compile
def package
ENV["RUBY_CC_VERSION"] ||= compilation_task.ruby_cc_version

run_rake_tasks!("easy_compile:setup", :cross, :native, :gem)
run_rake_tasks!("cibuildgem:setup", :cross, :native, :gem)
end

desc "test", "Run the test suites of the target gem"
long_desc <<~EOM
EasyCompile will run the test suite of the gem. It either expects a `spec` or `test` task defined.
cibuildgem will run the test suite of the gem. It either expects a `spec` or `test` task defined.
EOM
def test
run_rake_tasks!(:test)
end

desc "copy_from_staging_to_lib", "Copy the staging binary. For internal usage.", hide: true
def copy_from_staging_to_lib
run_rake_tasks!("easy_compile:setup", "copy:stage:lib")
run_rake_tasks!("cibuildgem:setup", "copy:stage:lib")
end

desc "clean", "Cleanup temporary compilation artifacts."
Expand All @@ -68,7 +68,7 @@ def copy_from_staging_to_lib
to cleanup by adding files to the vanilla CLEAN rake list.
MSG
def clean
run_rake_tasks!("easy_compile:setup", :clean)
run_rake_tasks!("cibuildgem:setup", :clean)
end

desc "clobber", "Remove compiled binaries."
Expand All @@ -79,7 +79,7 @@ def clean
to remove by adding files to the vanilla CLOBBER rake list.
MSG
def clobber
run_rake_tasks!("easy_compile:setup", :clobber)
run_rake_tasks!("cibuildgem:setup", :clobber)
end

desc "ci_template", "Generate CI template files."
Expand Down
Loading
Loading