concourse 0.24.0 → 0.25.0
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/CHANGELOG.md +5 -0
- data/README.md +44 -1
- data/lib/concourse.rb +57 -8
- data/lib/concourse/util.rb +12 -0
- data/lib/concourse/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4b1fac24b6a006de483423b88d279800eace3d340f06ff3e44bd245c06b56ae
|
4
|
+
data.tar.gz: c31951fe43411e6b9249d78e084f5e06c65e1003a8529c4b695df265bf61f30d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffb2453c377421f1f7b35f2eafb17e8933471d716525c7bd8c7edf05d5839a280198b17d356d365e3fc96e7f6dcf4b5b02b5443a5a5e70894201ba76c52448fb
|
7
|
+
data.tar.gz: 9a136ccc848d40e06e58a8d98bf5a36dec2fdb814f2a423cbe9910b032763ca79b78d455cdb2ec261d9e81a078987e5a22831cd0ee95566e951ec2a9e90e6774
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# concourse (the rubygem)
|
2
2
|
|
3
|
-
The `concourse` gem provides rake tasks to help you manage Concourse pipelines, jobs, and workers,
|
3
|
+
The `concourse` gem provides rake tasks to help you manage Concourse pipelines, jobs, and workers, to assist in running tasks with `fly execute`, and even run a local ephemeral deployment of Concourse on your development machine.
|
4
4
|
|
5
5
|
If you're not familiar with Concourse CI, you can read up on it at https://concourse.ci
|
6
6
|
|
@@ -31,6 +31,10 @@ If you're not familiar with Concourse CI, you can read up on it at https://conco
|
|
31
31
|
* [Run a Concourse task with `fly execute`](#run-a-concourse-task-with-fly-execute)
|
32
32
|
* [Abort running builds](#abort-running-builds)
|
33
33
|
* [Prune stalled concourse workers](#prune-stalled-concourse-workers)
|
34
|
+
- [Running a local ephemeral Concourse](#running-a-local-ephemeral-concourse)
|
35
|
+
* [Spinning up a local deployment](#spinning-up-a-local-deployment)
|
36
|
+
* [Doing things with the local deployment](#doing-things-with-the-local-deployment)
|
37
|
+
* [Shutting down the local deployment](#shutting-down-the-local-deployment)
|
34
38
|
- [Contributing](#contributing)
|
35
39
|
- [License](#license)
|
36
40
|
|
@@ -319,6 +323,45 @@ rake concourse:prune-stalled-workers # prune any stalled workers
|
|
319
323
|
```
|
320
324
|
|
321
325
|
|
326
|
+
## Running a local ephemeral Concourse
|
327
|
+
|
328
|
+
You can run a local Concourse deployment on your development system, if you have `docker` and `docker-compose` installed.
|
329
|
+
|
330
|
+
|
331
|
+
### Spinning up a local deployment
|
332
|
+
|
333
|
+
To spin up the local cluster:
|
334
|
+
|
335
|
+
``` sh
|
336
|
+
rake concourse:local:up
|
337
|
+
```
|
338
|
+
|
339
|
+
You can view that Concourse deployment at `http://127.0.0.1:8080` using the credentials `test`/`test`.
|
340
|
+
|
341
|
+
|
342
|
+
### Doing things with the local deployment
|
343
|
+
|
344
|
+
To target that local cluster, simply prepend the `concourse:local` task on the command line. For example, to `fly execute` a task on the local cluster:
|
345
|
+
|
346
|
+
``` sh
|
347
|
+
rake concourse:local concourse:task[ruby-2.4/rake-task]
|
348
|
+
```
|
349
|
+
|
350
|
+
Or to push your pipelines to that local cluster:
|
351
|
+
|
352
|
+
``` sh
|
353
|
+
rake concourse:local concourse:set
|
354
|
+
```
|
355
|
+
|
356
|
+
### Shutting down the local deployment
|
357
|
+
|
358
|
+
Finally, to spin down the cluster (when you're done with it):
|
359
|
+
|
360
|
+
``` sh
|
361
|
+
rake concourse:local:down
|
362
|
+
```
|
363
|
+
|
364
|
+
|
322
365
|
## Contributing
|
323
366
|
|
324
367
|
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. See [`CODE_OF_CONDUCT.md`](CODE_OF_CONDUCT.md).
|
data/lib/concourse.rb
CHANGED
@@ -3,6 +3,7 @@ require "concourse/util"
|
|
3
3
|
require "concourse/pipeline"
|
4
4
|
require "yaml"
|
5
5
|
require "tempfile"
|
6
|
+
require "open-uri"
|
6
7
|
|
7
8
|
class Concourse
|
8
9
|
include Rake::DSL
|
@@ -17,6 +18,8 @@ class Concourse
|
|
17
18
|
}
|
18
19
|
|
19
20
|
DEFAULT_DIRECTORY = "concourse"
|
21
|
+
DEFAULT_FLY_TARGET = "default"
|
22
|
+
DEFAULT_SECRETS = "private.yml"
|
20
23
|
|
21
24
|
attr_reader :project_name
|
22
25
|
attr_reader :directory
|
@@ -24,6 +27,8 @@ class Concourse
|
|
24
27
|
attr_reader :fly_target
|
25
28
|
attr_reader :secrets_filename
|
26
29
|
|
30
|
+
CONCOURSE_DOCKER_COMPOSE = "docker-compose.yml"
|
31
|
+
|
27
32
|
def self.url_for fly_target
|
28
33
|
matching_line = `fly targets`.split("\n").grep(/^#{fly_target}/).first
|
29
34
|
raise "invalid fly target #{fly_target}" unless matching_line
|
@@ -50,9 +55,9 @@ class Concourse
|
|
50
55
|
@project_name = project_name
|
51
56
|
|
52
57
|
@directory = options[:directory] || DEFAULT_DIRECTORY
|
53
|
-
@fly_target = options[:fly_target] ||
|
58
|
+
@fly_target = options[:fly_target] || DEFAULT_FLY_TARGET
|
54
59
|
|
55
|
-
base_secrets_filename = options[:secrets_filename] ||
|
60
|
+
base_secrets_filename = options[:secrets_filename] || DEFAULT_SECRETS
|
56
61
|
@secrets_filename = File.join(@directory, base_secrets_filename)
|
57
62
|
|
58
63
|
@pipelines = []
|
@@ -85,7 +90,32 @@ class Concourse
|
|
85
90
|
File.open pipeline.filename, "w" do |f|
|
86
91
|
f.write erbify_file(pipeline.erb_filename, working_directory: directory)
|
87
92
|
end
|
88
|
-
|
93
|
+
fly "validate-pipeline -c #{pipeline.filename}"
|
94
|
+
end
|
95
|
+
|
96
|
+
def rake_concourse_local
|
97
|
+
ensure_docker_compose_file
|
98
|
+
@fly_target = "local"
|
99
|
+
fly "login -u test -p test -c http://127.0.0.1:8080"
|
100
|
+
end
|
101
|
+
|
102
|
+
def ensure_docker_compose_file
|
103
|
+
return if File.exist?(docker_compose_path)
|
104
|
+
note "fetching docker compose file ..."
|
105
|
+
File.open(docker_compose_path, "w") do |f|
|
106
|
+
f.write open("https://concourse-ci.org/docker-compose.yml").read
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def rake_concourse_local_up
|
111
|
+
ensure_docker_compose_file
|
112
|
+
docker_compose "up -d"
|
113
|
+
docker_compose "ps"
|
114
|
+
end
|
115
|
+
|
116
|
+
def rake_concourse_local_down
|
117
|
+
ensure_docker_compose_file
|
118
|
+
docker_compose "down"
|
89
119
|
end
|
90
120
|
|
91
121
|
def create_tasks!
|
@@ -137,7 +167,7 @@ class Concourse
|
|
137
167
|
note "using #{secrets_filename} to resolve template vars in #{pipeline.filename}"
|
138
168
|
options << "-l '#{secrets_filename}'"
|
139
169
|
end
|
140
|
-
|
170
|
+
fly "set-pipeline #{options.join(" ")}"
|
141
171
|
end
|
142
172
|
end
|
143
173
|
|
@@ -148,7 +178,7 @@ class Concourse
|
|
148
178
|
pipelines.each do |pipeline|
|
149
179
|
desc "#{command} the #{pipeline.name} pipeline"
|
150
180
|
task "#{command}:#{pipeline.name}" do
|
151
|
-
|
181
|
+
fly "#{command}-pipeline -p #{pipeline.name}"
|
152
182
|
end
|
153
183
|
end
|
154
184
|
end
|
@@ -194,7 +224,7 @@ class Concourse
|
|
194
224
|
f.write concourse_task["config"].to_yaml
|
195
225
|
f.close
|
196
226
|
Bundler.with_clean_env do
|
197
|
-
|
227
|
+
fly "execute #{fly_execute_args} -c #{f.path}"
|
198
228
|
end
|
199
229
|
end
|
200
230
|
end
|
@@ -208,7 +238,7 @@ class Concourse
|
|
208
238
|
pipeline_job, build_id, status = *line.split(/\s+/)[1,3]
|
209
239
|
next unless status == "started"
|
210
240
|
|
211
|
-
|
241
|
+
fly "abort-build -j #{pipeline_job} -b #{build_id}"
|
212
242
|
end
|
213
243
|
end
|
214
244
|
|
@@ -219,7 +249,26 @@ class Concourse
|
|
219
249
|
task "prune-stalled-workers" do
|
220
250
|
`fly -t #{fly_target} workers | fgrep stalled`.each_line do |line|
|
221
251
|
worker_id = line.split.first
|
222
|
-
|
252
|
+
fly "prune-worker -w #{worker_id}"
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
#
|
257
|
+
# docker commands
|
258
|
+
#
|
259
|
+
task "local" do
|
260
|
+
rake_concourse_local
|
261
|
+
end
|
262
|
+
|
263
|
+
namespace "local" do
|
264
|
+
desc "start up a docker-compose cluster for local CI"
|
265
|
+
task "up" do
|
266
|
+
rake_concourse_local_up
|
267
|
+
end
|
268
|
+
|
269
|
+
desc "shut down the docker-compose cluster"
|
270
|
+
task "down" do
|
271
|
+
rake_concourse_local_down
|
223
272
|
end
|
224
273
|
end
|
225
274
|
end
|
data/lib/concourse/util.rb
CHANGED
@@ -18,6 +18,18 @@ class Concourse
|
|
18
18
|
File.open(GITIGNORE_FILE, "a") { |f| f.puts file_glob }
|
19
19
|
end
|
20
20
|
|
21
|
+
def fly command
|
22
|
+
sh "fly -t #{fly_target} #{command}"
|
23
|
+
end
|
24
|
+
|
25
|
+
def docker_compose command
|
26
|
+
sh "docker-compose -f #{docker_compose_path} #{command}"
|
27
|
+
end
|
28
|
+
|
29
|
+
def docker_compose_path
|
30
|
+
File.join(directory, CONCOURSE_DOCKER_COMPOSE)
|
31
|
+
end
|
32
|
+
|
21
33
|
def sh command
|
22
34
|
running "(in #{Dir.pwd}) #{command}"
|
23
35
|
Rake.sh command, verbose: false
|
data/lib/concourse/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: concourse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.25.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Dalessio
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: term-ansicolor
|