concourse 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0236660cb2584a322eb4db46b4461b93adf0c695
4
+ data.tar.gz: c1c63234d0b22c971824f9b7fe1fc30b14f9f803
5
+ SHA512:
6
+ metadata.gz: 3f1794f53cb5411453369bf8f5895da7557c5ee60d3a9ef38c19ab38b314e99fe68aeb7cbd91410b34e7d825f25989f57ad6eb16e7ad5bcb0315b0713d9b8ae1
7
+ data.tar.gz: a102f6a46079b353c1ef95c3ec854688b1313c89019f33174b51326d6212b43549a9c88c03524a8c895b195cf28e2a7e142d4778e4b7fe91ce684467174804cb
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at mike.dalessio@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in concourse-gem.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Mike Dalessio
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,119 @@
1
+ # Concourse
2
+
3
+ The `Concourse` gem creates rake tasks to help you manage your Concourse pipelines, and to assist in running individual tasks on your local development machine.
4
+
5
+ If you're not familiar with Concourse CI, you can read up on it at https://concourse.ci
6
+
7
+
8
+ ## Usage
9
+
10
+ In your Rakefile,
11
+
12
+ ``` ruby
13
+ require 'concourse'
14
+
15
+ Concourse.new("myproject").create_tasks!
16
+ ```
17
+
18
+ This will create a set of rake tasks for you.
19
+
20
+
21
+ ### Managing your Concourse pipeline
22
+
23
+ Tasks to manage a local pipeline file, generated from an ERB template:
24
+
25
+ ```
26
+ rake concourse:clean # remove generate pipeline file
27
+ rake concourse:generate # generate and validate the pipeline file for myproject
28
+ ```
29
+
30
+ A task to upload your pipeline file to the cloud:
31
+
32
+ ```
33
+ rake concourse:set[fly_target] # upload the pipeline file for myproject
34
+ ```
35
+
36
+ Tasks to publicly expose or hide your pipeline:
37
+
38
+ ```
39
+ rake concourse:expose[fly_target] # expose the myproject pipeline
40
+ rake concourse:hide[fly_target] # hide the myproject pipeline
41
+ ```
42
+
43
+ Tasks to pause and unpause your pipeline:
44
+
45
+ ```
46
+ rake concourse:pause[fly_target] # pause the myproject pipeline
47
+ rake concourse:unpause[fly_target] # unpause the myproject pipeline
48
+ ```
49
+
50
+ ### Running tasks with `fly execute`
51
+
52
+ ```
53
+ rake concourse:tasks # list all the available tasks from the nokogiri pipeline
54
+ rake concourse:task[fly_target,task_name,fly_execute_args] # fly execute the specified task
55
+ ```
56
+
57
+ where `fly_execute_args` will default to `--input=git-master=.`
58
+
59
+
60
+
61
+ ### `fly_target`
62
+
63
+ The `fly_target` argument should be a fly target `name`, and the rake tasks assume that you're logged in already to that target.
64
+
65
+
66
+ ### Templating and `RUBIES`
67
+
68
+ The ruby variable `RUBIES` is defined during the context of pipeline generation. The structure is something like:
69
+
70
+ ``` ruby
71
+ # these numbers/names align with public docker image names
72
+ RUBIES = {
73
+ mri: %w[2.1 2.2 2.3 2.4], # docker repository: "ruby"
74
+ jruby: %w[1.7 9.1], # docker repository: "jruby"
75
+ rbx: %w[latest], # docker repository: "rubinius/docker"
76
+ }
77
+ ```
78
+
79
+ and allows you to write your pipeline like this to get coverage on all the supported rubies:
80
+
81
+ ``` yaml
82
+ # myproject.yaml.erb
83
+ jobs:
84
+ <% for ruby_version in RUBIES[:mri] %>
85
+ - name: "ruby-<%= ruby_version %>"
86
+ plan:
87
+ - get: git-master
88
+ trigger: true
89
+ - task: rake-test
90
+ ...
91
+ <% end %>
92
+ ```
93
+
94
+
95
+ ## Installation
96
+
97
+ Add this line to your application's Gemfile:
98
+
99
+ ```ruby
100
+ gem 'concourse'
101
+ ```
102
+
103
+ And then execute:
104
+
105
+ $ bundle
106
+
107
+ Or install it yourself as:
108
+
109
+ $ gem install concourse
110
+
111
+
112
+ ## Contributing
113
+
114
+ Bug reports and pull requests are welcome on GitHub at https://github.com/flavorjones/concourse-gem. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
115
+
116
+
117
+ ## License
118
+
119
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/concourse.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'concourse/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "concourse"
8
+ spec.version = Concourse::VERSION
9
+ spec.authors = ["Mike Dalessio"]
10
+ spec.email = ["mike.dalessio@gmail.com"]
11
+
12
+ spec.summary = "Rake tasks for Concourse pipelines."
13
+ spec.description = "Provide Rake tasks to ease management of Concourse pipelines. See https://concourse.ci/ to learn about Concourse."
14
+ spec.homepage = "https://github.com/flavorjones/concourse-gem"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.14"
25
+ spec.add_development_dependency "rake", "~> 12.0"
26
+ spec.add_development_dependency "rspec", "~> 3.0"
27
+ end
data/lib/concourse.rb ADDED
@@ -0,0 +1,130 @@
1
+ require "concourse/version"
2
+
3
+ class Concourse
4
+ include Rake::DSL
5
+
6
+ # these numbers/names align with public docker image names
7
+ RUBIES = {
8
+ mri: %w[2.1 2.2 2.3 2.4], # docker repository: "ruby"
9
+ jruby: %w[1.7 9.1], # docker repository: "jruby"
10
+ rbx: %w[latest], # docker repository: "rubinius/docker"
11
+ }
12
+
13
+ DIRECTORY = "concourse"
14
+
15
+ attr_reader :project_name, :pipeline_filename, :pipeline_erb_filename
16
+
17
+ def self.validate_fly_target task, task_args
18
+ unless task_args[:fly_target]
19
+ raise "ERROR: must specify a fly target, like `rake #{task.name}[targetname]`"
20
+ end
21
+ return task_args[:fly_target]
22
+ end
23
+
24
+ def initialize project_name
25
+ @project_name = project_name
26
+ @pipeline_filename = File.join(DIRECTORY, "#{project_name}.yml")
27
+ @pipeline_erb_filename = "#{pipeline_filename}.erb"
28
+ end
29
+
30
+ def create_tasks!
31
+ unless Dir.exist? DIRECTORY
32
+ mkdir_p DIRECTORY
33
+ end
34
+
35
+ unless File.exist? pipeline_erb_filename
36
+ raise "ERROR: concourse pipeline template #{pipeline_erb_filename.inspect} does not exist"
37
+ end
38
+
39
+ CLOBBER.include pipeline_filename
40
+
41
+ namespace :concourse do
42
+ #
43
+ # pipeline commands
44
+ #
45
+ file pipeline_filename do
46
+ File.open pipeline_filename, "w" do |f|
47
+ f.write ERB.new(File.read(pipeline_erb_filename)).result(binding)
48
+ end
49
+ end
50
+
51
+ desc "generate and validate the pipeline file for #{project_name}"
52
+ task "generate" => pipeline_filename do |t|
53
+ sh "fly validate-pipeline -c #{pipeline_filename}"
54
+ end
55
+
56
+ desc "upload the pipeline file for #{project_name}"
57
+ task "set", [:fly_target] => ["generate"] do |t, args|
58
+ fly_target = Concourse.validate_fly_target t, args
59
+ sh "fly -t #{fly_target} set-pipeline -p #{project_name} -c #{pipeline_filename}"
60
+ end
61
+
62
+ %w[expose hide pause unpause].each do |command|
63
+ desc "#{command} the #{project_name} pipeline"
64
+ task "#{command}", [:fly_target] do |t, args|
65
+ fly_target = Concourse.validate_fly_target t, args
66
+ sh "fly -t #{fly_target} #{command}-pipeline -p #{project_name}"
67
+ end
68
+ end
69
+
70
+ desc "remove generate pipeline file"
71
+ task "clean" do |t|
72
+ rm_f pipeline_filename
73
+ end
74
+
75
+ #
76
+ # task commands
77
+ #
78
+ desc "list all the available tasks from the #{project_name} pipeline"
79
+ task "tasks" => "generate" do
80
+ tasks = []
81
+
82
+ each_task do |job, task|
83
+ tasks << "#{job["name"]}/#{task["task"]}"
84
+ end
85
+
86
+ puts "Available Concourse tasks for #{project_name} are:"
87
+ tasks.each { |task| puts " * #{task}" }
88
+ end
89
+
90
+ desc "fly execute the specified task"
91
+ task "task", [:fly_target, :task_name, :fly_execute_args] => "generate" do |t, args|
92
+ task_name = args[:task_name]
93
+ fly_execute_args = args[:fly_execute_args] || "--input=git-master=."
94
+ fly_target = Concourse.validate_fly_target t, args
95
+
96
+ unless task_name
97
+ raise "ERROR: must specify a task name, like `rake #{t.name}[taskname]`"
98
+ end
99
+
100
+ concourse_task = find_task task_name
101
+ raise "ERROR: could not find task `#{task_name}`" unless concourse_task
102
+
103
+ puts concourse_task.to_yaml
104
+ Tempfile.create do |f|
105
+ f.write concourse_task["config"].to_yaml
106
+ f.close
107
+ sh "fly -t #{fly_target} execute #{fly_execute_args} -c #{f.path} -x"
108
+ end
109
+ end
110
+ end
111
+ end
112
+
113
+ def each_task
114
+ pipeline = YAML.load_file(pipeline_filename)
115
+
116
+ pipeline["jobs"].each do |job|
117
+ job["plan"].each do |task|
118
+ yield job, task if task["task"]
119
+ end
120
+ end
121
+ end
122
+
123
+ def find_task task_name
124
+ job_name, task_name = *task_name.split("/")
125
+ each_task do |job, task|
126
+ return task if task["task"] == task_name && job["name"] == job_name
127
+ end
128
+ nil
129
+ end
130
+ end
@@ -0,0 +1,6 @@
1
+ require "rake"
2
+ require "erb"
3
+
4
+ class Concourse
5
+ VERSION = "0.1.0"
6
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: concourse
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Mike Dalessio
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-01-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.14'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.14'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '12.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '12.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ description: Provide Rake tasks to ease management of Concourse pipelines. See https://concourse.ci/
56
+ to learn about Concourse.
57
+ email:
58
+ - mike.dalessio@gmail.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - ".rspec"
65
+ - CODE_OF_CONDUCT.md
66
+ - Gemfile
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - concourse.gemspec
71
+ - lib/concourse.rb
72
+ - lib/concourse/version.rb
73
+ homepage: https://github.com/flavorjones/concourse-gem
74
+ licenses:
75
+ - MIT
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.6.8
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: Rake tasks for Concourse pipelines.
97
+ test_files: []