pipedawg 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/.bundle/config +4 -0
- data/.gitignore +15 -0
- data/.gitlab-ci.yml +14 -0
- data/.rspec +3 -0
- data/.rubocop.yml +14 -0
- data/.travis.yml +6 -0
- data/Gemfile +14 -0
- data/LICENSE.txt +21 -0
- data/README.md +37 -0
- data/Rakefile +8 -0
- data/lib/pipedawg/job.rb +27 -0
- data/lib/pipedawg/pipeline.rb +51 -0
- data/lib/pipedawg/version.rb +5 -0
- data/lib/pipedawg.rb +10 -0
- data/pipedawg.gemspec +29 -0
- metadata +61 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6da632acfefa54ce858d4277758160be20246355596f84a5cf7f7a47c6bf7f93
|
4
|
+
data.tar.gz: 52c803810e345742b2ae1f0ff10e19e3afd5a8423164667346fcda75d78b54ee
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3aa2f038cabfca9659ac80cc1c04a186d3ffed3d5dac47e3ab64140f09d1c5dfecba9d41c59e90e7215dab99edad8aeff8a3f2162b11b88b42551fe88ace12e8
|
7
|
+
data.tar.gz: 758697c43505ff847d74e3c5db85417652636dda97082b444ef975752dd03cd0853d6cc78b9403c9ecf11894510daf5ded82edeab7bb7b1e99b9441ec28b207b
|
data/.bundle/config
ADDED
data/.gitignore
ADDED
data/.gitlab-ci.yml
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in pipedawg.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
gem 'irb', '~> 1.4'
|
9
|
+
gem 'rake', '~> 12.0'
|
10
|
+
gem 'rdoc', '~> 6.4'
|
11
|
+
gem 'rspec', '~> 3.0'
|
12
|
+
gem 'rubocop', '~> 1.24', require: false
|
13
|
+
gem 'rubocop-rake', '~> 0.6', require: false
|
14
|
+
gem 'rubocop-rspec', '~> 2.7', require: false
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 Richard Grainger
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# Pipedawg
|
2
|
+
|
3
|
+
Generate GitLab CI pipelines.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'pipedawg'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle install
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install pipedawg
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
|
24
|
+
## Development
|
25
|
+
|
26
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
27
|
+
|
28
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
29
|
+
|
30
|
+
## Contributing
|
31
|
+
|
32
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/liger1978/pipedawg.
|
33
|
+
|
34
|
+
|
35
|
+
## License
|
36
|
+
|
37
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/lib/pipedawg/job.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Pipedawg
|
4
|
+
# job class
|
5
|
+
class Job
|
6
|
+
attr_accessor :name, :opts
|
7
|
+
|
8
|
+
def initialize(name = 'build', opts = {}) # rubocop:disable Metrics/MethodLength
|
9
|
+
@name = name
|
10
|
+
@opts = {
|
11
|
+
artifacts: {},
|
12
|
+
cache: {},
|
13
|
+
image: { name: 'ruby:2.5' },
|
14
|
+
needs: [],
|
15
|
+
retry: nil,
|
16
|
+
rules: [],
|
17
|
+
script: [],
|
18
|
+
stage: 'build',
|
19
|
+
tags: []
|
20
|
+
}.merge(opts)
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_hash
|
24
|
+
{ "#{name}": opts.compact }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Pipedawg
|
4
|
+
# pipeline class
|
5
|
+
class Pipeline
|
6
|
+
attr_accessor :name, :opts
|
7
|
+
|
8
|
+
def initialize(name = 'pipeline', opts = {})
|
9
|
+
@name = name
|
10
|
+
@opts = {
|
11
|
+
jobs: [Pipedawg::Job.new],
|
12
|
+
stages: ['build'],
|
13
|
+
workflow: {}
|
14
|
+
}.merge(opts)
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_yaml
|
18
|
+
require 'json'
|
19
|
+
require 'yaml'
|
20
|
+
pipeline = opts.compact.reject { |k, _| %i[jobs].include? k }
|
21
|
+
opts[:jobs].each do |job|
|
22
|
+
pipeline.merge!(job.to_hash)
|
23
|
+
end
|
24
|
+
JSON.parse(pipeline.to_json).to_yaml
|
25
|
+
end
|
26
|
+
|
27
|
+
def to_yaml_file(file = '.gitlab-ci.yml')
|
28
|
+
File.write(file, to_yaml)
|
29
|
+
end
|
30
|
+
|
31
|
+
def update_stages
|
32
|
+
stages = []
|
33
|
+
opts[:jobs].each do |job|
|
34
|
+
stage = stage_from_needs(opts[:jobs], job.name)
|
35
|
+
stages << stage
|
36
|
+
job.opts[:stage] = stage.to_s
|
37
|
+
end
|
38
|
+
opts[:stages] = stages.uniq.sort.map(&:to_s)
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def stage_from_needs(jobs, job_name)
|
44
|
+
if jobs.select { |job| job.name == job_name }[0].opts.fetch(:needs, []) == []
|
45
|
+
1
|
46
|
+
else
|
47
|
+
jobs.select { |job| job.name == job_name }[0].opts[:needs].map { |need| stage_from_needs(jobs, need) }.max + 1
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/lib/pipedawg.rb
ADDED
data/pipedawg.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/pipedawg/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'pipedawg'
|
7
|
+
spec.version = Pipedawg::VERSION
|
8
|
+
spec.authors = ['harbottle']
|
9
|
+
spec.email = ['harbottle@room3d3.com']
|
10
|
+
|
11
|
+
spec.summary = 'Generate GitLab CI pipelines.'
|
12
|
+
spec.description = 'Generate GitLab CI pipelines.'
|
13
|
+
spec.homepage = 'https://github.com/liger1978/pipedawg'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
17
|
+
spec.metadata['source_code_uri'] = 'https://github.com/liger1978/pipedawg'
|
18
|
+
spec.metadata['changelog_uri'] = 'https://github.com/liger1978/pipedawg'
|
19
|
+
|
20
|
+
# Specify which files should be added to the gem when it is released.
|
21
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
22
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
23
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
24
|
+
end
|
25
|
+
spec.bindir = 'exe'
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
+
spec.require_paths = ['lib']
|
28
|
+
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pipedawg
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- harbottle
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-01-18 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Generate GitLab CI pipelines.
|
14
|
+
email:
|
15
|
+
- harbottle@room3d3.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- ".bundle/config"
|
21
|
+
- ".gitignore"
|
22
|
+
- ".gitlab-ci.yml"
|
23
|
+
- ".rspec"
|
24
|
+
- ".rubocop.yml"
|
25
|
+
- ".travis.yml"
|
26
|
+
- Gemfile
|
27
|
+
- LICENSE.txt
|
28
|
+
- README.md
|
29
|
+
- Rakefile
|
30
|
+
- lib/pipedawg.rb
|
31
|
+
- lib/pipedawg/job.rb
|
32
|
+
- lib/pipedawg/pipeline.rb
|
33
|
+
- lib/pipedawg/version.rb
|
34
|
+
- pipedawg.gemspec
|
35
|
+
homepage: https://github.com/liger1978/pipedawg
|
36
|
+
licenses:
|
37
|
+
- MIT
|
38
|
+
metadata:
|
39
|
+
homepage_uri: https://github.com/liger1978/pipedawg
|
40
|
+
source_code_uri: https://github.com/liger1978/pipedawg
|
41
|
+
changelog_uri: https://github.com/liger1978/pipedawg
|
42
|
+
post_install_message:
|
43
|
+
rdoc_options: []
|
44
|
+
require_paths:
|
45
|
+
- lib
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0'
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
requirements: []
|
57
|
+
rubygems_version: 3.0.3
|
58
|
+
signing_key:
|
59
|
+
specification_version: 4
|
60
|
+
summary: Generate GitLab CI pipelines.
|
61
|
+
test_files: []
|