Skip to content

Commit 1f2bc5a

Browse files
committed
jruby support
1 parent 175fef9 commit 1f2bc5a

File tree

8 files changed

+641
-28
lines changed

8 files changed

+641
-28
lines changed

.github/workflows/test.yml

Lines changed: 43 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,50 @@
1-
name: test
1+
name: CI
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
pull_request:
6+
schedule:
7+
- cron: '15 9 * * *'
48

59
jobs:
6-
build:
7-
name: build (${{ matrix.ruby }} / ${{ matrix.os }})
10+
host:
11+
name: ${{ matrix.os }} ${{ matrix.ruby }}
12+
if: ${{ github.repository == 'ruby/cgi' || github.event_name != 'schedule' }}
13+
runs-on: ${{ matrix.os }}
814
strategy:
15+
fail-fast: false
916
matrix:
10-
ruby: [ '3.0', 2.7, 2.6, 2.5, head ]
11-
os: [ ubuntu-latest, macos-latest, windows-latest ]
12-
exclude:
13-
- { os: windows-latest, ruby: head }
17+
os:
18+
- ubuntu-latest
19+
- macos-latest
20+
- windows-latest
21+
ruby:
22+
- '3.0'
23+
- 2.7
24+
- 2.6
25+
- 2.5
1426
include:
15-
- { os: windows-latest, ruby: mingw }
16-
- { os: windows-latest, ruby: mswin }
17-
runs-on: ${{ matrix.os }}
27+
- { os: ubuntu-latest, ruby: head, ignore-pkg-error: true }
28+
- { os: windows-latest, ruby: mingw, ignore-pkg-error: true }
29+
- { os: windows-latest, ruby: mswin, ignore-pkg-error: true }
30+
- { os: ubuntu-latest, ruby: jruby }
31+
- { os: ubuntu-latest, ruby: jruby-head, ignore-pkg-error: true }
32+
1833
steps:
19-
- uses: actions/checkout@v2
20-
- name: Set up Ruby
21-
uses: ruby/setup-ruby@v1
22-
with:
23-
ruby-version: ${{ matrix.ruby }}
24-
- name: Install dependencies
25-
run: bundle install
26-
- name: Run test
27-
run: rake test
34+
- uses: actions/checkout@v2
35+
36+
- name: Set up Ruby
37+
uses: ruby/setup-ruby@v1
38+
with:
39+
ruby-version: ${{ matrix.ruby }}
40+
bundler-cache: true # 'bundle install' and cache
41+
42+
- run: bundle exec rake compile
43+
44+
- run: bundle exec rake build
45+
46+
- run: bundle exec rake test
47+
48+
- name: Integration test
49+
run: bundle exec rake check
50+
continue-on-error: ${{ matrix.ignore-pkg-error }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
/tmp/
1010
/ChangeLog
1111
/Gemfile.lock
12+
*.jar
1213
*.bundle
1314
*.so
1415
*.dll

Rakefile

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,30 @@
11
require "bundler/gem_tasks"
22
require "rake/testtask"
33

4-
require 'rake/extensiontask'
5-
extask = Rake::ExtensionTask.new("cgi/escape") do |x|
6-
x.lib_dir << "/#{RUBY_VERSION}/#{x.platform}"
4+
require 'rake/javaextensiontask'
5+
Rake::JavaExtensionTask.new("escape") do |ext|
6+
ext.source_version = '1.8'
7+
ext.target_version = '1.8'
8+
ext.ext_dir = 'ext/java'
9+
ext.lib_dir = 'lib/cgi'
10+
11+
task :build => :compile
12+
end
13+
14+
unless RUBY_ENGINE == 'jruby'
15+
require 'rake/extensiontask'
16+
extask = Rake::ExtensionTask.new("cgi/escape") do |x|
17+
x.lib_dir << "/#{RUBY_VERSION}/#{x.platform}"
18+
end
719
end
820

921
Rake::TestTask.new(:test) do |t|
10-
t.libs << extask.lib_dir
1122
t.libs << "test/lib"
23+
if RUBY_ENGINE == 'jruby'
24+
t.libs << "ext/java/org/jruby/ext/cgi/escape/lib"
25+
else
26+
t.libs << extask.lib_dir
27+
end
1228
t.ruby_opts << "-rhelper"
1329
t.test_files = FileList['test/**/test_*.rb']
1430
end

cgi.gemspec

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,21 @@ Gem::Specification.new do |spec|
2222
spec.metadata["homepage_uri"] = spec.homepage
2323
spec.metadata["source_code_uri"] = spec.homepage
2424

25-
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
26-
`git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{\A(?:(?:test|spec|features)/|\.git)}) }
27-
end
28-
spec.extensions = ["ext/cgi/escape/extconf.rb"]
2925
spec.executables = []
26+
27+
spec.files = [
28+
"LICENSE.txt",
29+
"README.md",
30+
*Dir["lib{.rb,/**/*.rb}", "bin/*"] ]
31+
3032
spec.require_paths = ["lib"]
33+
34+
if Gem::Platform === spec.platform and spec.platform =~ 'java' or RUBY_ENGINE == 'jruby'
35+
spec.platform = 'java'
36+
spec.require_paths << "ext/java/org/jruby/ext/cgi/escape/lib"
37+
spec.files += Dir["ext/java/**/*.{rb}", "lib/cgi/escape.jar"]
38+
else
39+
spec.files += Dir["ext/cgi/**/*.{rb,c,h,sh}", "ext/cgi/escape/depend", "lib/cgi/escape.so"]
40+
spec.extensions = ["ext/cgi/escape/extconf.rb"]
41+
end
3142
end

0 commit comments

Comments
 (0)