Skip to content

Commit

Permalink
Merge pull request #116 from lutaml/maxirmx-issue-74-3
Browse files Browse the repository at this point in the history
- finalized fixes for segfaults in C++ native extension ( using antlr4-native-rb 2.0.0.1 ) (Segfaults in C++ native extension #74)
- added native extension sanity checks to CI scripts (Code review  #113)
- added rubocop run to CI scripts, some of ruby files are fixed to meet desired rubocop criteria (Code review  #113)
- added verification of pakaged gems in CI scripts (this is critical since development and release procedures use different toolchains) (Code review  #113)
- cleaned obsolete files
- fixed build for x64-mingw-ucrt binary gem (Build x64-mingw-ucrt version to support Windows Ruby 3.1 #103)
  • Loading branch information
maxirmx authored May 12, 2022
2 parents 44d7cac + 89e9b9f commit f24c94a
Show file tree
Hide file tree
Showing 62 changed files with 999 additions and 212,142 deletions.
6 changes: 0 additions & 6 deletions .cross_rubies
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
3.1.0:i686-w64-mingw32
3.1.0:x86_64-w64-mingw32
3.1.0:i686-linux-gnu
3.1.0:x86_64-linux-gnu
3.1.0:aarch64-linux-gnu
3.1.0:x86_64-darwin
3.1.0:arm64-darwin
3.0.0:i686-w64-mingw32
3.0.0:x86_64-w64-mingw32
3.0.0:i686-linux-gnu
3.0.0:x86_64-linux-gnu
3.0.0:aarch64-linux-gnu
3.0.0:x86_64-darwin
3.0.0:arm64-darwin
2.7.0:i686-w64-mingw32
2.7.0:x86_64-w64-mingw32
2.7.0:i686-linux-gnu
2.7.0:x86_64-linux-gnu
2.7.0:aarch64-linux-gnu
2.7.0:x86_64-darwin
Expand Down
205 changes: 196 additions & 9 deletions .github/workflows/rake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,29 @@ on:
pull_request:

jobs:
rubocop:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.0
bundler-cache: true

- name: Bundle
run: bundle install --jobs 4 --retry 3

- name: Rubocop
run: bundle exec rake rubocop

rake:
name: test on ruby-${{ matrix.ruby }} ${{ matrix.os }}
runs-on: ${{ matrix.os }}
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
Expand All @@ -29,7 +49,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
submodules: recursive

Expand All @@ -55,18 +75,18 @@ jobs:
run: bundle exec rake compile

- name: Run tests
run: bundle exec rake
run: |
bundle exec rake
cat .rspec_status
# test release workflow
pack:
pack-ruby:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
host: [ linux, windows, darwin ]
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
submodules: recursive

Expand All @@ -81,16 +101,36 @@ jobs:
run: bundle install --jobs 4 --retry 3

- name: Build gem without native extension
if: matrix.host == 'linux'
run: gem build expressir.gemspec

- name: Package gem without native extension
if: matrix.host == 'linux'
uses: actions/upload-artifact@v2
with:
name: pkg-ruby
path: expressir-*.gem

pack:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
host: [ linux, windows, darwin ]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0'
# bundler-cache: true important to not use cache because it leads to "cannot find -lrice"
# more info https://github.com/lutaml/expressir/runs/2097658383?check_suite_focus=true#step:7:2126

- name: Bundle
run: bundle install --jobs 4 --retry 3

- name: Enable swap
run: |
sudo fallocate -l 15g /compile.swap
Expand All @@ -107,3 +147,150 @@ jobs:
with:
name: pkg-${{ matrix.host }}
path: pkg/*.gem

verify-ruby:
name: verify ruby gem on ruby-${{ matrix.ruby }} ${{ matrix.os }}
needs: pack-ruby
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
ruby: [ '3.1', '3.0', '2.7' ]
os: [ ubuntu-latest, windows-latest, macos-latest ]
steps:
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true

- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: Bundle
run: bundle install --jobs 4 --retry 3

- name: Download packaged gem
uses: actions/download-artifact@v2
with:
name: pkg-ruby
path: pkg

- name: Install gem
run: gem install -l pkg/expressir-*.gem

- name: Verify
run: |
cd $(ruby -e "puts RbConfig::TOPDIR + '\/lib\/ruby\/gems\/' + RbConfig::CONFIG['ruby_version'] + '\/gems\/expressir*'")
ruby bin/rspec
verify-darwin:
name: verify MacOS binary gem on ruby-${{ matrix.ruby }}
needs: pack
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
ruby: [ '3.1', '3.0', '2.7' ]
steps:
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true

- name: Checkout
uses: actions/checkout@v3

- name: Bundle
run: bundle install --jobs 4 --retry 3

- name: Download packaged gem
uses: actions/download-artifact@v2
with:
name: pkg-darwin
path: pkg

- name: Install binary gem
run: gem install -l pkg/expressir-*-$(ruby -e "puts RUBY_PLATFORM.sub(/darwin\d{2}$/, 'darwin')").gem
# MacOS with have something like x86_64-darwin19, others just x86_64-linux

- name: Verify
run: |
cd $(ruby -e "puts RbConfig::TOPDIR + '\/lib\/ruby\/gems\/' + RbConfig::CONFIG['ruby_version'] + '\/gems\/expressir*'")
ruby bin/rspec
verify-linux:
name: verify Linux binary gem on ruby-${{ matrix.ruby }}
needs: pack
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby: [ '3.1', '3.0', '2.7' ]
steps:
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true

- name: Checkout
uses: actions/checkout@v3

- name: Bundle
run: bundle install --jobs 4 --retry 3

- name: Download packaged gem
uses: actions/download-artifact@v2
with:
name: pkg-linux
path: pkg

- name: Install binary gem
run: gem install -l pkg/expressir-*-$(ruby -e "puts RUBY_PLATFORM").gem

- name: Verify
run: |
cd $(ruby -e "puts RbConfig::TOPDIR + '\/lib\/ruby\/gems\/' + RbConfig::CONFIG['ruby_version'] + '\/gems\/expressir*'")
ruby bin/rspec
verify-windows:
name: verify Windows binary gem on ruby-${{ matrix.ruby }}
needs: pack
continue-on-error: true
runs-on: windows-latest
strategy:
fail-fast: false
# Ruby 3.1 fails
# https://github.com/lutaml/expressir/issues/103
matrix:
ruby: [ '3.1', '3.0', '2.7' ]
steps:
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true

- name: Checkout
uses: actions/checkout@v3

- name: Bundle
run: bundle install --jobs 4 --retry 3

- name: Download packaged gem
uses: actions/download-artifact@v2
with:
name: pkg-windows
path: pkg

- name: Install binary gem
run: gem install -l pkg/expressir-*-$(ruby -e "puts RUBY_PLATFORM").gem

- name: Verify
run: |
cd $(ruby -e "puts RbConfig::TOPDIR + '\/lib\/ruby\/gems\/' + RbConfig::CONFIG['ruby_version'] + '\/gems\/expressir*'")
ruby bin/rspec
9 changes: 7 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@
/tmp/
/Gemfile.lock
/.idea
/.vscode
/lib/expressir/express/express_parser.bundle
/lib/expressir/express/express_parser.so
/lib/expressir/express/*/express_parser.bundle
/lib/expressir/express/*/express_parser.so
/spec/syntax/*-pretty.exp
/ext/express-parser/rice-embed

# rspec failure tracking
.rspec_status

/ext/express-parser/rice-embed
/lib/expressir/express/express_parser.so
# rubocop guide
.rubocop-https---*
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "ext/express-parser/antlr4-upstream"]
path = ext/express-parser/antlr4-upstream
url = https://github.com/antlr/antlr4
[submodule "ext/express-grammar"]
path = ext/express-grammar
url = https://github.com/lutaml/express-grammar
17 changes: 13 additions & 4 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
inherit_from:
- https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml

# local repo-specific modifications
# ...

AllCops:
TargetRubyVersion: 2.4
TargetRubyVersion: 2.6
SuggestExtensions: false
Exclude:
- 'vendor/**/*'
- 'expressir.gemspec'
- 'tmp/**/*'
- 'pkg/**/*'
- 'exe/format-test'
- 'lib/expressir/express/**/*'
- 'lib/expressir/model/**/*'

Layout/LineLength:
Max: 160
5 changes: 4 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
require "bundler/gem_tasks"
require "rspec/core/rake_task"
require "rake/extensiontask"
require "rubocop/rake_task"
require "yard"

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

task :default => :spec
task default: :spec

GEMSPEC = Gem::Specification.load("expressir.gemspec")

RuboCop::RakeTask.new

Gem::PackageTask.new(GEMSPEC).define

YARD::Rake::YardocTask.new
1 change: 0 additions & 1 deletion bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ require "reeper"
# (If you use this, don't forget to add pry to your Gemfile!)
require "pry"
Pry.start

6 changes: 3 additions & 3 deletions bin/rspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@

require "pathname"
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
Pathname.new(__FILE__).realpath)

bundle_binstub = File.expand_path("../bundle", __FILE__)
bundle_binstub = File.expand_path("bundle", __dir__)

if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
if /This file was generated by Bundler/.match?(File.read(bundle_binstub, 300))
load(bundle_binstub)
else
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
Expand Down
18 changes: 0 additions & 18 deletions demo.rb

This file was deleted.

6 changes: 4 additions & 2 deletions exe/expressir
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ $:.unshift File.expand_path("../../lib", bin_file)
# Fixes https://github.com/rubygems/rubygems/issues/1420
require "rubygems/specification"

class Gem::Specification
def this; self; end
module Gem
class Specification
def this; self; end
end
end

# start up the CLI
Expand Down
Loading

0 comments on commit f24c94a

Please sign in to comment.