singularity_dsl 1.4.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Gemfile.lock +18 -14
- data/README.md +45 -1
- data/lib/singularity_dsl/cli/cli.rb +16 -25
- data/lib/singularity_dsl/cli/utils.rb +54 -0
- data/lib/singularity_dsl/dsl/dsl.rb +11 -1
- data/lib/singularity_dsl/git_helper.rb +1 -1
- data/lib/singularity_dsl/tasks/rake.rb +1 -1
- data/lib/singularity_dsl/tasks/rubocop.rb +3 -5
- data/lib/singularity_dsl/version.rb +1 -1
- data/singularity_dsl.gemspec +2 -2
- data/spec/singularity_dsl/application_spec.rb +25 -21
- data/spec/singularity_dsl/cli/cli_spec.rb +2 -2
- data/spec/singularity_dsl/dsl/batch_spec.rb +1 -1
- data/spec/singularity_dsl/dsl/changeset_spec.rb +3 -3
- data/spec/singularity_dsl/dsl/dsl_spec.rb +28 -0
- data/spec/singularity_dsl/dsl/runner_spec.rb +3 -3
- data/spec/singularity_dsl/git_helper_spec.rb +26 -22
- data/spec/singularity_dsl/tasks/shell_task_spec.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NjMwNTkyMDAwNWM3ODg1ZjY2ZGMzY2ExYmQzNzFlMWMzMmQ5MjM3MQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MTE3Y2JkNDMwOWVjZjU3NmU2YTZmNTUzNzU1ZDllNGRiMGZhN2UxNw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZjUxMDFhYmRjMGEyMTU5MjFjYTc1YTAwZGUwMGJkMTM1ZjhjODQzZjdjYTg5
|
10
|
+
N2QwYzJkMmRlYTdiODA1Y2JhODE3NmNhZjI1MmRkOGZlZDUwMGU4M2I4MmQ0
|
11
|
+
Y2JjYjQxM2JiMmY4NzY5MTNhMzc0Mjg0Mzk0MTE2ZDM1MGE3Yjg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MDhiZDg3ZTgwYWM3NzQ1MWJiNDIzOGZmNGM0NjY4NDRjODMyMzE2M2EyYWI1
|
14
|
+
MTlkMDNmM2NiZmFkNzA0ZTg3MGFjNmU0NWNhYTU5OGQ5MzNlYWIwOTUzMGY2
|
15
|
+
ODhlNjg0YmYyNzMwNzVhOWFiOTRhMDgwYmU0ODQ3ZTkwODU4OGQ=
|
data/Gemfile.lock
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
singularity_dsl (1.
|
4
|
+
singularity_dsl (1.5.0)
|
5
5
|
mixlib-shellout (~> 1.4)
|
6
6
|
rainbow (~> 2.0.0)
|
7
7
|
rake (~> 10.3)
|
8
|
-
rspec (~>
|
9
|
-
rubocop (~> 0.
|
8
|
+
rspec (~> 3.0)
|
9
|
+
rubocop (~> 0.24)
|
10
10
|
terminal-table (~> 1.4)
|
11
11
|
thor (~> 0.19)
|
12
12
|
|
@@ -18,23 +18,27 @@ GEM
|
|
18
18
|
gem-release (0.7.3)
|
19
19
|
json (1.8.1)
|
20
20
|
mixlib-shellout (1.4.0)
|
21
|
-
parser (2.
|
21
|
+
parser (2.2.0.pre.4)
|
22
22
|
ast (>= 1.1, < 3.0)
|
23
23
|
slop (~> 3.4, >= 3.4.5)
|
24
24
|
powerpack (0.0.9)
|
25
25
|
rainbow (2.0.0)
|
26
26
|
rake (10.3.2)
|
27
|
-
rspec (
|
28
|
-
rspec-core (~>
|
29
|
-
rspec-expectations (~>
|
30
|
-
rspec-mocks (~>
|
31
|
-
rspec-core (
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
27
|
+
rspec (3.0.0)
|
28
|
+
rspec-core (~> 3.0.0)
|
29
|
+
rspec-expectations (~> 3.0.0)
|
30
|
+
rspec-mocks (~> 3.0.0)
|
31
|
+
rspec-core (3.0.3)
|
32
|
+
rspec-support (~> 3.0.0)
|
33
|
+
rspec-expectations (3.0.3)
|
34
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
35
|
+
rspec-support (~> 3.0.0)
|
36
|
+
rspec-mocks (3.0.3)
|
37
|
+
rspec-support (~> 3.0.0)
|
38
|
+
rspec-support (3.0.3)
|
39
|
+
rubocop (0.24.1)
|
36
40
|
json (>= 1.7.7, < 2)
|
37
|
-
parser (
|
41
|
+
parser (>= 2.2.0.pre.3, < 3.0)
|
38
42
|
powerpack (~> 0.0.6)
|
39
43
|
rainbow (>= 1.99.1, < 3.0)
|
40
44
|
ruby-progressbar (~> 1.4)
|
data/README.md
CHANGED
@@ -30,6 +30,8 @@ All you need is a `.singularityrc` file in your repository, the `singularity_run
|
|
30
30
|
-a, [--all-tasks], [--no-all-tasks] # Do not stop on task failure(s), collect all results
|
31
31
|
-s, [--script=SCRIPT] # Specify path to a .singularityrc file
|
32
32
|
# Default: ./.singularityrc
|
33
|
+
[--env=one two three] # EnvVars to set, formatted as VAR:VAL
|
34
|
+
[--flags=one two three] # Runtime flags to set for use with flag_set?, formatted as VAR:VAL
|
33
35
|
|
34
36
|
The `singularity_runner` is designed to do two things:
|
35
37
|
|
@@ -87,7 +89,7 @@ What this means is that you can pass blocks of code to tasks from your `.singula
|
|
87
89
|
|
88
90
|
### `singularity_runner`, Custom Tasks & Task Extensions
|
89
91
|
|
90
|
-
As mentioned, `singularity_runner` can load custom tasks or task extensions. By default, it will load **all
|
92
|
+
As mentioned, `singularity_runner` can load custom tasks or task extensions. By default, it will load **all `.rb`** files in `cwd/.singularity`
|
91
93
|
|
92
94
|
This allows you to do a few things:
|
93
95
|
|
@@ -246,6 +248,48 @@ singularity_runner testmerge git@github.com:me/repo feature-branch master git@gi
|
|
246
248
|
```
|
247
249
|
Will perform the test merge & then pass ALL of the changed files in that merge into the `.singularityrc`!
|
248
250
|
|
251
|
+
## Environment Variables && Custom Runtime Flags
|
252
|
+
|
253
|
+
The `singularity_runner` allows you to set custom environment variables for your scripts & tools to use.
|
254
|
+
|
255
|
+
```
|
256
|
+
singularity_runner test --env MY_REPO:git@github.com:me/foo
|
257
|
+
```
|
258
|
+
|
259
|
+
Will set `ENV['MY_REPO'] = 'git@github.com:me/foo'`
|
260
|
+
|
261
|
+
Similarly, you can also set flags to better direct more complicated workflows.
|
262
|
+
|
263
|
+
```
|
264
|
+
singularity_runner test --flags npm phpunit-suite:ci
|
265
|
+
```
|
266
|
+
|
267
|
+
Will allow you to run something like this:
|
268
|
+
|
269
|
+
```ruby
|
270
|
+
# works! npm == true here
|
271
|
+
if flag? 'npm' do
|
272
|
+
npm { action 'install' }
|
273
|
+
end
|
274
|
+
|
275
|
+
# suite_name == 'ci' here
|
276
|
+
suite_name = flag? 'phpunit-suite' || 'default'
|
277
|
+
phpunit { suite suite_name }
|
278
|
+
```
|
279
|
+
|
280
|
+
Assuming that you have already defined `npm` & `phpunit` tasks.
|
281
|
+
|
282
|
+
## Using Task File Paths during runtime
|
283
|
+
|
284
|
+
The DSL also keeps a record of where each task is defined. To get that path:
|
285
|
+
|
286
|
+
```
|
287
|
+
SingularityDsl.task_file(self)
|
288
|
+
```
|
289
|
+
|
290
|
+
This is just a utility function provided to you when writing new Tasks.
|
291
|
+
You *can* use it in your `.singularityrc` but it's not recommended that you do.
|
292
|
+
|
249
293
|
## Contributing
|
250
294
|
|
251
295
|
1. Fork it
|
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
require 'singularity_dsl/application'
|
4
4
|
require 'singularity_dsl/cli/table'
|
5
|
+
require 'singularity_dsl/cli/utils'
|
5
6
|
require 'singularity_dsl/dsl/dsl'
|
6
7
|
require 'singularity_dsl/errors'
|
7
8
|
require 'singularity_dsl/git_helper'
|
8
|
-
require 'singularity_dsl/stdout'
|
9
9
|
require 'thor'
|
10
10
|
|
11
11
|
module SingularityDsl
|
@@ -14,8 +14,8 @@ module SingularityDsl
|
|
14
14
|
# CLI Thor app
|
15
15
|
class Cli < Thor
|
16
16
|
include Errors
|
17
|
-
include Stdout
|
18
17
|
include Table
|
18
|
+
include Utils
|
19
19
|
|
20
20
|
attr_reader :git
|
21
21
|
|
@@ -23,12 +23,7 @@ module SingularityDsl
|
|
23
23
|
super
|
24
24
|
@diff_list = nil
|
25
25
|
@git = GitHelper.new
|
26
|
-
|
27
|
-
envvars.each do |pair|
|
28
|
-
key = pair.split(':', 2).first
|
29
|
-
val = pair.split(':', 2).last
|
30
|
-
ENV[key] = val
|
31
|
-
end
|
26
|
+
env_vars(options[:env] || [])
|
32
27
|
end
|
33
28
|
|
34
29
|
class_option :task_path,
|
@@ -48,6 +43,11 @@ module SingularityDsl
|
|
48
43
|
class_option :env,
|
49
44
|
type: :array,
|
50
45
|
desc: 'EnvVars to set, formatted as VAR:VAL'
|
46
|
+
class_option :flags,
|
47
|
+
type: :array,
|
48
|
+
desc: <<-EOD
|
49
|
+
Runtime flags to set for use with flag_set?, formatted as VAR:VAL
|
50
|
+
EOD
|
51
51
|
|
52
52
|
# TASKS COMMAND
|
53
53
|
desc 'tasks', 'Available tasks.'
|
@@ -64,7 +64,10 @@ module SingularityDsl
|
|
64
64
|
# TEST COMMAND
|
65
65
|
desc 'test', 'Run singularity script.'
|
66
66
|
def test(app = nil)
|
67
|
-
app ||= setup_app(Application.new,
|
67
|
+
app ||= setup_app(Application.new,
|
68
|
+
singularity_script,
|
69
|
+
tasks_path,
|
70
|
+
options[:flags] || [])
|
68
71
|
exit(app.run false, options[:all_tasks])
|
69
72
|
end
|
70
73
|
|
@@ -72,7 +75,10 @@ module SingularityDsl
|
|
72
75
|
desc 'batch BATCH_NAME',
|
73
76
|
'Run single task batch in the .singularityrc script.'
|
74
77
|
def batch(batch, app = nil)
|
75
|
-
app ||= setup_app(Application.new,
|
78
|
+
app ||= setup_app(Application.new,
|
79
|
+
singularity_script,
|
80
|
+
tasks_path,
|
81
|
+
options[:flags] || [])
|
76
82
|
exit(app.run batch, options[:all_tasks])
|
77
83
|
end
|
78
84
|
|
@@ -108,21 +114,6 @@ module SingularityDsl
|
|
108
114
|
target
|
109
115
|
end
|
110
116
|
|
111
|
-
def setup_app(app, singularity_script, tasks_path)
|
112
|
-
if File.exist? tasks_path
|
113
|
-
info "Loading tasks from #{tasks_path}"
|
114
|
-
app.load_tasks tasks_path
|
115
|
-
end
|
116
|
-
unless @diff_list.nil?
|
117
|
-
info 'Running with diff-list'
|
118
|
-
list_items @diff_list
|
119
|
-
app.change_list @diff_list
|
120
|
-
end
|
121
|
-
info "Loading CI script from #{singularity_script} ..."
|
122
|
-
app.load_script singularity_script
|
123
|
-
app
|
124
|
-
end
|
125
|
-
|
126
117
|
def singularity_script
|
127
118
|
File.expand_path options[:script]
|
128
119
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'singularity_dsl/stdout'
|
4
|
+
|
5
|
+
module SingularityDsl
|
6
|
+
# CLI
|
7
|
+
module Cli
|
8
|
+
# util functions
|
9
|
+
module Utils
|
10
|
+
include Stdout
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def env_vars(vals)
|
15
|
+
vals.each do |pair|
|
16
|
+
key = pair.split(':', 2).first
|
17
|
+
val = pair.split(':', 2).last
|
18
|
+
ENV[key] = val
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def setup_app(app, singularity_script, tasks_path, flags = [])
|
23
|
+
inject_flags app, flags
|
24
|
+
inject_diff_list app
|
25
|
+
if ::File.exist? tasks_path
|
26
|
+
info "Loading tasks from #{tasks_path}"
|
27
|
+
app.load_tasks tasks_path
|
28
|
+
end
|
29
|
+
info "Loading CI script from #{singularity_script} ..."
|
30
|
+
app.load_script singularity_script
|
31
|
+
app
|
32
|
+
end
|
33
|
+
|
34
|
+
def inject_flags(app, flags = [])
|
35
|
+
flags.each do |pair|
|
36
|
+
key = pair.split(':', 2).first
|
37
|
+
val = pair.split(':', 2).last
|
38
|
+
app.runner.dsl.flag key if key == val
|
39
|
+
app.runner.dsl.flag key, val unless key == val
|
40
|
+
end
|
41
|
+
app
|
42
|
+
end
|
43
|
+
|
44
|
+
def inject_diff_list(app)
|
45
|
+
unless @diff_list.nil?
|
46
|
+
info 'Running with diff-list'
|
47
|
+
list_items @diff_list
|
48
|
+
app.change_list @diff_list
|
49
|
+
end
|
50
|
+
app
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -17,11 +17,12 @@ module SingularityDsl
|
|
17
17
|
include Files
|
18
18
|
include Utils
|
19
19
|
|
20
|
-
attr_reader :registry
|
20
|
+
attr_reader :registry, :flags
|
21
21
|
|
22
22
|
def initialize
|
23
23
|
super
|
24
24
|
@registry = Registry.new
|
25
|
+
@flags = {}
|
25
26
|
load_tasks_in_path default_task_dir
|
26
27
|
end
|
27
28
|
|
@@ -55,6 +56,15 @@ module SingularityDsl
|
|
55
56
|
@registry.batch(name, self, &block)
|
56
57
|
end
|
57
58
|
|
59
|
+
def flag(name, val = true)
|
60
|
+
@flags[name.to_sym] = val
|
61
|
+
end
|
62
|
+
|
63
|
+
def flag?(flag)
|
64
|
+
return @flags[flag.to_sym] if @flags.key? flag.to_sym
|
65
|
+
false
|
66
|
+
end
|
67
|
+
|
58
68
|
private
|
59
69
|
|
60
70
|
def raise_task_def_error(klass)
|
@@ -28,7 +28,7 @@ module SingularityDsl
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def diff_remote(branch, url, flags = '')
|
31
|
-
flags = flags.join ' ' if flags.
|
31
|
+
flags = flags.join ' ' if flags.is_a? Array
|
32
32
|
cmd = remote_cmd branch, url, "diff #{flags}"
|
33
33
|
task = Mixlib::ShellOut.new cmd
|
34
34
|
task.run_command
|
@@ -35,11 +35,9 @@ class Rubocop < Task
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def execute
|
38
|
-
|
39
|
-
#
|
40
|
-
|
41
|
-
false
|
42
|
-
end
|
38
|
+
runner = ::RuboCop::Runner.new({}, @cfg_store)
|
39
|
+
# returns true if all files passed, false otherwise
|
40
|
+
!runner.run(files)
|
43
41
|
end
|
44
42
|
|
45
43
|
def description
|
data/singularity_dsl.gemspec
CHANGED
@@ -21,8 +21,8 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_dependency 'mixlib-shellout', '~> 1.4'
|
22
22
|
spec.add_dependency 'rainbow', '~> 2.0.0'
|
23
23
|
spec.add_dependency 'rake', '~> 10.3'
|
24
|
-
spec.add_dependency 'rspec', '~>
|
25
|
-
spec.add_dependency 'rubocop', '~> 0.
|
24
|
+
spec.add_dependency 'rspec', '~> 3.0'
|
25
|
+
spec.add_dependency 'rubocop', '~> 0.24'
|
26
26
|
spec.add_dependency 'terminal-table', '~> 1.4'
|
27
27
|
spec.add_dependency 'thor', '~> 0.19'
|
28
28
|
|
@@ -14,7 +14,7 @@ describe 'Application' do
|
|
14
14
|
context '#load_script' do
|
15
15
|
it 'just calls runner.load_ex_script' do
|
16
16
|
stub_res = 'spooooooky ghooooost'
|
17
|
-
|
17
|
+
allow(app.runner).to(receive(:load_ex_script).and_return stub_res)
|
18
18
|
expect(app.load_script 'dummy').to eql stub_res
|
19
19
|
end
|
20
20
|
end
|
@@ -22,38 +22,42 @@ describe 'Application' do
|
|
22
22
|
context '#run' do
|
23
23
|
it 'logs resource failures' do
|
24
24
|
# don't want the entire thing to exit...
|
25
|
-
app.
|
26
|
-
app.runner.
|
25
|
+
allow(app).to receive(:post_task_runner_actions)
|
26
|
+
allow(app.runner).to receive(:execute)
|
27
|
+
.and_raise(SingularityDsl::Errors::ResourceFail)
|
27
28
|
expect(app).to receive(:log_resource_fail)
|
28
29
|
app.run
|
29
30
|
end
|
30
31
|
|
31
32
|
it 'runner post-script actions are evaulated on failure' do
|
32
|
-
app.
|
33
|
-
app.
|
34
|
-
app.runner.
|
33
|
+
allow(app).to receive(:post_task_runner_actions)
|
34
|
+
allow(app).to receive(:log_resource_fail)
|
35
|
+
allow(app.runner).to receive(:execute)
|
36
|
+
.and_raise(SingularityDsl::Errors::ResourceFail)
|
35
37
|
expect(app).to receive(:post_task_runner_actions)
|
36
38
|
app.run
|
37
39
|
end
|
38
40
|
|
39
41
|
it 'logs resource errors' do
|
40
|
-
app.
|
41
|
-
app.runner.
|
42
|
+
allow(app).to receive(:post_task_runner_actions)
|
43
|
+
allow(app.runner).to receive(:execute)
|
44
|
+
.and_raise(SingularityDsl::Errors::ResourceError)
|
42
45
|
expect(app).to receive(:log_resource_error)
|
43
46
|
app.run
|
44
47
|
end
|
45
48
|
|
46
49
|
it 'runner post-script actions are evaulated on error' do
|
47
|
-
app.
|
48
|
-
app.
|
49
|
-
app.runner.
|
50
|
+
allow(app).to receive(:post_task_runner_actions)
|
51
|
+
allow(app).to receive(:log_resource_error)
|
52
|
+
allow(app.runner).to receive(:execute)
|
53
|
+
.and_raise(SingularityDsl::Errors::ResourceError)
|
50
54
|
expect(app).to receive(:post_task_runner_actions)
|
51
55
|
app.run
|
52
56
|
end
|
53
57
|
|
54
58
|
it 'runner post-script actions are evaulated on error' do
|
55
|
-
app.
|
56
|
-
app.
|
59
|
+
allow(app).to receive(:post_task_runner_actions)
|
60
|
+
allow(app).to receive(:execute)
|
57
61
|
expect(app.runner.state).to receive :exit_code
|
58
62
|
app.run
|
59
63
|
end
|
@@ -61,19 +65,19 @@ describe 'Application' do
|
|
61
65
|
|
62
66
|
context '#post_task_runner_actions' do
|
63
67
|
it 'outputs warning when script fails' do
|
64
|
-
app.
|
65
|
-
app.runner.
|
66
|
-
app.
|
67
|
-
app.runner.state.
|
68
|
+
allow(app).to receive(:script_warn)
|
69
|
+
allow(app.runner).to receive(:post_actions)
|
70
|
+
allow(app).to receive(:exit_run)
|
71
|
+
allow(app.runner.state).to receive(:failed).and_return(true)
|
68
72
|
expect(app).to receive(:script_warn)
|
69
73
|
app.post_task_runner_actions
|
70
74
|
end
|
71
75
|
|
72
76
|
it 'outputs warning when script errors' do
|
73
|
-
app.
|
74
|
-
app.runner.
|
75
|
-
app.
|
76
|
-
app.runner.state.
|
77
|
+
allow(app).to receive(:script_error)
|
78
|
+
allow(app.runner).to receive(:post_actions)
|
79
|
+
allow(app).to receive(:exit_run)
|
80
|
+
allow(app.runner.state).to receive(:error).and_return(true)
|
77
81
|
expect(app).to receive(:script_error)
|
78
82
|
app.post_task_runner_actions
|
79
83
|
end
|
@@ -13,13 +13,13 @@ describe 'Cli' do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'runs test method if no run_task' do
|
16
|
-
cli.
|
16
|
+
allow(cli).to receive(:target_run_task).and_return(false)
|
17
17
|
expect(cli).to receive(:test)
|
18
18
|
cli.testmerge 'fork', 'fork_branch', 'base_branch'
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'runs batch method if no run_task' do
|
22
|
-
cli.
|
22
|
+
allow(cli).to receive(:target_run_task).and_return('test_batch')
|
23
23
|
expect(cli).to receive(:batch)
|
24
24
|
cli.testmerge 'fork', 'fork_branch', 'base_branch'
|
25
25
|
end
|
@@ -25,13 +25,13 @@ describe 'DslChangeset' do
|
|
25
25
|
|
26
26
|
context '#changed_files' do
|
27
27
|
before :each do
|
28
|
-
::File.
|
28
|
+
allow(::File).to receive(:exist?)
|
29
29
|
.with('something.css')
|
30
30
|
.and_return(true)
|
31
|
-
::File.
|
31
|
+
allow(::File).to receive(:exist?)
|
32
32
|
.with('something.js')
|
33
33
|
.and_return(true)
|
34
|
-
::File.
|
34
|
+
allow(::File).to receive(:exist?)
|
35
35
|
.with('something.php')
|
36
36
|
.and_return(false)
|
37
37
|
end
|
@@ -45,4 +45,32 @@ describe 'Dsl' do
|
|
45
45
|
SingularityDsl.reset_map
|
46
46
|
end
|
47
47
|
end
|
48
|
+
|
49
|
+
context '#flag' do
|
50
|
+
it 'sets true by default' do
|
51
|
+
dsl.flag 'default'
|
52
|
+
expect(dsl.flags).to eql default: true
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'sets vals' do
|
56
|
+
dsl.flag 'foo', 'bar'
|
57
|
+
expect(dsl.flags).to eql foo: 'bar'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context '#flag?' do
|
62
|
+
it 'returns false by default' do
|
63
|
+
expect(dsl.flag? 'blah').to eql false
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'returns true by default' do
|
67
|
+
dsl.flag 'default'
|
68
|
+
expect(dsl.flag? 'default').to eql true
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'returns vals' do
|
72
|
+
dsl.flag 'foo', 'bar'
|
73
|
+
expect(dsl.flag? 'foo').to eql 'bar'
|
74
|
+
end
|
75
|
+
end
|
48
76
|
end
|
@@ -21,8 +21,8 @@ describe 'DslRunner' do
|
|
21
21
|
context '#execute' do
|
22
22
|
it 'taps & evaluates failed task.execute statuses correctly' do
|
23
23
|
task = SingularityDsl::Task.new
|
24
|
-
task.
|
25
|
-
runner.dsl.registry.
|
24
|
+
allow(task).to receive(:execute).and_return(true)
|
25
|
+
allow(runner.dsl.registry).to receive(:run_list).and_return([task])
|
26
26
|
expect(runner).to receive(:record_failure).with task
|
27
27
|
expect(runner).to receive(:resource_fail).with task
|
28
28
|
runner.execute
|
@@ -31,7 +31,7 @@ describe 'DslRunner' do
|
|
31
31
|
|
32
32
|
context '#load_ex_script' do
|
33
33
|
it 'instance_evals contents of a file' do
|
34
|
-
::File.
|
34
|
+
allow(::File).to receive(:read).and_return('0')
|
35
35
|
expect(runner.dsl).to receive(:instance_eval).with('0')
|
36
36
|
runner.load_ex_script 'foo'
|
37
37
|
end
|
@@ -4,18 +4,16 @@ require 'singularity_dsl/git_helper'
|
|
4
4
|
|
5
5
|
describe 'GitHelper' do
|
6
6
|
before :each do
|
7
|
-
SingularityDsl::GitHelper
|
8
|
-
|
9
|
-
|
10
|
-
.and_return true
|
7
|
+
allow_any_instance_of(SingularityDsl::GitHelper)
|
8
|
+
.to receive(:git_installed)
|
9
|
+
.and_return true
|
11
10
|
end
|
12
11
|
let(:git) { SingularityDsl::GitHelper.new }
|
13
12
|
|
14
13
|
context '#initialize' do
|
15
14
|
it 'throws if git is not installed' do
|
16
|
-
SingularityDsl::GitHelper
|
17
|
-
.
|
18
|
-
.stub(:git_installed)
|
15
|
+
allow_any_instance_of(SingularityDsl::GitHelper)
|
16
|
+
.to receive(:git_installed)
|
19
17
|
.and_return false
|
20
18
|
expect { SingularityDsl::GitHelper.new }
|
21
19
|
.to(raise_error ArgumentError, /git not installed/)
|
@@ -24,22 +22,22 @@ describe 'GitHelper' do
|
|
24
22
|
|
25
23
|
context '#clean_reset' do
|
26
24
|
it 'fails when reset fails' do
|
27
|
-
git.
|
28
|
-
git.
|
25
|
+
allow(git).to receive(:reset).and_return(1)
|
26
|
+
allow(git).to receive(:clean).and_return(0)
|
29
27
|
expect { git.clean_reset }
|
30
28
|
.to(raise_error RuntimeError, /failed to clean/)
|
31
29
|
end
|
32
30
|
|
33
31
|
it 'fails when clean fails' do
|
34
|
-
git.
|
35
|
-
git.
|
32
|
+
allow(git).to receive(:reset).and_return(0)
|
33
|
+
allow(git).to receive(:clean).and_return(1)
|
36
34
|
expect { git.clean_reset }
|
37
35
|
.to(raise_error RuntimeError, /failed to clean/)
|
38
36
|
end
|
39
37
|
|
40
38
|
it 'fails when both reset & clean fail' do
|
41
|
-
git.
|
42
|
-
git.
|
39
|
+
allow(git).to receive(:reset).and_return(1)
|
40
|
+
allow(git).to receive(:clean).and_return(1)
|
43
41
|
expect { git.clean_reset }
|
44
42
|
.to(raise_error RuntimeError, /failed to clean/)
|
45
43
|
end
|
@@ -47,25 +45,31 @@ describe 'GitHelper' do
|
|
47
45
|
|
48
46
|
context '#merge_remote' do
|
49
47
|
it 'generates & calls correct cmd' do
|
50
|
-
git.
|
51
|
-
git.
|
52
|
-
|
48
|
+
allow(git).to receive(:remotes).and_return([])
|
49
|
+
allow(git).to receive(:exec)
|
50
|
+
.with('git fetch --all')
|
51
|
+
allow(git).to receive(:exec)
|
52
|
+
.with('git merge bar/foo').and_return(0)
|
53
53
|
git.merge_remote 'foo', 'bar'
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
57
|
context '#diff_remote' do
|
58
58
|
it 'generates & calls correct cmd w/ single flag' do
|
59
|
-
git.
|
60
|
-
git.
|
61
|
-
|
59
|
+
allow(git).to receive(:remotes).and_return([])
|
60
|
+
allow(git).to receive(:exec)
|
61
|
+
.with('git fetch --all')
|
62
|
+
allow(git).to receive(:exec)
|
63
|
+
.with('git diff bar/foo --flag').and_return(0)
|
62
64
|
git.diff_remote 'foo', 'bar', '--flag'
|
63
65
|
end
|
64
66
|
|
65
67
|
it 'generates & calls correct cmd w/ multiple flags' do
|
66
|
-
git.
|
67
|
-
git.
|
68
|
-
|
68
|
+
allow(git).to receive(:remotes).and_return([])
|
69
|
+
allow(git).to receive(:exec)
|
70
|
+
.with('git fetch --all')
|
71
|
+
allow(git).to receive(:exec)
|
72
|
+
.with('git diff bar/foo --flag --other').and_return(0)
|
69
73
|
git.diff_remote 'foo', 'bar', %w(--flag, --other)
|
70
74
|
end
|
71
75
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: singularity_dsl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- chr0n1x
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mixlib-shellout
|
@@ -58,28 +58,28 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '3.0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '3.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rubocop
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ~>
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.
|
75
|
+
version: '0.24'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - ~>
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.
|
82
|
+
version: '0.24'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: terminal-table
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -158,6 +158,7 @@ files:
|
|
158
158
|
- lib/singularity_dsl/application.rb
|
159
159
|
- lib/singularity_dsl/cli/cli.rb
|
160
160
|
- lib/singularity_dsl/cli/table.rb
|
161
|
+
- lib/singularity_dsl/cli/utils.rb
|
161
162
|
- lib/singularity_dsl/dsl/batch.rb
|
162
163
|
- lib/singularity_dsl/dsl/changeset.rb
|
163
164
|
- lib/singularity_dsl/dsl/components.rb
|