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
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
18 changes: 14 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,22 @@ on:

jobs:
build:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
name: Ruby ${{ matrix.ruby }}
strategy:
fail-fast: false
matrix:
ruby:
- '3.2.2'
include:
- ruby: '3.2.2'
os: ubuntu-latest
task: 'bundle exec rake'
- ruby: '2.6'
os: ubuntu-22.04
task: 'bundle exec rspec'
gemfile: 'gemfiles/ruby26.gemfile'

env:
BUNDLE_GEMFILE: ${{ github.workspace }}/${{ matrix.gemfile || 'Gemfile' }}

steps:
- uses: actions/checkout@v4
Expand All @@ -24,4 +34,4 @@ jobs:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Run the default task
run: bundle exec rake
run: ${{ matrix.task }}
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest

container:
image: ghcr.io/tamatebako/tebako-ubuntu-20.04:latest
image: ghcr.io/tamatebako/tebako-ubuntu-20.04:0.12.6

steps:
- name: Checkout
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@
.irbrc

rubyshell-*.gem

/.direnv/
/gemfiles/*.lock
61 changes: 61 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
description = "rubyshell development environment";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
ruby = pkgs.ruby_3_3;
in
{
devShells.default = pkgs.mkShell {
packages = [
ruby
pkgs.bundler
pkgs.libyaml
pkgs.gnumake
pkgs.gcc
];

shellHook = ''
export BUNDLE_PATH="$PWD/.bundle/vendor"
export BUNDLE_BIN="$PWD/.bundle/bin"
export GEM_HOME="$BUNDLE_PATH"
export PATH="$BUNDLE_BIN:$PWD/bin:$PATH"
'';
};
});
}
11 changes: 11 additions & 0 deletions gemfiles/ruby26.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

# Minimal dependency set for the Ruby 2.6 compatibility job.
# The main Gemfile pulls in debug (needs >= 2.7) and rubocop, which do not
# install on 2.6; this one only carries what the specs need.
source "https://rubygems.org"

gemspec path: ".."

gem "rake", "~> 13.0"
gem "rspec", "~> 3.0"
4 changes: 4 additions & 0 deletions lib/rubyshell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ def config(kwargs)
module Kernel
def sh(command = nil, *args, **kwargs, &block)
if command
# On Ruby 2.6 an empty **kwargs is still passed along as a positional
# empty hash, which breaks arity for methods like OverwritedCommands#cd.
return RubyShell::Executor.send(command, *args) if kwargs.empty?

RubyShell::Executor.send(command, *args, **kwargs)
elsif block.nil?
RubyShell::Executor
Expand Down
2 changes: 1 addition & 1 deletion lib/rubyshell/chainer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def shared_settings
end

def settings
@options.select { shared_settings.include?(_1.to_sym) }.transform_keys { :"_#{_1}" }
@options.select { |k, _v| shared_settings.include?(k.to_sym) }.transform_keys { |k| :"_#{k}" }
end

def method_missing(method_name, *args, &block)
Expand Down
2 changes: 1 addition & 1 deletion lib/rubyshell/parallel_executor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def shared_settings
end

def settings
@options.select { shared_settings.include?(_1.to_sym) }.transform_keys { :"_#{_1}" }
@options.select { |k, _v| shared_settings.include?(k.to_sym) }.transform_keys { |k| :"_#{k}" }
end

def _evaluate(&block)
Expand Down
4 changes: 3 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# frozen_string_literal: true

require "tmpdir"
require "debug"
# The debug gem requires Ruby >= 2.7. On 2.6 `require "debug"` would load the
# stdlib debugger (rdb) instead, which takes over the run on the first raise.
require "debug" if RUBY_VERSION >= "2.7"
require_relative "../lib/rubyshell"

RSpec.configure do |config|
Expand Down
Loading