ski 0.0.1 → 0.0.4
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/README.md +9 -1
- data/lib/missing_file_error.rb +4 -0
- data/lib/project.rb +32 -42
- data/lib/ski.rb +1 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '09204c617277258d060a920173e34b9e33085bd2'
|
4
|
+
data.tar.gz: e8a61b3bbdc196c94b67674021bba88f4b398cef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27b92b5f0c6f69bb2f334106fa6b9ca4625ce30a41f07383ecd80a301848b31c6b69939247f94405afd6864137f364447e04be2f354f5675b5e5af4f039dccb7
|
7
|
+
data.tar.gz: 0a73d1e7965fc444941e0839068621f145ef580d829e849b0ec84f006d41dc5dc3dab8ab36bec74ccb8bc591420c4666522ee156f87e64b2fafc22bfdc3510e4
|
data/README.md
CHANGED
@@ -75,4 +75,12 @@ targets:
|
|
75
75
|
```
|
76
76
|
|
77
77
|
3. Run:
|
78
|
-
`ski -P your-project -p build`
|
78
|
+
`ski -P your-project -p build`
|
79
|
+
|
80
|
+
# Todo
|
81
|
+
|
82
|
+
* Add functionality for remote tasks
|
83
|
+
* Add functionality for prompts (like configurable 'are you sure' etc)
|
84
|
+
* Add functionality for variables (:prompts, :my_var etc)
|
85
|
+
* Make use of pipeline targets in code
|
86
|
+
* Add functionality for secrets and ssh keys (stored somewhere on a safe place not in your project dir)
|
data/lib/project.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'open3'
|
1
2
|
require_relative 'missing_attribute_error'
|
2
3
|
|
3
4
|
module Ski
|
@@ -12,68 +13,57 @@ module Ski
|
|
12
13
|
@description = config.dig('description')
|
13
14
|
@pipelines = config.dig('pipelines')
|
14
15
|
@credentials = config.dig('pipelines')
|
15
|
-
@
|
16
|
-
|
16
|
+
@fail = false
|
17
|
+
puts "PROJECT: #{@title}"
|
18
|
+
puts "DESCRIPTION: #{@description}"
|
19
|
+
puts "PIPELINES:"
|
20
|
+
@pipelines.each do |pipeline|
|
21
|
+
puts " ID: #{pipeline.dig('pipeline', 'id')}"
|
22
|
+
puts " DESCRIPTION: #{pipeline.dig('pipeline', 'description')}"
|
23
|
+
puts " TASKS: #{pipeline.dig('pipeline', 'tasks').count}"
|
24
|
+
end
|
17
25
|
end
|
18
26
|
|
19
27
|
def kick_off(pipeline_id)
|
20
28
|
@pipeline = @pipelines.find { |pipeline| pipeline.dig('pipeline', 'id') == pipeline_id }
|
21
|
-
|
22
|
-
if @
|
23
|
-
|
29
|
+
run(tasks, 'TASK:')
|
30
|
+
if @fail
|
31
|
+
run(error_tasks, 'ERROR:')
|
24
32
|
else
|
25
|
-
|
33
|
+
run(success_tasks, 'SUCCESS:')
|
26
34
|
end
|
27
35
|
end
|
28
36
|
|
29
37
|
private
|
30
38
|
|
31
|
-
def
|
32
|
-
@pipeline.dig('pipeline','on-error', 'tasks')
|
33
|
-
puts "************ ON-ERROR: Running error task: #{index+1}/#{number_of_error_tasks} #{task.dig('task', 'name')} ************"
|
34
|
-
begin
|
35
|
-
output = system task.dig('task', 'command')
|
36
|
-
rescue SystemCallError
|
37
|
-
puts output
|
38
|
-
exit 255
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def run_on_success
|
44
|
-
@pipeline.dig('pipeline','on-success', 'tasks').each_with_index do |task, index|
|
45
|
-
puts "************ ON-SUCCESS: Running success task: #{index+1}/#{number_of_success_tasks} #{task.dig('task', 'name')} ************"
|
46
|
-
begin
|
47
|
-
output = system task.dig('task', 'command')
|
48
|
-
rescue SystemCallError
|
49
|
-
puts output
|
50
|
-
exit 255
|
51
|
-
end
|
52
|
-
end
|
39
|
+
def error_tasks
|
40
|
+
@pipeline.dig('pipeline','on-error', 'tasks') || []
|
53
41
|
end
|
54
42
|
|
55
|
-
def
|
56
|
-
@pipeline.dig('pipeline','tasks')
|
43
|
+
def success_tasks
|
44
|
+
@pipeline.dig('pipeline','on-success', 'tasks') || []
|
57
45
|
end
|
58
46
|
|
59
|
-
def
|
60
|
-
@pipeline.dig('pipeline',
|
47
|
+
def tasks
|
48
|
+
@pipeline.dig('pipeline', 'tasks') || []
|
61
49
|
end
|
62
50
|
|
63
|
-
def
|
64
|
-
@pipeline.dig('pipeline','
|
51
|
+
def ff
|
52
|
+
@pipeline.dig('pipeline', 'fail-fast') || true
|
65
53
|
end
|
66
54
|
|
67
|
-
def
|
68
|
-
|
69
|
-
puts "************
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
55
|
+
def run(tasks, prefix)
|
56
|
+
tasks.each_with_index do |task, index|
|
57
|
+
puts "************ #{prefix} Running: #{index+1}/#{tasks.count} #{task.dig('task', 'name')} ************"
|
58
|
+
stdout, stderr, status = Open3.capture3(task.dig('task', 'command').to_s)
|
59
|
+
if status.exitstatus != 0
|
60
|
+
@fail = true
|
61
|
+
puts "ERROR: #{stderr}"
|
62
|
+
break if ff
|
75
63
|
end
|
64
|
+
puts stdout
|
76
65
|
end
|
77
66
|
end
|
67
|
+
|
78
68
|
end
|
79
69
|
end
|
data/lib/ski.rb
CHANGED
@@ -7,6 +7,7 @@ module Ski
|
|
7
7
|
class Ski
|
8
8
|
def initialize(project, pipeline)
|
9
9
|
raise NoSkiProjectError unless Dir.exists?('.ski')
|
10
|
+
raise MissingFileError unless File.exists?(".ski/#{project}.yml")
|
10
11
|
@project = Project.new(YAML.load_file(".ski/#{project}.yml"))
|
11
12
|
@project.kick_off(pipeline)
|
12
13
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ski
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Niklas Hanft
|
@@ -10,7 +10,7 @@ bindir: bin
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2018-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
13
|
+
description: README.md
|
14
14
|
email: niklas.hanft@outlook.com
|
15
15
|
executables:
|
16
16
|
- ski
|
@@ -22,6 +22,7 @@ files:
|
|
22
22
|
- README.md
|
23
23
|
- bin/ski
|
24
24
|
- lib/missing_attribute_error.rb
|
25
|
+
- lib/missing_file_error.rb
|
25
26
|
- lib/no_ski_project_error.rb
|
26
27
|
- lib/project.rb
|
27
28
|
- lib/ski.rb
|
@@ -49,5 +50,5 @@ rubyforge_project:
|
|
49
50
|
rubygems_version: 2.6.14
|
50
51
|
signing_key:
|
51
52
|
specification_version: 4
|
52
|
-
summary: Automation framework
|
53
|
+
summary: Automation framework made for portability
|
53
54
|
test_files: []
|