diff --git a/.github/workflows/eol.yml b/.github/workflows/eol.yml new file mode 100644 index 0000000..250163e --- /dev/null +++ b/.github/workflows/eol.yml @@ -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 diff --git a/.gitignore b/.gitignore index 5c249f1..48530c2 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ .rspec_status Gemfile.lock +/lib/.rbnext diff --git a/.rbnextrc b/.rbnextrc new file mode 100644 index 0000000..c73b7eb --- /dev/null +++ b/.rbnextrc @@ -0,0 +1,3 @@ +nextify: | + ./lib + --min-version=2.2 diff --git a/Gemfile b/Gemfile index 5bbd468..f76bec4 100644 --- a/Gemfile +++ b/Gemfile @@ -9,3 +9,4 @@ gem "rake", "~> 13.0" gem "rspec", "~> 3.0" gem "simplecov", require: false gem "standard" +gem "ruby-next" diff --git a/Rakefile b/Rakefile index b6ae734..b317945 100644 --- a/Rakefile +++ b/Rakefile @@ -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 diff --git a/gemfiles/eol.gemfile b/gemfiles/eol.gemfile new file mode 100644 index 0000000..bc71b33 --- /dev/null +++ b/gemfiles/eol.gemfile @@ -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: ".." diff --git a/lib/paco.rb b/lib/paco.rb index 35333ed..8171b4c 100644 --- a/lib/paco.rb +++ b/lib/paco.rb @@ -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" diff --git a/paco.gemspec b/paco.gemspec index bad222d..0117351 100644 --- a/paco.gemspec +++ b/paco.gemspec @@ -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", @@ -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 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index dc294bb..4715aaf 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -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"