argus-builder 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -1
- data/bin/argus-build +29 -0
- data/bin/argus-send +1 -1
- data/lib/argus/docker.rb +9 -3
- data/lib/argus/git.rb +10 -3
- data/lib/argus/runner.rb +1 -1
- data/lib/argus/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 145c2ab7806fa9d79f972c7c7204fab58c7f991f
|
4
|
+
data.tar.gz: afbc50652c564cfd36b3de596c01d901072290c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45bb8ebdb954fbff07336c80f870b0dd0a102a63256e11c541daf4f777ba9cad1801d54c4a34b1ccc4f4571defd2a76d965418bb2f95f46dbe421a354fb3ae4d
|
7
|
+
data.tar.gz: d9c5c2c0848dfd1be63a487deacd4db6993d7fe30d4c5ae0156498e9f26114cd596bf72d87c4d43f677655417ae0a91ac675666e9e91c149569826ca8a721268
|
data/README.md
CHANGED
@@ -27,7 +27,13 @@ You will need:
|
|
27
27
|
`GITHUB_TOKEN`
|
28
28
|
- a repository created on ECR to push the docker image once built
|
29
29
|
|
30
|
-
|
30
|
+
If you have local docker, you can run a single build with:
|
31
|
+
|
32
|
+
```
|
33
|
+
argus-build rlister/argus:master
|
34
|
+
```
|
35
|
+
|
36
|
+
To run the builder daemon, create an SQS queue called `argus`, then:
|
31
37
|
|
32
38
|
```
|
33
39
|
gem install argus-builder
|
data/bin/argus-build
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
## run a single argus build directly
|
3
|
+
|
4
|
+
require 'argus'
|
5
|
+
|
6
|
+
usage = 'argus-build org/repo:branch [sha]'
|
7
|
+
|
8
|
+
if ARGV.empty?
|
9
|
+
puts "Usage: #{usage}"
|
10
|
+
exit
|
11
|
+
end
|
12
|
+
|
13
|
+
## parse github repo
|
14
|
+
org, repo, branch = ARGV[0].split(/[\/:]+/, 3)
|
15
|
+
sha = ARGV[1] || nil
|
16
|
+
|
17
|
+
## incoming message from sqs
|
18
|
+
msg = {
|
19
|
+
org: org,
|
20
|
+
repo: repo,
|
21
|
+
branch: branch,
|
22
|
+
sha: sha
|
23
|
+
}
|
24
|
+
|
25
|
+
## prevent timeout on docker api operations (e.g. long bundle install during build)
|
26
|
+
Excon.defaults[:write_timeout] = ENV.fetch('DOCKER_WRITE_TIMEOUT', 1000)
|
27
|
+
Excon.defaults[:read_timeout] = ENV.fetch('DOCKER_READ_TIMEOUT', 1000)
|
28
|
+
|
29
|
+
Argus::Runner.new(msg)
|
data/bin/argus-send
CHANGED
data/lib/argus/docker.rb
CHANGED
@@ -34,9 +34,15 @@ module Argus
|
|
34
34
|
|
35
35
|
@build_time = Benchmark.realtime do
|
36
36
|
@image = Docker::Image.build_from_dir('.', dockerfile: 'Dockerfile') do |chunk|
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
chunk.split(/[\r\n]+/).each do |line| # latest docker jams multiple streams into chunk
|
38
|
+
begin
|
39
|
+
stream = JSON.parse(line)['stream']
|
40
|
+
unless (stream.nil? || stream.match(/^[\s\.]+$/)) # very verbose about build progress
|
41
|
+
puts stream.chomp
|
42
|
+
end
|
43
|
+
rescue => e # be robust to json parse errors
|
44
|
+
puts e.message
|
45
|
+
end
|
40
46
|
end
|
41
47
|
end
|
42
48
|
end
|
data/lib/argus/git.rb
CHANGED
@@ -2,11 +2,11 @@ module Argus
|
|
2
2
|
class Git
|
3
3
|
attr_reader :org, :repo, :branch, :sha
|
4
4
|
|
5
|
-
def initialize(org, repo, branch = 'master')
|
5
|
+
def initialize(org, repo, branch = 'master', sha = nil)
|
6
6
|
@org = org
|
7
7
|
@repo = repo
|
8
8
|
@branch = branch
|
9
|
-
@sha =
|
9
|
+
@sha = sha
|
10
10
|
end
|
11
11
|
|
12
12
|
def to_s
|
@@ -34,7 +34,8 @@ module Argus
|
|
34
34
|
else
|
35
35
|
clone
|
36
36
|
end
|
37
|
-
|
37
|
+
reset if sha # specific sha was requested
|
38
|
+
@sha = rev_parse # return sha
|
38
39
|
end
|
39
40
|
|
40
41
|
## checkout branch of an existing repo
|
@@ -51,6 +52,12 @@ module Argus
|
|
51
52
|
raise ArgusError, "git clone failed for #{self}" unless $? == 0
|
52
53
|
end
|
53
54
|
|
55
|
+
## get a specific commit
|
56
|
+
def reset
|
57
|
+
puts "specific sha requested, resetting to #{sha}"
|
58
|
+
%x[git fetch && git reset --hard #{sha}]
|
59
|
+
end
|
60
|
+
|
54
61
|
## get current sha
|
55
62
|
def rev_parse
|
56
63
|
%x[git rev-parse #{branch} ].chomp
|
data/lib/argus/runner.rb
CHANGED
@@ -52,7 +52,7 @@ module Argus
|
|
52
52
|
FileUtils.mkdir_p(dir)
|
53
53
|
|
54
54
|
## github repo to get
|
55
|
-
git = Git.new(msg[:org], msg[:repo], msg[:branch])
|
55
|
+
git = Git.new(msg[:org], msg[:repo], msg[:branch], msg.fetch(:sha, nil))
|
56
56
|
|
57
57
|
## authenticate to registry
|
58
58
|
registry = authenticate_ecr
|
data/lib/argus/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: argus-builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Lister
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -84,6 +84,7 @@ description:
|
|
84
84
|
email:
|
85
85
|
- rlister+gh@gmail.com
|
86
86
|
executables:
|
87
|
+
- argus-build
|
87
88
|
- argus-send
|
88
89
|
- argus-worker
|
89
90
|
- console
|
@@ -100,6 +101,7 @@ files:
|
|
100
101
|
- README.md
|
101
102
|
- Rakefile
|
102
103
|
- argus.gemspec
|
104
|
+
- bin/argus-build
|
103
105
|
- bin/argus-send
|
104
106
|
- bin/argus-worker
|
105
107
|
- bin/console
|