drunker 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/.gitignore +12 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +281 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/drunker.gemspec +33 -0
- data/exe/drunker +6 -0
- data/lib/drunker.rb +20 -0
- data/lib/drunker/aggregator.rb +9 -0
- data/lib/drunker/aggregator/base.rb +13 -0
- data/lib/drunker/artifact.rb +73 -0
- data/lib/drunker/artifact/layer.rb +30 -0
- data/lib/drunker/cli.rb +74 -0
- data/lib/drunker/config.rb +160 -0
- data/lib/drunker/executor.rb +122 -0
- data/lib/drunker/executor/builder.rb +124 -0
- data/lib/drunker/executor/buildspec.yml.erb +11 -0
- data/lib/drunker/executor/iam.rb +92 -0
- data/lib/drunker/source.rb +72 -0
- data/lib/drunker/version.rb +3 -0
- metadata +182 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1e4f32c3b7e312a8fed15ab1d6181193fb13744b
|
4
|
+
data.tar.gz: b5535975e7b881f411db29139d5ba72afb39d1b3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0055dbb90fd76fe7c75b38aa11f77a1ff96d2db1ce17652f9376e7187ae469f04ab056f5a75aef296a33bf1993cbe3be1099a68f22101609976d7e1336149350
|
7
|
+
data.tar.gz: d5d3607e90d875220781900b1bac374cbbbf789034b570715d35a5de699820d1747f0177ffacc83717a65502390a29f4d6c90257da6e35649737a48ac3c50135
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -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 watassbass@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
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 wata_mac
|
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,281 @@
|
|
1
|
+
# Drunker
|
2
|
+
|
3
|
+
Distributed CLI runner on [AWS CodeBuild](https://aws.amazon.com/codebuild/). This is a wrapper for handling CodeBuild container more easily.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
$ gem install drunker
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
All you need to use Drunker is the Docker image name of the container you want to use and the command you want to execute (Of course, AWS credentials is also necessary). For example, you can run [RSpec](https://github.com/rspec/rspec) on CodeBuild with the following command.
|
12
|
+
|
13
|
+
```
|
14
|
+
$ bundle install --path=vendor/bundle
|
15
|
+
$ drunker run --env=BUNDLE_PATH:vendor/bundle/ruby/2.4.0 --timeout=5 ruby:2.4.1 bundle exec rspec
|
16
|
+
```
|
17
|
+
|
18
|
+
First, specify the Docker image name, and then the command you want to execute. After that, Drunker archives files under the current directory and uploads it to S3 and creates a CodeBuild project and the required IAM role.
|
19
|
+
|
20
|
+
When preparation is completed, run builds, download artifacts from S3, and display it on your terminal. Resources created by Drunker are automatically deleted. Also, in this example, timeout and environment variables used inside containers are specified by options.
|
21
|
+
|
22
|
+
You can see execution result (e.g. STDOUT, STDERR and exit status) from output like the following.
|
23
|
+
|
24
|
+
```
|
25
|
+
-------------------------------------------------------------------------------------------
|
26
|
+
BUILD_ID: drunker-executor-1494139943:10c9c785-bae0-4a2d-b5eb-927528943626
|
27
|
+
RESULT: SUCCESS
|
28
|
+
STDOUT: .....................................................................................................................................
|
29
|
+
|
30
|
+
Finished in 5.9 seconds (files took 0.17053 seconds to load)
|
31
|
+
133 examples, 0 failures
|
32
|
+
|
33
|
+
STDERR:
|
34
|
+
EXIT_STATUS: 0
|
35
|
+
-------------------------------------------------------------------------------------------
|
36
|
+
```
|
37
|
+
|
38
|
+
### Parallel Build
|
39
|
+
|
40
|
+
The essence of Drunker is parallel build. For example, if you want to run RSpec in parallel, you can do it easily with the following command.
|
41
|
+
|
42
|
+
```
|
43
|
+
$ drunker run --concurrency=3 --file-pattern="spec/**/*_spec.rb" --env=BUNDLE_PATH:vendor/bundle/ruby/2.4.0 --timeout=5 ruby:2.4.1 bundle exec rspec FILES
|
44
|
+
```
|
45
|
+
|
46
|
+
`FILES` included in the execution command has a special meaning. This is interpolated into the list of filenames according to the number of parallels. For example, in this case, it will be the following command (filename changes for each build):
|
47
|
+
|
48
|
+
```
|
49
|
+
$ bundle exec rspec spec/aggregator_spec.rb spec/artifact_spec.rb ...
|
50
|
+
```
|
51
|
+
|
52
|
+
The target file is all files matching the glob pattern `**/*`. However, you can change this with `--file-pattern` option. You can see the execution result as the following:
|
53
|
+
|
54
|
+
```
|
55
|
+
-------------------------------------------------------------------------------------------
|
56
|
+
BUILD_ID: drunker-executor-1494140968:59c0b89f-099e-482c-8995-659f8b6b8523
|
57
|
+
RESULT: SUCCESS
|
58
|
+
STDOUT: ................
|
59
|
+
|
60
|
+
Finished in 0.12019 seconds (files took 0.14562 seconds to load)
|
61
|
+
16 examples, 0 failures
|
62
|
+
|
63
|
+
STDERR:
|
64
|
+
EXIT_STATUS: 0
|
65
|
+
-------------------------------------------------------------------------------------------
|
66
|
+
|
67
|
+
|
68
|
+
-------------------------------------------------------------------------------------------
|
69
|
+
BUILD_ID: drunker-executor-1494140968:f6cb0396-3005-44ca-8221-33b29cbbd309
|
70
|
+
RESULT: SUCCESS
|
71
|
+
STDOUT: ..........................................................................
|
72
|
+
|
73
|
+
Finished in 0.15774 seconds (files took 0.19026 seconds to load)
|
74
|
+
74 examples, 0 failures
|
75
|
+
|
76
|
+
STDERR:
|
77
|
+
EXIT_STATUS: 0
|
78
|
+
-------------------------------------------------------------------------------------------
|
79
|
+
|
80
|
+
|
81
|
+
-------------------------------------------------------------------------------------------
|
82
|
+
BUILD_ID: drunker-executor-1494140968:620c471e-19e7-48da-95e7-42cd66728455
|
83
|
+
RESULT: SUCCESS
|
84
|
+
STDOUT: ...........................................
|
85
|
+
|
86
|
+
Finished in 5.56 seconds (files took 0.14991 seconds to load)
|
87
|
+
43 examples, 0 failures
|
88
|
+
|
89
|
+
STDERR:
|
90
|
+
EXIT_STATUS: 0
|
91
|
+
-------------------------------------------------------------------------------------------
|
92
|
+
```
|
93
|
+
|
94
|
+
What is surprising is that do not require your local machine specs at all even if you increase the number of parallels. You can increase the number of parallels within the bounds of common sense.
|
95
|
+
|
96
|
+
### EC2 Container Registry
|
97
|
+
|
98
|
+
Do you want to use private images? You can also specify the image of [EC2 Container Registry](https://aws.amazon.com/ecr/). Following example:
|
99
|
+
|
100
|
+
```
|
101
|
+
$ drunker run account-ID.dkr.ecr.us-east-1.amazonaws.com/your-Amazon-ECR-repo-name:latest ruby task.rb
|
102
|
+
```
|
103
|
+
|
104
|
+
For details, please see [Amazon ECR Sample for AWS CodeBuild](http://docs.aws.amazon.com/codebuild/latest/userguide/sample-ecr.html).
|
105
|
+
|
106
|
+
## Available Options
|
107
|
+
|
108
|
+
Please show `drunker help run`
|
109
|
+
|
110
|
+
```
|
111
|
+
Usage:
|
112
|
+
drunker run [IMAGE] [COMMAND]
|
113
|
+
|
114
|
+
Options:
|
115
|
+
[--config=CONFIG] # Location of config file
|
116
|
+
# Default: .drunker.yml
|
117
|
+
[--concurrency=N] # Build concurrency
|
118
|
+
# Default: 1
|
119
|
+
[--compute-type=COMPUTE_TYPE] # Container compute type
|
120
|
+
# Default: small
|
121
|
+
# Possible values: small, medium, large
|
122
|
+
[--timeout=N] # Build timeout in minutes, should be between 5 and 480
|
123
|
+
# Default: 60
|
124
|
+
[--env=key:value] # Environment variables in containers
|
125
|
+
[--buildspec=BUILDSPEC] # Location of custom buildspec
|
126
|
+
[--file-pattern=FILE_PATTERN] # FILES target file pattern, can use glob to specify, but files beginning with a dot are ignored.
|
127
|
+
# Default: **/*
|
128
|
+
[--aggregator=AGGREGATOR] # Aggregator name. If you want to use custom aggregator, please install that beforehand.
|
129
|
+
# Default: pretty
|
130
|
+
[--loglevel=LOGLEVEL] # Output log level
|
131
|
+
# Default: info
|
132
|
+
# Possible values: debug, info, warn, error, fatal
|
133
|
+
[--debug], [--no-debug] # Enable debug mode. This mode does not delete the AWS resources created by Drunker
|
134
|
+
[--access-key=ACCESS_KEY] # AWS access key token used by Drunker
|
135
|
+
[--secret-key=SECRET_KEY] # AWS secret key token used by Drunker
|
136
|
+
[--region=REGION] # AWS region in which resources is created by Drunker
|
137
|
+
[--profile-name=PROFILE_NAME] # AWS shared credentials profile name used by Drunker
|
138
|
+
|
139
|
+
Run a command on CodeBuild
|
140
|
+
```
|
141
|
+
|
142
|
+
## Configuration
|
143
|
+
|
144
|
+
By default, it loads `.drunker.yml`. In the configuration file, many options can be written in advance. Following example:
|
145
|
+
|
146
|
+
```yaml
|
147
|
+
concurrency: 10
|
148
|
+
compute_type: medium
|
149
|
+
timeout: 5
|
150
|
+
file_pattern: spec/**/*_spec.rb
|
151
|
+
environment_variables:
|
152
|
+
RAILS_ENV: test
|
153
|
+
SECRET_KEY_BASE: super secret
|
154
|
+
aws_credentials:
|
155
|
+
access_key: AWS_ACCESS_KEY_ID
|
156
|
+
secret_key: AWS_SECRET_ACCESS_KEY
|
157
|
+
region: us-east-1
|
158
|
+
```
|
159
|
+
|
160
|
+
If you want to create a configuration file with a different name, specify the file name with --config option.
|
161
|
+
|
162
|
+
```
|
163
|
+
$ drunker run --config=.custom_drunker.yml ruby:2.4.1 bundle exec rspec
|
164
|
+
```
|
165
|
+
|
166
|
+
### Credentials
|
167
|
+
|
168
|
+
Drunker supports various credential providers. It is used with the following priority:
|
169
|
+
|
170
|
+
- Specified shared credentials
|
171
|
+
- Static credentials
|
172
|
+
- Environment credentials
|
173
|
+
- Default shared credentials
|
174
|
+
|
175
|
+
#### Static Credentials
|
176
|
+
|
177
|
+
If you have access key and secret key, you can specify these credentials.
|
178
|
+
|
179
|
+
```
|
180
|
+
$ drunker run --access-key=AWS_ACCESS_KEY_ID --secret-key=AWS_SECRET_ACCESS_KEY --region=us-east-1 owner_name/image_name ruby task.rb
|
181
|
+
```
|
182
|
+
|
183
|
+
```yaml
|
184
|
+
aws_credentials:
|
185
|
+
access_key: AWS_ACCESS_KEY_ID
|
186
|
+
secret_key: AWS_SECRET_ACCESS_KEY
|
187
|
+
region: us-east-1
|
188
|
+
```
|
189
|
+
|
190
|
+
#### Shared Credentials
|
191
|
+
|
192
|
+
If you have [shared credentials](https://aws.amazon.com/blogs/security/a-new-and-standardized-way-to-manage-credentials-in-the-aws-sdks/), you can specify credentials profile name. However Drunker supports only `~/.aws/credentials` as shared credentials location.
|
193
|
+
|
194
|
+
```
|
195
|
+
$ drunker run --profile-name=PROFILE_NAME --region=us-east-1 owner_name/image_name ruby task.rb
|
196
|
+
```
|
197
|
+
|
198
|
+
```yaml
|
199
|
+
aws_credentials:
|
200
|
+
profile_name: PROFILE_NAME
|
201
|
+
region: us-east-1
|
202
|
+
```
|
203
|
+
|
204
|
+
## Customize Build Specification
|
205
|
+
|
206
|
+
Do you want to customize the build specification more? You can change the `buildspec.yml` that is used by Drunker. The default `buildspec.yml` is [here](https://github.com/wata727/drunker/tree/master/lib/drunker/executor/buildspec.yml.erb). For example, if you want to run `bundle install` in the install phase, create the `custom_buildspec.yml` like the following.
|
207
|
+
|
208
|
+
```yaml
|
209
|
+
version: 0.1
|
210
|
+
phases:
|
211
|
+
install:
|
212
|
+
commands:
|
213
|
+
- bundle install
|
214
|
+
build:
|
215
|
+
commands:
|
216
|
+
- <%= commands.join(" ") %> 1> <%= stdout %> 2> <%= stderr %>; echo $? > <%= exit_status %>
|
217
|
+
artifacts:
|
218
|
+
files:
|
219
|
+
- <%= stdout %>
|
220
|
+
- <%= stderr %>
|
221
|
+
- <%= exit_status %>
|
222
|
+
```
|
223
|
+
|
224
|
+
Actual commands and output files are interpolated by ERB. Please see [here](http://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html) for how to write `buildspec.yml`. After that, specify the file path with the `--buildspec` option.
|
225
|
+
|
226
|
+
```
|
227
|
+
$ drunker run --buildspec=custom_buildspec.yml owner_name/image_name ruby task.rb
|
228
|
+
```
|
229
|
+
|
230
|
+
Also, you can specify it in the configuration file.
|
231
|
+
|
232
|
+
```yaml
|
233
|
+
buildspec: custom_buildspec.yml
|
234
|
+
```
|
235
|
+
|
236
|
+
In configuration file, you can also be described inline style.
|
237
|
+
|
238
|
+
```yaml
|
239
|
+
buildspec:
|
240
|
+
version: 0.1
|
241
|
+
phases:
|
242
|
+
install:
|
243
|
+
commands:
|
244
|
+
- bundle install
|
245
|
+
build:
|
246
|
+
commands:
|
247
|
+
- <%= commands.join(" ") %> 1> <%= stdout %> 2> <%= stderr %>; echo $? > <%= exit_status %>
|
248
|
+
artifacts:
|
249
|
+
files:
|
250
|
+
- <%= stdout %>
|
251
|
+
- <%= stderr %>
|
252
|
+
- <%= exit_status %>
|
253
|
+
```
|
254
|
+
|
255
|
+
## Customize Output
|
256
|
+
|
257
|
+
Do you want to customize the output format? You can customize output format, exit code by creating Gem called aggregator. For example, the default aggregator is implemented as a separate [Gem](https://github.com/wata727/drunker-aggregator-pretty).
|
258
|
+
|
259
|
+
The specifications that the aggregator must satisfy are the following three.
|
260
|
+
|
261
|
+
- Inherit `Drunker::Aggregator::Base`
|
262
|
+
- Implement `run` and `exit_status` methods to receive array of `Drunker::Artifact::Layer`
|
263
|
+
- Return a number in `exit_status` method
|
264
|
+
|
265
|
+
`Drunker::Artifact::Layer` has outputs and build ID for each build. Please see the [implementation](https://github.com/wata727/drunker/blob/master/lib/drunker/artifact/layer.rb) for details.
|
266
|
+
|
267
|
+
## Development
|
268
|
+
|
269
|
+
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.
|
270
|
+
|
271
|
+
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).
|
272
|
+
|
273
|
+
## Contributing
|
274
|
+
|
275
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/wata727/drunker. 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.
|
276
|
+
|
277
|
+
|
278
|
+
## License
|
279
|
+
|
280
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
281
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "drunker"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|