mumuki-r-runner 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/metadata_hook.rb +24 -0
- data/lib/query_hook.rb +48 -0
- data/lib/r_runner.rb +15 -0
- data/lib/test_hook.rb +48 -0
- data/lib/try_hook.rb +47 -0
- data/lib/version.rb +3 -0
- metadata +133 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 16dac79ec3a5bf8a0f39be4ea303b2a2ce76c6e880740ce6506b0f7d34900cd8
|
4
|
+
data.tar.gz: 61edafb16a21bbf9f4e8c205dd12aa563512c0a1d1006f710f6c19d50d1595ac
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b3994020d6d9e97170d7735d7d79c135f32527d2b77d10113a5026d531dd35f5087d7eff923717d85598a46d688e6c73a4468a957428954316f8beaa7730fda5
|
7
|
+
data.tar.gz: 6dddb828be0def8f2f9d65a3c152d4be2c6f8cc2e26526b894dbffd4eab117d216514e39b27a4e555b54eba4b67125f9b39d032423006f78ede02a611f2a5987
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class RMetadataHook < Mumukit::Hook
|
2
|
+
def metadata
|
3
|
+
{language: {
|
4
|
+
name: 'r',
|
5
|
+
icon: {type: 'devicon', name: 'r'},
|
6
|
+
version: '3.6.1',
|
7
|
+
extension: 'R',
|
8
|
+
ace_mode: 'R'
|
9
|
+
},
|
10
|
+
test_framework: {
|
11
|
+
name: 'testthat',
|
12
|
+
version: '2.3.1', # FIXME fix version using devtools
|
13
|
+
test_extension: '.R',
|
14
|
+
template: <<R
|
15
|
+
test_that("{{ test_template_sample_description }}", {
|
16
|
+
expect_true( TRUE )
|
17
|
+
})
|
18
|
+
R
|
19
|
+
}}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
|
data/lib/query_hook.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
class RQueryHook < Mumukit::Templates::FileHook
|
2
|
+
with_error_patterns
|
3
|
+
isolated true
|
4
|
+
|
5
|
+
def tempfile_extension
|
6
|
+
'.R'
|
7
|
+
end
|
8
|
+
|
9
|
+
def compile_file_content(r)
|
10
|
+
"#{compile_file_header(r)}\n#{compile_query(r.query)}"
|
11
|
+
end
|
12
|
+
|
13
|
+
def compile_file_header(r)
|
14
|
+
<<R
|
15
|
+
#{r.extra}
|
16
|
+
|
17
|
+
#{r.content}
|
18
|
+
|
19
|
+
#{compile_cookie(r.cookie)}
|
20
|
+
R
|
21
|
+
end
|
22
|
+
|
23
|
+
def compile_query(query)
|
24
|
+
query
|
25
|
+
end
|
26
|
+
|
27
|
+
def compile_cookie(cookie)
|
28
|
+
return if cookie.blank?
|
29
|
+
|
30
|
+
compile_statements(cookie).join "\n"
|
31
|
+
end
|
32
|
+
|
33
|
+
def command_line(filename)
|
34
|
+
"Rscript #{filename}"
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def compile_statements(cookie)
|
40
|
+
cookie.map { |query| "invisible(tryCatch({ #{query} }, error = function(e) {}))" }
|
41
|
+
end
|
42
|
+
|
43
|
+
def error_patterns
|
44
|
+
[
|
45
|
+
Mumukit::ErrorPattern::Errored.new(/(?=Execution halted\n$)/)
|
46
|
+
]
|
47
|
+
end
|
48
|
+
end
|
data/lib/r_runner.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'mumukit'
|
2
|
+
require 'nokogiri'
|
3
|
+
|
4
|
+
Mumukit.runner_name = 'r'
|
5
|
+
Mumukit.configure do |config|
|
6
|
+
config.docker_image = 'mumuki/mumuki-r-worker:0.1'
|
7
|
+
config.structured = true
|
8
|
+
config.stateful = true
|
9
|
+
end
|
10
|
+
|
11
|
+
require_relative './version'
|
12
|
+
require_relative './metadata_hook'
|
13
|
+
require_relative './test_hook'
|
14
|
+
require_relative './query_hook'
|
15
|
+
require_relative './try_hook'
|
data/lib/test_hook.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
class RTestHook < Mumukit::Templates::FileHook
|
2
|
+
isolated true
|
3
|
+
structured true
|
4
|
+
|
5
|
+
def compile_file_content(request)
|
6
|
+
<<R
|
7
|
+
#{request.extra}
|
8
|
+
#{request.content}
|
9
|
+
#{request.test}
|
10
|
+
R
|
11
|
+
end
|
12
|
+
|
13
|
+
def tempfile_extension
|
14
|
+
'.R'
|
15
|
+
end
|
16
|
+
|
17
|
+
def command_line(filename)
|
18
|
+
%Q{R -q -e testthat::test_file('#{filename}',reporter='junit')} #TODO use
|
19
|
+
end
|
20
|
+
|
21
|
+
def post_process_file(file, result, status)
|
22
|
+
if status.failed?
|
23
|
+
[result, :errored]
|
24
|
+
else
|
25
|
+
super
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def to_structured_result(result)
|
30
|
+
clean_xml = result.gsub(/^>.+$/, '')
|
31
|
+
transform(Nokogiri::XML(clean_xml).xpath('//testcase'))
|
32
|
+
end
|
33
|
+
|
34
|
+
def transform(examples)
|
35
|
+
examples.map do |it|
|
36
|
+
failure = it.at('failure', 'error')
|
37
|
+
if failure
|
38
|
+
[it['name'].gsub('_', ' '), :failed, failure.content]
|
39
|
+
else
|
40
|
+
[it['name'].gsub('_', ' '), :passed, '']
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def cleanup_raw_result(result)
|
46
|
+
super(result.gsub 'tmpmumuki', '/tmp/mumuki')
|
47
|
+
end
|
48
|
+
end
|
data/lib/try_hook.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
class RTryHook < Mumukit::Templates::TryHook
|
2
|
+
isolated true
|
3
|
+
attr_reader :query_hook
|
4
|
+
|
5
|
+
def initialize(config = nil)
|
6
|
+
super config
|
7
|
+
@query_hook = RQueryHook.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def compile_file_content(r)
|
11
|
+
<<R
|
12
|
+
#{@query_hook.compile_file_header(r)}
|
13
|
+
cat("#{query_separator}", fill = TRUE);
|
14
|
+
#{@query_hook.compile_query(r.query)}
|
15
|
+
cat("#{goal_separator}", fill = TRUE);
|
16
|
+
#{@query_hook.compile_query(r.goal.with_indifferent_access[:query] || 'NULL')}
|
17
|
+
R
|
18
|
+
end
|
19
|
+
|
20
|
+
delegate :tempfile_extension, to: :query_hook
|
21
|
+
delegate :command_line, to: :query_hook
|
22
|
+
|
23
|
+
def query_separator
|
24
|
+
'!!!MUMUKI-QUERY-START!!!'
|
25
|
+
end
|
26
|
+
|
27
|
+
def goal_separator
|
28
|
+
'!!!MUMUKI-GOAL-START!!!'
|
29
|
+
end
|
30
|
+
|
31
|
+
def to_structured_results(_file, result, status)
|
32
|
+
/#{query_separator}
|
33
|
+
?(.*)
|
34
|
+
#{goal_separator}
|
35
|
+
?(.*)
|
36
|
+
/m =~ result
|
37
|
+
{
|
38
|
+
query: to_query_result($1, status),
|
39
|
+
goal: $2,
|
40
|
+
status: status
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
def to_query_result(result, status)
|
45
|
+
{ result: result, status: status }
|
46
|
+
end
|
47
|
+
end
|
data/lib/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mumuki-r-runner
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Franco Leonardo Bulgarelli
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-02-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: mumukit
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.30'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.30'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.4'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.4'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: codeclimate-test-reporter
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: mumukit-bridge
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.5'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.5'
|
97
|
+
description:
|
98
|
+
email:
|
99
|
+
- franco@mumuki.org
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- lib/metadata_hook.rb
|
105
|
+
- lib/query_hook.rb
|
106
|
+
- lib/r_runner.rb
|
107
|
+
- lib/test_hook.rb
|
108
|
+
- lib/try_hook.rb
|
109
|
+
- lib/version.rb
|
110
|
+
homepage: http://github.com/mumuki/mumuki-r-runner
|
111
|
+
licenses:
|
112
|
+
- MIT
|
113
|
+
metadata: {}
|
114
|
+
post_install_message:
|
115
|
+
rdoc_options: []
|
116
|
+
require_paths:
|
117
|
+
- lib
|
118
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
requirements: []
|
129
|
+
rubygems_version: 3.0.3
|
130
|
+
signing_key:
|
131
|
+
specification_version: 4
|
132
|
+
summary: R Runner for Mumuki
|
133
|
+
test_files: []
|