Skip to content

Commit

Permalink
Add Ruby Next to support older versions (#1)
Browse files Browse the repository at this point in the history
That would make it possible to use Paco in Ruby Next
  • Loading branch information
palkan committed Apr 9, 2022
1 parent 65f7053 commit 1ce2454
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 6 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/eol.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Build EOL Rubies

on:
push:
branches:
- master
pull_request:

jobs:
transpile:
runs-on: ubuntu-latest
timeout-minutes: 5
env:
BUNDLE_JOBS: 4
BUNDLE_RETRY: 3
CI: true
steps:
- uses: actions/checkout@v2
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.0
bundler-cache: true
- name: Transpile Ruby Next
run: |
bundle exec rake nextify
- name: Store transpiled files
uses: actions/upload-artifact@v2
with:
name: ruby-next-transpiled
path: lib/.rbnext
if-no-files-found: ignore

build:
needs: transpile
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby: [2.2, 2.3, 2.4, 2.5]
env:
BUNDLE_JOBS: 4
BUNDLE_RETRY: 3
BUNDLE_GEMFILE: gemfiles/eol.gemfile
CI: true
EOL: true
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler: 1.17
bundler-cache: true
- name: Restore transpiled files
uses: actions/download-artifact@v2
with:
name: ruby-next-transpiled
path: lib/.rbnext
- name: Run RSpec
run: bundle exec rspec
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
.rspec_status

Gemfile.lock
/lib/.rbnext
3 changes: 3 additions & 0 deletions .rbnextrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
nextify: |
./lib
--min-version=2.2
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ gem "rake", "~> 13.0"
gem "rspec", "~> 3.0"
gem "simplecov", require: false
gem "standard"
gem "ruby-next"
5 changes: 5 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,9 @@ require "rspec/core/rake_task"

RSpec::Core::RakeTask.new(:spec)

desc "Run Ruby Next nextify"
task :nextify do
sh "bundle exec ruby-next nextify -V"
end

task default: :spec
12 changes: 12 additions & 0 deletions gemfiles/eol.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

source "https://rubygems.org"

gem "rake", "~> 13.0"
gem "rspec", "~> 3.0"
gem "simplecov", require: false

gem "backports"

# Specify your gem's dependencies in paco.gemspec
gemspec path: ".."
3 changes: 3 additions & 0 deletions lib/paco.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# frozen_string_literal: true

require "ruby-next/language/setup"
RubyNext::Language.setup_gem_load_path(transpile: true)

require "paco/version"
require "paco/parse_error"
require "paco/context"
Expand Down
6 changes: 4 additions & 2 deletions paco.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
spec.description = "Paco is a parser combinator library."
spec.homepage = "https://github.com/skryukov/paco"
spec.license = "MIT"
spec.required_ruby_version = ">= 2.6.0"
spec.required_ruby_version = ">= 2.2.0"

spec.metadata = {
"bug_tracker_uri" => "#{spec.homepage}/issues",
Expand All @@ -22,7 +22,9 @@ Gem::Specification.new do |spec|
"source_code_uri" => spec.homepage
}

spec.files = Dir.glob("lib/**/*") + %w[README.md LICENSE.txt CHANGELOG.md]
spec.files = Dir.glob("lib/**/*") + Dir.glob("lib/.rbnext/**/*") + %w[README.md LICENSE.txt CHANGELOG.md]

spec.require_paths = ["lib"]

spec.add_dependency "ruby-next-core", ">= 0.15.0"
end
12 changes: 8 additions & 4 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# frozen_string_literal: true

require "simplecov"
if ENV["EOL"] != "true"
require "simplecov"

SimpleCov.start do
add_filter "/spec/"
enable_coverage :branch
SimpleCov.start do
add_filter "/spec/"
enable_coverage :branch
end
end

require "backports/2.5" if ENV["EOL"] == "true"

require "paco"
require "paco/rspec"

Expand Down

0 comments on commit 1ce2454

Please sign in to comment.