local_ci 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/local_ci/dsl.rb +8 -0
- data/lib/local_ci/flow.rb +45 -28
- data/lib/local_ci/generator/buildkite.rb +41 -0
- data/lib/local_ci/generator/semaphore_ci.rb +55 -0
- data/lib/local_ci/helper.rb +49 -3
- data/lib/local_ci/job.rb +41 -10
- data/lib/local_ci/output.rb +71 -30
- data/lib/local_ci/rake.rb +17 -0
- data/lib/local_ci/task.rb +4 -2
- data/lib/local_ci.rb +13 -0
- metadata +46 -18
- data/.gitignore +0 -2
- data/Gemfile +0 -10
- data/Gemfile.lock +0 -97
- data/Rakefile +0 -44
- data/local_ci.gemspec +0 -19
- data/spec/spec_helper.rb +0 -15
- data/spec/support/dsl_klass.rb +0 -5
- data/spec/unit/local_ci/dsl_spec.rb +0 -85
- data/spec/unit/local_ci/exec_context_spec.rb +0 -106
- data/spec/unit/local_ci/failure_spec.rb +0 -12
- data/spec/unit/local_ci/flow_spec.rb +0 -225
- data/spec/unit/local_ci/helper_spec.rb +0 -31
- data/spec/unit/local_ci/job_spec.rb +0 -171
- data/spec/unit/local_ci/output_spec.rb +0 -413
- data/spec/unit/local_ci/rake_spec.rb +0 -16
- data/spec/unit/local_ci/task_spec.rb +0 -114
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
PATH
|
|
2
|
-
remote: .
|
|
3
|
-
specs:
|
|
4
|
-
local_ci (0.0.4)
|
|
5
|
-
logger
|
|
6
|
-
pastel
|
|
7
|
-
rake
|
|
8
|
-
tty-command
|
|
9
|
-
tty-cursor
|
|
10
|
-
tty-screen
|
|
11
|
-
|
|
12
|
-
GEM
|
|
13
|
-
remote: https://rubygems.org/
|
|
14
|
-
specs:
|
|
15
|
-
ast (2.4.3)
|
|
16
|
-
diff-lcs (1.6.2)
|
|
17
|
-
json (2.17.1)
|
|
18
|
-
language_server-protocol (3.17.0.5)
|
|
19
|
-
lint_roller (1.1.0)
|
|
20
|
-
logger (1.7.0)
|
|
21
|
-
parallel (1.27.0)
|
|
22
|
-
parser (3.3.10.0)
|
|
23
|
-
ast (~> 2.4.1)
|
|
24
|
-
racc
|
|
25
|
-
pastel (0.8.0)
|
|
26
|
-
tty-color (~> 0.5)
|
|
27
|
-
prism (1.6.0)
|
|
28
|
-
racc (1.8.1)
|
|
29
|
-
rainbow (3.1.1)
|
|
30
|
-
rake (13.3.1)
|
|
31
|
-
regexp_parser (2.11.3)
|
|
32
|
-
rspec (3.13.2)
|
|
33
|
-
rspec-core (~> 3.13.0)
|
|
34
|
-
rspec-expectations (~> 3.13.0)
|
|
35
|
-
rspec-mocks (~> 3.13.0)
|
|
36
|
-
rspec-core (3.13.6)
|
|
37
|
-
rspec-support (~> 3.13.0)
|
|
38
|
-
rspec-expectations (3.13.5)
|
|
39
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
|
40
|
-
rspec-support (~> 3.13.0)
|
|
41
|
-
rspec-mocks (3.13.7)
|
|
42
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
|
43
|
-
rspec-support (~> 3.13.0)
|
|
44
|
-
rspec-support (3.13.6)
|
|
45
|
-
rubocop (1.81.7)
|
|
46
|
-
json (~> 2.3)
|
|
47
|
-
language_server-protocol (~> 3.17.0.2)
|
|
48
|
-
lint_roller (~> 1.1.0)
|
|
49
|
-
parallel (~> 1.10)
|
|
50
|
-
parser (>= 3.3.0.2)
|
|
51
|
-
rainbow (>= 2.2.2, < 4.0)
|
|
52
|
-
regexp_parser (>= 2.9.3, < 3.0)
|
|
53
|
-
rubocop-ast (>= 1.47.1, < 2.0)
|
|
54
|
-
ruby-progressbar (~> 1.7)
|
|
55
|
-
unicode-display_width (>= 2.4.0, < 4.0)
|
|
56
|
-
rubocop-ast (1.48.0)
|
|
57
|
-
parser (>= 3.3.7.2)
|
|
58
|
-
prism (~> 1.4)
|
|
59
|
-
rubocop-performance (1.25.0)
|
|
60
|
-
lint_roller (~> 1.1)
|
|
61
|
-
rubocop (>= 1.75.0, < 2.0)
|
|
62
|
-
rubocop-ast (>= 1.38.0, < 2.0)
|
|
63
|
-
ruby-progressbar (1.13.0)
|
|
64
|
-
standard (1.52.0)
|
|
65
|
-
language_server-protocol (~> 3.17.0.2)
|
|
66
|
-
lint_roller (~> 1.0)
|
|
67
|
-
rubocop (~> 1.81.7)
|
|
68
|
-
standard-custom (~> 1.0.0)
|
|
69
|
-
standard-performance (~> 1.8)
|
|
70
|
-
standard-custom (1.0.2)
|
|
71
|
-
lint_roller (~> 1.0)
|
|
72
|
-
rubocop (~> 1.50)
|
|
73
|
-
standard-performance (1.8.0)
|
|
74
|
-
lint_roller (~> 1.1)
|
|
75
|
-
rubocop-performance (~> 1.25.0)
|
|
76
|
-
standardrb (1.0.1)
|
|
77
|
-
standard
|
|
78
|
-
tty-color (0.6.0)
|
|
79
|
-
tty-command (0.10.1)
|
|
80
|
-
pastel (~> 0.8)
|
|
81
|
-
tty-cursor (0.7.1)
|
|
82
|
-
tty-screen (0.8.2)
|
|
83
|
-
unicode-display_width (3.2.0)
|
|
84
|
-
unicode-emoji (~> 4.1)
|
|
85
|
-
unicode-emoji (4.1.0)
|
|
86
|
-
|
|
87
|
-
PLATFORMS
|
|
88
|
-
ruby
|
|
89
|
-
x86_64-linux
|
|
90
|
-
|
|
91
|
-
DEPENDENCIES
|
|
92
|
-
local_ci!
|
|
93
|
-
rspec
|
|
94
|
-
standardrb
|
|
95
|
-
|
|
96
|
-
BUNDLED WITH
|
|
97
|
-
2.7.2
|
data/Rakefile
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
require "standard/rake"
|
|
2
|
-
require "local_ci"
|
|
3
|
-
|
|
4
|
-
LocalCI::Rake.setup(self)
|
|
5
|
-
|
|
6
|
-
setup do
|
|
7
|
-
job "Bundle", "bundle check | bundle install"
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
teardown do
|
|
11
|
-
job "Echo", "echo", "global teardown"
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
flow "Linting" do
|
|
15
|
-
job "StandardRB", "bundle exec rake standard"
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
flow "Specs" do
|
|
19
|
-
setup do
|
|
20
|
-
job "Specs Setup", "echo specs setup"
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
teardown do
|
|
24
|
-
job "Specs Teardown", "echo specs teardown"
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
job "RSpec", "bundle exec rspec"
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
flow "Build" do
|
|
31
|
-
setup do
|
|
32
|
-
job "Start docker", "echo docker start"
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
Dir.glob("*").each do |file|
|
|
36
|
-
job "Compile - #{file}" do
|
|
37
|
-
run "echo", "gcc", file
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
teardown do
|
|
42
|
-
job "Stop Docker", "echo docker stop"
|
|
43
|
-
end
|
|
44
|
-
end
|
data/local_ci.gemspec
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
Gem::Specification.new do |s|
|
|
2
|
-
s.name = "local_ci"
|
|
3
|
-
s.version = "0.0.5"
|
|
4
|
-
s.summary = "Run CI locally"
|
|
5
|
-
s.description = "A way to run CI locally but also able to run easily on your hosted CI"
|
|
6
|
-
s.authors = ["Sean Earle"]
|
|
7
|
-
s.email = "sean.r.earle@gmail.com"
|
|
8
|
-
s.files = `git ls-files`.split($\)
|
|
9
|
-
s.executables = []
|
|
10
|
-
s.homepage = "https://github.com/HellRok/local_ci"
|
|
11
|
-
s.license = "MIT"
|
|
12
|
-
|
|
13
|
-
s.add_dependency "logger"
|
|
14
|
-
s.add_dependency "pastel"
|
|
15
|
-
s.add_dependency "rake"
|
|
16
|
-
s.add_dependency "tty-command"
|
|
17
|
-
s.add_dependency "tty-cursor"
|
|
18
|
-
s.add_dependency "tty-screen"
|
|
19
|
-
end
|
data/spec/spec_helper.rb
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
require "rspec"
|
|
2
|
-
require "rake"
|
|
3
|
-
|
|
4
|
-
require "local_ci"
|
|
5
|
-
|
|
6
|
-
require "support/dsl_klass"
|
|
7
|
-
|
|
8
|
-
RSpec.configure do |config|
|
|
9
|
-
config.after(:example) do
|
|
10
|
-
Rake::Task.clear
|
|
11
|
-
|
|
12
|
-
LocalCI::Helper.instance_variable_set(:@pastel, nil)
|
|
13
|
-
LocalCI::Helper.instance_variable_set(:@runner, nil)
|
|
14
|
-
end
|
|
15
|
-
end
|
data/spec/support/dsl_klass.rb
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
require "spec_helper"
|
|
2
|
-
|
|
3
|
-
describe LocalCI::DSL do
|
|
4
|
-
before do
|
|
5
|
-
@block = -> {}
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
describe ".flow" do
|
|
9
|
-
it "calls LocalCI::Flow" do
|
|
10
|
-
expect(LocalCI::Flow).to receive(:new).with(
|
|
11
|
-
name: :name,
|
|
12
|
-
heading: "heading",
|
|
13
|
-
parallel: "parallel",
|
|
14
|
-
block: @block
|
|
15
|
-
)
|
|
16
|
-
|
|
17
|
-
Support::DSLKlass.new.flow(:name, "heading", parallel: "parallel", &@block)
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
context "when only passed a heading" do
|
|
21
|
-
it "converts the heading to a sensible name name" do
|
|
22
|
-
expect(LocalCI::Flow).to receive(:new).with(
|
|
23
|
-
name: :my_cool_flow,
|
|
24
|
-
heading: "My Cool Flow!",
|
|
25
|
-
parallel: true,
|
|
26
|
-
block: @block
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
Support::DSLKlass.new.flow("My Cool Flow!", &@block)
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
describe ".setup" do
|
|
35
|
-
it "calls LocalCI::Flow" do
|
|
36
|
-
expect(LocalCI::Flow).to receive(:new).with(
|
|
37
|
-
name: :setup,
|
|
38
|
-
heading: "Setup",
|
|
39
|
-
parallel: "parallel",
|
|
40
|
-
actions: false,
|
|
41
|
-
block: @block
|
|
42
|
-
)
|
|
43
|
-
|
|
44
|
-
Support::DSLKlass.new.setup(parallel: "parallel", &@block)
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
it "passes through the heading" do
|
|
48
|
-
expect(LocalCI::Flow).to receive(:new).with(
|
|
49
|
-
name: :setup,
|
|
50
|
-
heading: "My Cool Setup",
|
|
51
|
-
parallel: "parallel",
|
|
52
|
-
actions: false,
|
|
53
|
-
block: @block
|
|
54
|
-
)
|
|
55
|
-
|
|
56
|
-
Support::DSLKlass.new.setup("My Cool Setup", parallel: "parallel", &@block)
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
describe ".teardown" do
|
|
61
|
-
it "calls LocalCI::Flow" do
|
|
62
|
-
expect(LocalCI::Flow).to receive(:new).with(
|
|
63
|
-
name: :teardown,
|
|
64
|
-
heading: "Teardown",
|
|
65
|
-
parallel: "parallel",
|
|
66
|
-
actions: false,
|
|
67
|
-
block: @block
|
|
68
|
-
)
|
|
69
|
-
|
|
70
|
-
Support::DSLKlass.new.teardown(parallel: "parallel", &@block)
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
it "passes through the heading" do
|
|
74
|
-
expect(LocalCI::Flow).to receive(:new).with(
|
|
75
|
-
name: :teardown,
|
|
76
|
-
heading: "My Cool Teardown",
|
|
77
|
-
parallel: "parallel",
|
|
78
|
-
actions: false,
|
|
79
|
-
block: @block
|
|
80
|
-
)
|
|
81
|
-
|
|
82
|
-
Support::DSLKlass.new.teardown("My Cool Teardown", parallel: "parallel", &@block)
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
end
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
require "spec_helper"
|
|
2
|
-
|
|
3
|
-
describe LocalCI::ExecContext do
|
|
4
|
-
before do
|
|
5
|
-
@block = -> {}
|
|
6
|
-
@flow = double(
|
|
7
|
-
:flow,
|
|
8
|
-
task: "flow-task",
|
|
9
|
-
heading: "flow-heading"
|
|
10
|
-
)
|
|
11
|
-
@context = LocalCI::ExecContext.new(flow: @flow)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
describe "#initialize" do
|
|
15
|
-
it "assigns the flow" do
|
|
16
|
-
expect(@context.flow).to eq(@flow)
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
describe "#run" do
|
|
21
|
-
it "runs the commands" do
|
|
22
|
-
expect(LocalCI::Helper.runner).to receive(:run)
|
|
23
|
-
.with("command", "arg1", "arg2")
|
|
24
|
-
|
|
25
|
-
@context.instance_exec {
|
|
26
|
-
run "command", "arg1", "arg2"
|
|
27
|
-
}
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
describe "#setup" do
|
|
32
|
-
it "creates a new flow" do
|
|
33
|
-
expect(LocalCI::Flow).to receive(:new)
|
|
34
|
-
.with(
|
|
35
|
-
name: "flow-task:setup",
|
|
36
|
-
heading: "flow-heading - Setup",
|
|
37
|
-
parallel: false,
|
|
38
|
-
actions: false,
|
|
39
|
-
block: @block
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
block = @block
|
|
43
|
-
@context.instance_exec {
|
|
44
|
-
setup(&block)
|
|
45
|
-
}
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
it "passes through heading and parallel" do
|
|
49
|
-
expect(LocalCI::Flow).to receive(:new)
|
|
50
|
-
.with(
|
|
51
|
-
name: "flow-task:setup",
|
|
52
|
-
heading: "Special Setup",
|
|
53
|
-
parallel: "parallel",
|
|
54
|
-
actions: false,
|
|
55
|
-
block: @block
|
|
56
|
-
)
|
|
57
|
-
|
|
58
|
-
block = @block
|
|
59
|
-
@context.instance_exec {
|
|
60
|
-
setup(
|
|
61
|
-
"Special Setup",
|
|
62
|
-
parallel: "parallel",
|
|
63
|
-
&block
|
|
64
|
-
)
|
|
65
|
-
}
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
describe "#teardown" do
|
|
70
|
-
it "creates a new flow" do
|
|
71
|
-
expect(LocalCI::Flow).to receive(:new)
|
|
72
|
-
.with(
|
|
73
|
-
name: "flow-task:teardown",
|
|
74
|
-
heading: "flow-heading - Teardown",
|
|
75
|
-
parallel: false,
|
|
76
|
-
actions: false,
|
|
77
|
-
block: @block
|
|
78
|
-
)
|
|
79
|
-
|
|
80
|
-
block = @block
|
|
81
|
-
@context.instance_exec {
|
|
82
|
-
teardown(&block)
|
|
83
|
-
}
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
it "passes through heading and parallel" do
|
|
87
|
-
expect(LocalCI::Flow).to receive(:new)
|
|
88
|
-
.with(
|
|
89
|
-
name: "flow-task:teardown",
|
|
90
|
-
heading: "Special Teardown",
|
|
91
|
-
parallel: "parallel",
|
|
92
|
-
actions: false,
|
|
93
|
-
block: @block
|
|
94
|
-
)
|
|
95
|
-
|
|
96
|
-
block = @block
|
|
97
|
-
@context.instance_exec {
|
|
98
|
-
teardown(
|
|
99
|
-
"Special Teardown",
|
|
100
|
-
parallel: "parallel",
|
|
101
|
-
&block
|
|
102
|
-
)
|
|
103
|
-
}
|
|
104
|
-
end
|
|
105
|
-
end
|
|
106
|
-
end
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
require "spec_helper"
|
|
2
|
-
|
|
3
|
-
describe LocalCI::Failure do
|
|
4
|
-
describe "#initialize" do
|
|
5
|
-
it "sets up the instance variables" do
|
|
6
|
-
failure = LocalCI::Failure.new(job: "job", message: "message")
|
|
7
|
-
|
|
8
|
-
expect(failure.job).to eq("job")
|
|
9
|
-
expect(failure.message).to eq("message")
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
end
|
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
require "spec_helper"
|
|
2
|
-
|
|
3
|
-
describe LocalCI::Flow do
|
|
4
|
-
describe "#initialize" do
|
|
5
|
-
context "when creating parallel" do
|
|
6
|
-
it "call Rake::MultiTask" do
|
|
7
|
-
task = double(:task, prerequisites: [])
|
|
8
|
-
allow(task).to receive(:comment=)
|
|
9
|
-
allow(Rake::Task).to receive(:[]).and_return(task)
|
|
10
|
-
allow(Rake::Task).to receive(:define_task)
|
|
11
|
-
expect(Rake::MultiTask).to receive(:define_task).with("ci:parallel:jobs")
|
|
12
|
-
|
|
13
|
-
LocalCI::Flow.new(
|
|
14
|
-
name: "parallel",
|
|
15
|
-
heading: "heading",
|
|
16
|
-
parallel: true,
|
|
17
|
-
block: -> {}
|
|
18
|
-
)
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
context "when creating sequential" do
|
|
23
|
-
it "call Rake::Task" do
|
|
24
|
-
task = double(:task, prerequisites: [])
|
|
25
|
-
expect(task).to receive(:comment=).at_least(:once)
|
|
26
|
-
expect(Rake::Task).to receive(:[]).and_return(task).at_least(:once)
|
|
27
|
-
expect(Rake::Task).to receive(:define_task).with("ci:sequential:jobs").at_least(:once)
|
|
28
|
-
expect(Rake::Task).to receive(:define_task).at_least(:once)
|
|
29
|
-
|
|
30
|
-
LocalCI::Flow.new(
|
|
31
|
-
name: "sequential",
|
|
32
|
-
heading: "heading",
|
|
33
|
-
parallel: false,
|
|
34
|
-
block: -> {}
|
|
35
|
-
)
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
context "when actions is true" do
|
|
40
|
-
it "creates the expected tasks" do
|
|
41
|
-
LocalCI::Flow.new(
|
|
42
|
-
name: "actions",
|
|
43
|
-
heading: "heading",
|
|
44
|
-
parallel: true,
|
|
45
|
-
actions: true,
|
|
46
|
-
block: -> {}
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
expect(Rake::Task.task_defined?("ci")).to be(true)
|
|
50
|
-
expect(Rake::Task.task_defined?("ci:setup")).to be(true)
|
|
51
|
-
expect(Rake::Task.task_defined?("ci:actions")).to be(true)
|
|
52
|
-
expect(Rake::Task.task_defined?("ci:actions:setup")).to be(true)
|
|
53
|
-
expect(Rake::Task.task_defined?("ci:actions:jobs")).to be(true)
|
|
54
|
-
expect(Rake::Task.task_defined?("ci:actions:teardown")).to be(true)
|
|
55
|
-
expect(Rake::Task.task_defined?("ci:teardown")).to be(true)
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
context "when actions is false" do
|
|
60
|
-
it "creates the expected tasks" do
|
|
61
|
-
LocalCI::Flow.new(
|
|
62
|
-
name: "actionless",
|
|
63
|
-
heading: "heading",
|
|
64
|
-
parallel: true,
|
|
65
|
-
actions: false,
|
|
66
|
-
block: -> {}
|
|
67
|
-
)
|
|
68
|
-
|
|
69
|
-
expect(Rake::Task.task_defined?("ci")).to be(true)
|
|
70
|
-
expect(Rake::Task.task_defined?("ci:setup")).to be(true)
|
|
71
|
-
expect(Rake::Task.task_defined?("ci:actionless")).to be(true)
|
|
72
|
-
expect(Rake::Task.task_defined?("ci:actionless:setup")).to be(false)
|
|
73
|
-
expect(Rake::Task.task_defined?("ci:actionless:jobs")).to be(true)
|
|
74
|
-
expect(Rake::Task.task_defined?("ci:actionless:teardown")).to be(false)
|
|
75
|
-
expect(Rake::Task.task_defined?("ci:teardown")).to be(true)
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
it "gives tasks the right comments" do
|
|
80
|
-
LocalCI::Flow.new(
|
|
81
|
-
name: "test",
|
|
82
|
-
heading: "heading",
|
|
83
|
-
parallel: true,
|
|
84
|
-
block: -> {}
|
|
85
|
-
)
|
|
86
|
-
|
|
87
|
-
expect(Rake::Task["ci"].comment).to eq("Run the CI suite")
|
|
88
|
-
expect(Rake::Task["ci:setup"].comment).to eq("Setup the system to run CI")
|
|
89
|
-
expect(Rake::Task["ci:teardown"].comment).to eq("Cleanup after the CI")
|
|
90
|
-
expect(Rake::Task["ci:test"].comment).to eq("heading")
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
it "has the correct prerequisites for all tasks" do
|
|
94
|
-
LocalCI::Flow.new(
|
|
95
|
-
name: "test",
|
|
96
|
-
heading: "heading",
|
|
97
|
-
parallel: true,
|
|
98
|
-
block: -> {}
|
|
99
|
-
)
|
|
100
|
-
|
|
101
|
-
expect(Rake::Task["ci"].prerequisites).to eq(["ci:setup", "ci:test"])
|
|
102
|
-
expect(Rake::Task["ci:test"].prerequisites).to eq(["ci:test:teardown"])
|
|
103
|
-
expect(Rake::Task["ci:test:teardown"].prerequisites).to eq(["ci:test:jobs"])
|
|
104
|
-
expect(Rake::Task["ci:test:jobs"].prerequisites).to eq(["ci:test:setup"])
|
|
105
|
-
expect(Rake::Task["ci:test:setup"].prerequisites).to eq(["ci:setup"])
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
it "calls the expected jobs" do
|
|
109
|
-
allow(LocalCI::Job).to receive(:new)
|
|
110
|
-
|
|
111
|
-
job_1_block = -> {}
|
|
112
|
-
|
|
113
|
-
flow = LocalCI::Flow.new(
|
|
114
|
-
name: "test",
|
|
115
|
-
heading: "heading",
|
|
116
|
-
parallel: true,
|
|
117
|
-
block: -> {
|
|
118
|
-
job("Job 1", &job_1_block)
|
|
119
|
-
job("Job 2", "ls", "-la")
|
|
120
|
-
}
|
|
121
|
-
)
|
|
122
|
-
|
|
123
|
-
expect(LocalCI::Job).to have_received(:new).with(
|
|
124
|
-
flow: flow,
|
|
125
|
-
name: "Job 1",
|
|
126
|
-
command: [],
|
|
127
|
-
block: job_1_block
|
|
128
|
-
)
|
|
129
|
-
|
|
130
|
-
expect(LocalCI::Job).to have_received(:new).with(
|
|
131
|
-
flow: flow,
|
|
132
|
-
name: "Job 2",
|
|
133
|
-
command: ["ls", "-la"],
|
|
134
|
-
block: nil
|
|
135
|
-
)
|
|
136
|
-
end
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
describe "#after_jobs" do
|
|
140
|
-
before do
|
|
141
|
-
@flow = LocalCI::Flow.new(
|
|
142
|
-
name: "flow",
|
|
143
|
-
heading: "heading",
|
|
144
|
-
parallel: true,
|
|
145
|
-
block: -> {}
|
|
146
|
-
)
|
|
147
|
-
|
|
148
|
-
@ci = double(:ci, already_invoked: false)
|
|
149
|
-
allow(LocalCI::Task).to receive(:[]).with("ci").and_return(@ci)
|
|
150
|
-
|
|
151
|
-
@flow_teardown = double(:flow_teardown)
|
|
152
|
-
allow(@flow_teardown).to receive(:invoke)
|
|
153
|
-
allow(LocalCI::Task).to receive(:[]).with("ci:flow:teardown").and_return(@flow_teardown)
|
|
154
|
-
|
|
155
|
-
@teardown = double(:teardown)
|
|
156
|
-
allow(@teardown).to receive(:invoke)
|
|
157
|
-
allow(LocalCI::Task).to receive(:[]).with("ci:teardown").and_return(@teardown)
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
context "when there are no failures" do
|
|
161
|
-
it "runs ci:flow:teardown" do
|
|
162
|
-
expect(@flow_teardown).to receive(:invoke)
|
|
163
|
-
|
|
164
|
-
::Rake::Task["ci:flow"].invoke
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
context "when run in isolation" do
|
|
168
|
-
it "runs ci:teardown" do
|
|
169
|
-
expect(@teardown).to receive(:invoke)
|
|
170
|
-
|
|
171
|
-
::Rake::Task["ci:flow"].invoke
|
|
172
|
-
end
|
|
173
|
-
end
|
|
174
|
-
|
|
175
|
-
context "when not run in isolation" do
|
|
176
|
-
before do
|
|
177
|
-
allow(@ci).to receive(:already_invoked).and_return(true)
|
|
178
|
-
end
|
|
179
|
-
|
|
180
|
-
it "does not run ci:teardown" do
|
|
181
|
-
expect(@teardown).not_to receive(:invoke)
|
|
182
|
-
|
|
183
|
-
::Rake::Task["ci:flow"].invoke
|
|
184
|
-
end
|
|
185
|
-
end
|
|
186
|
-
end
|
|
187
|
-
|
|
188
|
-
context "when there are failures" do
|
|
189
|
-
before do
|
|
190
|
-
@failure = double(:failure, job: "job", message: "hi")
|
|
191
|
-
@flow.failures << @failure
|
|
192
|
-
|
|
193
|
-
allow(@flow).to receive(:abort)
|
|
194
|
-
|
|
195
|
-
@output = double(:output)
|
|
196
|
-
allow(@output).to receive(:failures)
|
|
197
|
-
allow(@flow).to receive(:output).and_return(@output)
|
|
198
|
-
end
|
|
199
|
-
|
|
200
|
-
it "runs ci:flow:teardown" do
|
|
201
|
-
expect(@flow_teardown).to receive(:invoke)
|
|
202
|
-
|
|
203
|
-
::Rake::Task["ci:flow"].invoke
|
|
204
|
-
end
|
|
205
|
-
|
|
206
|
-
it "invokes ci:teardown" do
|
|
207
|
-
expect(@teardown).to receive(:invoke)
|
|
208
|
-
|
|
209
|
-
::Rake::Task["ci:flow"].invoke
|
|
210
|
-
end
|
|
211
|
-
|
|
212
|
-
it "displays the failures" do
|
|
213
|
-
expect(@output).to receive(:failures)
|
|
214
|
-
|
|
215
|
-
::Rake::Task["ci:flow"].invoke
|
|
216
|
-
end
|
|
217
|
-
|
|
218
|
-
it "aborts with a message" do
|
|
219
|
-
expect(@flow).to receive(:abort).with(/heading failed, see ci\.log for more\./)
|
|
220
|
-
|
|
221
|
-
::Rake::Task["ci:flow"].invoke
|
|
222
|
-
end
|
|
223
|
-
end
|
|
224
|
-
end
|
|
225
|
-
end
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
require "spec_helper"
|
|
2
|
-
|
|
3
|
-
describe LocalCI::Helper do
|
|
4
|
-
describe ".pastel" do
|
|
5
|
-
it "returns a Pastel instance" do
|
|
6
|
-
expect(TTY::Color).to receive(:support?).and_return("support")
|
|
7
|
-
expect(Pastel).to receive(:new).with(enabled: "support")
|
|
8
|
-
.and_return("pastel")
|
|
9
|
-
|
|
10
|
-
expect(LocalCI::Helper.pastel).to eq("pastel")
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
describe ".runner" do
|
|
15
|
-
it "returns a TTY::Command instance" do
|
|
16
|
-
expect(TTY::Color).to receive(:support?).and_return("support")
|
|
17
|
-
expect(Logger).to receive(:new).with("ci.log").and_return("logger")
|
|
18
|
-
expect(TTY::Command).to receive(:new)
|
|
19
|
-
.with(color: "support", output: "logger")
|
|
20
|
-
.and_return("tty-command")
|
|
21
|
-
|
|
22
|
-
expect(LocalCI::Helper.runner).to eq("tty-command")
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
describe ".taskize" do
|
|
27
|
-
it "returns a task-ized version of a string" do
|
|
28
|
-
expect(LocalCI::Helper.taskize("Hello There!")).to eq(:hello_there)
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|