pipely 0.8.3 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pipely/build.rb +2 -16
- data/lib/pipely/build/daily_scheduler.rb +1 -1
- data/lib/pipely/build/definition.rb +30 -2
- data/lib/pipely/build/environment_config.rb +24 -1
- data/lib/pipely/build/s3_path_builder.rb +65 -33
- data/lib/pipely/deploy/bootstrap.rb +17 -14
- data/lib/pipely/deploy/bootstrap_context.rb +87 -10
- data/lib/pipely/deploy/bootstrap_registry.rb +45 -0
- data/lib/pipely/deploy/client.rb +33 -18
- data/lib/pipely/deploy/json_definition.rb +51 -0
- data/lib/pipely/pipeline_date_time/pipeline_date.rb +62 -0
- data/lib/pipely/pipeline_date_time/pipeline_date_pattern.rb +42 -0
- data/lib/pipely/pipeline_date_time/pipeline_date_range_base.rb +44 -0
- data/lib/pipely/pipeline_date_time/pipeline_day_range.rb +14 -0
- data/lib/pipely/pipeline_date_time/pipeline_month_range.rb +26 -0
- data/lib/pipely/pipeline_date_time/pipeline_year_range.rb +25 -0
- data/lib/pipely/tasks/definition.rb +7 -0
- data/lib/pipely/tasks/deploy.rb +7 -0
- data/lib/pipely/tasks/upload_pipeline_as_gem.rb +19 -9
- data/lib/pipely/version.rb +1 -1
- data/spec/fixtures/bootstrap_contexts/green.rb +9 -0
- data/spec/fixtures/bootstrap_contexts/simple.rb +9 -0
- data/spec/fixtures/templates/bootstrap.sh.erb +4 -0
- data/spec/lib/pipely/build/environment_config_spec.rb +58 -0
- data/spec/lib/pipely/build/s3_path_builder_spec.rb +34 -2
- data/spec/lib/pipely/build/template_spec.rb +10 -10
- data/spec/lib/pipely/build_spec.rb +29 -0
- data/spec/lib/pipely/deploy/bootstrap_context_spec.rb +102 -14
- data/spec/lib/pipely/deploy/bootstrap_registry_spec.rb +32 -0
- data/spec/lib/pipely/deploy/bootstrap_spec.rb +41 -24
- data/spec/lib/pipely/pipeline_date_time/pipeline_date_pattern_spec.rb +181 -0
- data/spec/lib/pipely/pipeline_date_time/pipeline_date_range_base_spec.rb +39 -0
- data/spec/lib/pipely/pipeline_date_time/pipeline_date_spec.rb +110 -0
- data/spec/lib/pipely/pipeline_date_time/pipeline_day_range_spec.rb +23 -0
- data/spec/lib/pipely/pipeline_date_time/pipeline_month_range_spec.rb +93 -0
- data/spec/lib/pipely/pipeline_date_time/pipeline_year_range_spec.rb +93 -0
- data/spec/lib/pipely/tasks/upload_pipeline_as_gem_spec.rb +59 -0
- metadata +49 -3
@@ -0,0 +1,181 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'pipely/pipeline_date_time/pipeline_date_pattern'
|
3
|
+
|
4
|
+
TestSelection = Struct.new(:num_days_back, :target_date, :target_all_time)
|
5
|
+
|
6
|
+
class TestDatePatternMatcher
|
7
|
+
attr_accessor :day_offsets, :month_offsets, :year_offsets
|
8
|
+
|
9
|
+
PipelineDate = Pipely::PipelineDateTime::PipelineDate
|
10
|
+
|
11
|
+
def initialize(date_pattern, target_date, sep)
|
12
|
+
@day_offsets, @month_offsets, @year_offsets = [], [], []
|
13
|
+
date_pattern.split(sep).each do |part|
|
14
|
+
days, format = days_and_format(part, target_date)
|
15
|
+
case format
|
16
|
+
when PipelineDate::DEFAULT_YEAR_FORMAT then @year_offsets << days
|
17
|
+
when PipelineDate::DEFAULT_MONTH_FORMAT then @month_offsets << days
|
18
|
+
when PipelineDate::DEFAULT_DAY_FORMAT then @day_offsets << days
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def days_and_format(part, target_date)
|
26
|
+
trimmed = part.gsub("\#{format(", '').gsub("\")}", '')
|
27
|
+
days_expr, format = trimmed.split(", \"")
|
28
|
+
if days_expr == target_date
|
29
|
+
days = 0
|
30
|
+
else
|
31
|
+
days = days_expr.gsub("minusDays(#{target_date}, ", '').gsub(')', '')
|
32
|
+
end
|
33
|
+
return days.to_i, format
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
class TestPipelineDatePattern
|
38
|
+
include Pipely::PipelineDateTime::PipelineDatePattern
|
39
|
+
|
40
|
+
attr_reader :selection
|
41
|
+
|
42
|
+
def initialize
|
43
|
+
@selection = TestSelection.new
|
44
|
+
@selection.target_all_time = false
|
45
|
+
end
|
46
|
+
|
47
|
+
def num_days_back=(num_days_back)
|
48
|
+
@selection.num_days_back = num_days_back
|
49
|
+
end
|
50
|
+
|
51
|
+
def target_date=(target_date)
|
52
|
+
@selection.target_date = target_date
|
53
|
+
end
|
54
|
+
|
55
|
+
def any_string(parts)
|
56
|
+
if parts.empty?
|
57
|
+
nil
|
58
|
+
elsif parts.count == 1
|
59
|
+
parts.first
|
60
|
+
else
|
61
|
+
"#{parts.join('|')}"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe TestPipelineDatePattern do
|
67
|
+
let(:target_date) { '@scheduledStartTime' }
|
68
|
+
let(:sep) { '|' }
|
69
|
+
subject { described_class.new }
|
70
|
+
|
71
|
+
before { subject.target_date = target_date }
|
72
|
+
|
73
|
+
context 'with 0 days back' do
|
74
|
+
before { subject.num_days_back = 0 }
|
75
|
+
|
76
|
+
describe '#date_pattern' do
|
77
|
+
let(:pattern_matcher) do
|
78
|
+
TestDatePatternMatcher.new(subject.date_pattern, target_date, sep)
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'contains just target_date' do
|
82
|
+
expect(pattern_matcher.day_offsets).to eq([0])
|
83
|
+
expect(pattern_matcher.month_offsets).to eq([])
|
84
|
+
expect(pattern_matcher.year_offsets).to eq([])
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
context 'with 59 days back' do
|
90
|
+
before { subject.num_days_back = 59 }
|
91
|
+
|
92
|
+
describe '#date_pattern' do
|
93
|
+
let(:pattern_matcher) do
|
94
|
+
TestDatePatternMatcher.new(subject.date_pattern, target_date, sep)
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'contains 60 individual days' do
|
98
|
+
expect(pattern_matcher.day_offsets.sort).to eq((0..59).to_a)
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'contains no months' do
|
102
|
+
expect(pattern_matcher.month_offsets).to eq([])
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'contains no years' do
|
106
|
+
expect(pattern_matcher.year_offsets).to eq([])
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
context 'with 60 days back' do
|
112
|
+
before { subject.num_days_back = 60 }
|
113
|
+
|
114
|
+
describe '#date_pattern' do
|
115
|
+
let(:pattern_matcher) do
|
116
|
+
TestDatePatternMatcher.new(subject.date_pattern, target_date, sep)
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'contains 60 individual days' do
|
120
|
+
expected_days = (0..29).to_a + (31..60).to_a
|
121
|
+
expect(pattern_matcher.day_offsets.sort).to eq(expected_days)
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'contains 1 month' do
|
125
|
+
expect(pattern_matcher.month_offsets).to eq([30])
|
126
|
+
end
|
127
|
+
|
128
|
+
it 'contains no years' do
|
129
|
+
expect(pattern_matcher.year_offsets).to eq([])
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
context 'with 729 days back' do
|
135
|
+
before { subject.num_days_back = 729 }
|
136
|
+
|
137
|
+
describe '#date_pattern' do
|
138
|
+
let(:pattern_matcher) do
|
139
|
+
TestDatePatternMatcher.new(subject.date_pattern, target_date, sep)
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'contains 60 individual days' do
|
143
|
+
expected_days = (0..29).to_a + (700..729).to_a
|
144
|
+
expect(pattern_matcher.day_offsets.sort).to eq(expected_days)
|
145
|
+
end
|
146
|
+
|
147
|
+
it 'contains 24 individual months' do
|
148
|
+
expected_months = ((30..674).step(28)).to_a
|
149
|
+
expect(pattern_matcher.month_offsets.sort).to eq(expected_months)
|
150
|
+
end
|
151
|
+
|
152
|
+
it 'contains no years' do
|
153
|
+
expect(pattern_matcher.year_offsets).to eq([])
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
context 'with 730 days back' do
|
159
|
+
before { subject.num_days_back = 730 }
|
160
|
+
|
161
|
+
describe '#date_pattern' do
|
162
|
+
let(:pattern_matcher) do
|
163
|
+
TestDatePatternMatcher.new(subject.date_pattern, target_date, sep)
|
164
|
+
end
|
165
|
+
|
166
|
+
it 'contains 60 individual days' do
|
167
|
+
expected_days = (0..29).to_a + (701..730).to_a
|
168
|
+
expect(pattern_matcher.day_offsets.sort).to eq(expected_days)
|
169
|
+
end
|
170
|
+
|
171
|
+
it 'contains 24 individual months' do
|
172
|
+
expected_months = (30..394).step(28).to_a + (422..674).step(28).to_a
|
173
|
+
expect(pattern_matcher.month_offsets.sort).to eq(expected_months)
|
174
|
+
end
|
175
|
+
|
176
|
+
it 'contains 1 year' do
|
177
|
+
expect(pattern_matcher.year_offsets).to eq([365])
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'pipely/pipeline_date_time/pipeline_date_range_base'
|
3
|
+
|
4
|
+
describe Pipely::PipelineDateTime::PipelineDateRangeBase do
|
5
|
+
let(:target_date) { '@scheduledStartTime' }
|
6
|
+
let(:days_back_start) { 5 }
|
7
|
+
let(:days_back_end) { 0 }
|
8
|
+
subject { described_class.new(target_date, days_back_start, days_back_end) }
|
9
|
+
|
10
|
+
let(:expected_days_back) { (days_back_end..days_back_start).to_set }
|
11
|
+
|
12
|
+
describe '#days_back' do
|
13
|
+
it 'returns the expect value' do
|
14
|
+
expect(subject.days_back).to eq expected_days_back
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#exclude' do
|
19
|
+
it 'does not exclude when days_back_start is negative' do
|
20
|
+
subject.exclude(-1, 0)
|
21
|
+
expect(subject.days_back).to eq expected_days_back
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'does not exclude when days_back_end is negative' do
|
25
|
+
subject.exclude(0, -2)
|
26
|
+
expect(subject.days_back).to eq expected_days_back
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'does not exclude when days_back_start is smaller than days_back_end' do
|
30
|
+
subject.exclude(3, 5)
|
31
|
+
expect(subject.days_back).to eq expected_days_back
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'excludes expected offsets' do
|
35
|
+
subject.exclude(4, 2)
|
36
|
+
expect(subject.days_back).to eq Set.new([0,1,5])
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'pipely/pipeline_date_time/pipeline_date'
|
3
|
+
|
4
|
+
describe Pipely::PipelineDateTime::PipelineDate do
|
5
|
+
let(:target_date) { '@scheduledStartTime' }
|
6
|
+
|
7
|
+
context 'with default time formats' do
|
8
|
+
context 'with positive num days back' do
|
9
|
+
let(:num_days_back) { 5 }
|
10
|
+
subject { described_class.new(target_date, num_days_back) }
|
11
|
+
|
12
|
+
describe '#day' do
|
13
|
+
let(:result) do
|
14
|
+
"\#{format(minusDays(@scheduledStartTime, 5), \"YYYY/MM/dd\")}"
|
15
|
+
end
|
16
|
+
|
17
|
+
it { expect(subject.day).to eq(result) }
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#month' do
|
21
|
+
let(:result) do
|
22
|
+
"\#{format(minusDays(@scheduledStartTime, 5), \"YYYY/MM\")}"
|
23
|
+
end
|
24
|
+
|
25
|
+
it { expect(subject.month).to eq(result) }
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#year' do
|
29
|
+
let(:result) do
|
30
|
+
"\#{format(minusDays(@scheduledStartTime, 5), \"YYYY\")}"
|
31
|
+
end
|
32
|
+
|
33
|
+
it { expect(subject.year).to eq(result) }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'with 0 days back' do
|
38
|
+
let(:num_days_back) { 0 }
|
39
|
+
subject { described_class.new(target_date, num_days_back) }
|
40
|
+
|
41
|
+
describe '#day' do
|
42
|
+
let(:result) do
|
43
|
+
"\#{format(@scheduledStartTime, \"YYYY/MM/dd\")}"
|
44
|
+
end
|
45
|
+
|
46
|
+
it { expect(subject.day).to eq(result) }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'with negative num days back' do
|
51
|
+
let(:num_days_back) { -3 }
|
52
|
+
subject { described_class.new(target_date, num_days_back) }
|
53
|
+
|
54
|
+
describe '#day' do
|
55
|
+
let(:result) do
|
56
|
+
"\#{format(plusDays(@scheduledStartTime, 3), \"YYYY/MM/dd\")}"
|
57
|
+
end
|
58
|
+
|
59
|
+
it { expect(subject.day).to eq(result) }
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context 'with custom date time formats' do
|
65
|
+
let(:day_format) { 'DAY_FORMAT' }
|
66
|
+
let(:month_format) { 'MONTH_FORMAT' }
|
67
|
+
let(:year_format) { 'YEAR_FORMAT' }
|
68
|
+
|
69
|
+
before do
|
70
|
+
described_class.day_format = day_format
|
71
|
+
described_class.month_format = month_format
|
72
|
+
described_class.year_format = year_format
|
73
|
+
end
|
74
|
+
|
75
|
+
after do
|
76
|
+
described_class.day_format = described_class::DEFAULT_DAY_FORMAT
|
77
|
+
described_class.month_format = described_class::DEFAULT_MONTH_FORMAT
|
78
|
+
described_class.year_format = described_class::DEFAULT_YEAR_FORMAT
|
79
|
+
end
|
80
|
+
|
81
|
+
context 'with negative num days back' do
|
82
|
+
let(:num_days_back) { -3 }
|
83
|
+
subject { described_class.new(target_date, num_days_back) }
|
84
|
+
|
85
|
+
describe '#day' do
|
86
|
+
let(:result) do
|
87
|
+
"\#{format(plusDays(@scheduledStartTime, 3), \"#{day_format}\")}"
|
88
|
+
end
|
89
|
+
|
90
|
+
it { expect(subject.day).to eq(result) }
|
91
|
+
end
|
92
|
+
|
93
|
+
describe '#month' do
|
94
|
+
let(:result) do
|
95
|
+
"\#{format(plusDays(@scheduledStartTime, 3), \"#{month_format}\")}"
|
96
|
+
end
|
97
|
+
|
98
|
+
it { expect(subject.month).to eq(result) }
|
99
|
+
end
|
100
|
+
|
101
|
+
describe '#year' do
|
102
|
+
let(:result) do
|
103
|
+
"\#{format(plusDays(@scheduledStartTime, 3), \"#{year_format}\")}"
|
104
|
+
end
|
105
|
+
|
106
|
+
it { expect(subject.year).to eq(result) }
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'pipely/pipeline_date_time/pipeline_day_range'
|
3
|
+
|
4
|
+
describe Pipely::PipelineDateTime::PipelineDayRange do
|
5
|
+
let(:target_date) { '@scheduledStartTime' }
|
6
|
+
let(:days_back_start) { 2 }
|
7
|
+
let(:days_back_end) { 0 }
|
8
|
+
subject { described_class.new(target_date, days_back_start, days_back_end) }
|
9
|
+
|
10
|
+
describe '#days' do
|
11
|
+
let(:expected_days) do
|
12
|
+
[
|
13
|
+
"\#{format(@scheduledStartTime, \"YYYY/MM/dd\")}",
|
14
|
+
"\#{format(minusDays(@scheduledStartTime, 1), \"YYYY/MM/dd\")}",
|
15
|
+
"\#{format(minusDays(@scheduledStartTime, 2), \"YYYY/MM/dd\")}"
|
16
|
+
]
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'returns the expect value' do
|
20
|
+
expect(subject.days).to eq expected_days
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'pipely/pipeline_date_time/pipeline_month_range'
|
3
|
+
|
4
|
+
describe Pipely::PipelineDateTime::PipelineMonthRange do
|
5
|
+
let(:target_date) { '@scheduledStartTime' }
|
6
|
+
|
7
|
+
context 'with 59 days between start and end' do
|
8
|
+
let(:days_back_start) { 59 }
|
9
|
+
let(:days_back_end) { 0 }
|
10
|
+
subject { described_class.new(target_date, days_back_start, days_back_end) }
|
11
|
+
|
12
|
+
describe '#start' do
|
13
|
+
it { expect(subject.start).to eq 29 }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#end' do
|
17
|
+
it { expect(subject.end).to eq 30 }
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#months' do
|
21
|
+
it { expect(subject.months).to eq [] }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'with 60 days between start and end' do
|
26
|
+
let(:days_back_start) { 62 }
|
27
|
+
let(:days_back_end) { 2 }
|
28
|
+
subject { described_class.new(target_date, days_back_start, days_back_end) }
|
29
|
+
|
30
|
+
describe '#start' do
|
31
|
+
it { expect(subject.start).to eq 32 }
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#end' do
|
35
|
+
it { expect(subject.end).to eq 32 }
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#months' do
|
39
|
+
let(:expected_months) do
|
40
|
+
["\#{format(minusDays(@scheduledStartTime, 32), \"YYYY/MM\")}"]
|
41
|
+
end
|
42
|
+
|
43
|
+
it { expect(subject.months).to eq expected_months }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'with 87 days between start and end' do
|
48
|
+
let(:days_back_start) { 90 }
|
49
|
+
let(:days_back_end) { 3 }
|
50
|
+
subject { described_class.new(target_date, days_back_start, days_back_end) }
|
51
|
+
|
52
|
+
describe '#start' do
|
53
|
+
it { expect(subject.start).to eq 60 }
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '#end' do
|
57
|
+
it { expect(subject.end).to eq 33 }
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '#months' do
|
61
|
+
let(:expected_months) do
|
62
|
+
["\#{format(minusDays(@scheduledStartTime, 33), \"YYYY/MM\")}"]
|
63
|
+
end
|
64
|
+
|
65
|
+
it { expect(subject.months).to eq expected_months }
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context 'with 88 days between start and end' do
|
70
|
+
let(:days_back_start) { 92 }
|
71
|
+
let(:days_back_end) { 4 }
|
72
|
+
subject { described_class.new(target_date, days_back_start, days_back_end) }
|
73
|
+
|
74
|
+
describe '#start' do
|
75
|
+
it { expect(subject.start).to eq 62 }
|
76
|
+
end
|
77
|
+
|
78
|
+
describe '#end' do
|
79
|
+
it { expect(subject.end).to eq 34 }
|
80
|
+
end
|
81
|
+
|
82
|
+
describe '#months' do
|
83
|
+
let(:expected_months) do
|
84
|
+
[
|
85
|
+
"\#{format(minusDays(@scheduledStartTime, 34), \"YYYY/MM\")}",
|
86
|
+
"\#{format(minusDays(@scheduledStartTime, 62), \"YYYY/MM\")}"
|
87
|
+
]
|
88
|
+
end
|
89
|
+
|
90
|
+
it { expect(subject.months).to eq expected_months }
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|