djin 0.8.0 → 0.11.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 558aca989aad2d1cfd7b19768a7a5d6fd2f660afb5135fb9ca3ae03eacb233b4
4
- data.tar.gz: f2e5c3861c6db601b77bc04321386cb2c22ec049d315781966830ba8a5f6e8af
3
+ metadata.gz: c8ed8e839aa664296b03ffabbd80b1394d68bfbd02439205d79d26fc7b450653
4
+ data.tar.gz: a7023cca57674f3f7e176d80b21f7c60d3251017df6f1252bd47d3549ed89740
5
5
  SHA512:
6
- metadata.gz: a898ea486006d81980a4e963a1e7b2d31f40c5bec00d9b5948f4b32d0be5c222b61525c90fd214523cd482aadeab88e3927cb3a3697f7fc86b8180901e015543
7
- data.tar.gz: 3d6b0a29b1faa6a3bffb0fa5076ee88083229cbb36f77f2166e44bc19ddd84b73bd6b254578da2c721e1c08ffc7e9583f1325bdd73acc87511ceec47b3f0e512
6
+ metadata.gz: f8e9ead0edc8cf175b3fad08e6129f023be758610bc2e0636cd4d0b72aa7b2239b08b84234693127ddd8f1e74731852a5e7e2d0bdf8de55bbb17f88734aac625
7
+ data.tar.gz: 9d2f4d89f2a1a220b67f3e8a0d97b95e43c75f542559eb8ead1d829c4687f9a856f644268c3e3f3ed3a63f20d765d9689653490eb4a6d527fa1e4f864a18eb57
@@ -1,23 +1,37 @@
1
1
  name: Ruby
2
2
 
3
- on: [push]
3
+ on: [push, workflow_dispatch]
4
4
 
5
5
  jobs:
6
6
  build:
7
7
  runs-on: ubuntu-16.04
8
8
  strategy:
9
9
  matrix:
10
- ruby: [ '2.4', '2.5', '2.6' ]
10
+ ruby: [ '2.5', '2.6', '2.7' ]
11
11
  name: Ruby ${{ matrix.ruby }}
12
12
  steps:
13
13
  - uses: actions/checkout@v2
14
- - uses: actions/setup-ruby@v1
15
- with:
16
- ruby-version: ${{ matrix.ruby }}
17
- - run: |
18
- gem install bundler
19
- bundle install --jobs 4 --retry 3
20
- bundle exec rake
14
+
15
+ - name: Setup Code Climate test-reporter
16
+ run: |
17
+ curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
18
+ chmod +x ./cc-test-reporter
19
+ ./cc-test-reporter before-build
20
+
21
+ - name: Build
22
+ run: |
23
+ docker-compose -p djin_ruby_${{ matrix.ruby }} build --build-arg ${{ matrix.ruby }} app
24
+
25
+ - name: Run tests
26
+ run: |
27
+ docker-compose -p djin_ruby_${{ matrix.ruby }} run --rm app rspec
28
+ env:
29
+ TMP_TEST_FILE_FOLDER: '/tmp'
30
+
31
+ - name: Publish code coverage
32
+ run: |
33
+ # TODO: Move to script
34
+ docker-compose -p djin_ruby_${{ matrix.ruby }} run --rm app 'export GIT_BRANCH="${GITHUB_REF/refs\/heads\//}" && ./cc-test-reporter after-build -r ${{secrets.CC_TEST_REPORTER_ID}}'
21
35
 
22
36
  lint:
23
37
  runs-on: ubuntu-16.04
@@ -27,8 +41,10 @@ jobs:
27
41
  - uses: actions/setup-ruby@v1
28
42
  with:
29
43
  ruby-version: '2.6'
30
- - run: |
44
+ - name: Install Gems
45
+ run: |
31
46
  gem install bundler
32
47
  bundle install --jobs 4 --retry 3
33
- bundle exec rubocop
48
+ - name: Rubocop
49
+ run: bundle exec rubocop
34
50
 
data/.gitignore CHANGED
@@ -7,6 +7,7 @@
7
7
  /spec/reports/
8
8
  /tmp/
9
9
  .byebug_history
10
+ .irb_history
10
11
 
11
12
  # rspec failure tracking
12
13
  .rspec_status
data/.irbrc ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ IRB.conf[:SAVE_HISTORY] = 200
4
+ IRB.conf[:HISTORY_FILE] = '~/.irb_history'
@@ -3,6 +3,11 @@ inherit_from: .rubocop_todo.yml
3
3
  Style/Documentation:
4
4
  Enabled: false
5
5
 
6
+ Style/BlockDelimiters:
7
+ Exclude:
8
+ - spec/**/*
9
+
6
10
  Metrics/BlockLength:
7
11
  Exclude:
8
12
  - spec/**/*
13
+ - djin.gemspec
@@ -1,3 +1,20 @@
1
+ ## 0.11.2 - 29/01/2021
2
+ * [FIX] Remote-Config Fetch for custom Branches
3
+ [FIX] Integration Specs
4
+
5
+ ## 0.11.1 - 15/01/2021
6
+ * [FIX] remote-config fetch with same repo reference
7
+
8
+ ## 0.11.0 - 14/01/2021
9
+ * [FEATURE] Remote Configs
10
+ * [TECH] Adds Test Coverage
11
+
12
+ ## 0.10.0 - 08/10/2020
13
+ * [FEATURE] -f command option
14
+
15
+ ## 0.9.0 - 17/09/2020
16
+ * [FEATURE] Include Option
17
+
1
18
  ## 0.8.0 - 31/08/2020
2
19
  * [FEATURE] Adds aliases option
3
20
 
data/Dockerfile CHANGED
@@ -1,4 +1,5 @@
1
- FROM ruby:2.6.5-alpine AS builder
1
+ ARG RUBY_VERSION
2
+ FROM ruby:${RUBY_VERSION:-2.6.5}-alpine AS builder
2
3
 
3
4
  ENV BUILD_PACKAGES build-base git
4
5
 
@@ -13,17 +14,23 @@ COPY djin.gemspec Gemfile Gemfile.lock ./
13
14
 
14
15
  COPY lib/djin/version.rb lib/djin/version.rb
15
16
 
16
- RUN gem install bundler -v 2.0.2
17
+ RUN gem install bundler -v 2.1.4
17
18
 
18
19
  RUN bundle install
19
20
 
21
+ FROM builder AS dev
22
+
23
+ WORKDIR /usr/src/djin
24
+
25
+ COPY . .
26
+
20
27
  FROM ruby:2.6.5-alpine
21
28
 
22
29
  WORKDIR /usr/src/djin
23
30
 
24
31
  COPY --from=builder /usr/local/bundle/ /usr/local/bundle
25
32
 
26
- RUN gem install bundler -v 2.0.2
33
+ RUN gem install bundler -v 2.1.4
27
34
 
28
35
  ENV DEPENDENCIES git
29
36
 
data/Gemfile CHANGED
@@ -2,5 +2,9 @@
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
+ group :test do
6
+ gem 'factory_bot'
7
+ end
8
+
5
9
  # Specify your gem's dependencies in djin.gemspec
6
10
  gemspec
@@ -1,73 +1,86 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- djin (0.8.0)
4
+ djin (0.11.2)
5
5
  dry-cli (~> 0.6.0)
6
6
  dry-equalizer (~> 0.3.0)
7
7
  dry-struct (~> 1.3.0)
8
8
  dry-validation (~> 1.5.1)
9
+ git (~> 1.8.1)
9
10
  mustache (~> 1.1.1)
10
11
  vseries (~> 0.1.0)
11
12
 
12
13
  GEM
13
14
  remote: https://rubygems.org/
14
15
  specs:
16
+ activesupport (6.1.1)
17
+ concurrent-ruby (~> 1.0, >= 1.0.2)
18
+ i18n (>= 1.6, < 2)
19
+ minitest (>= 5.1)
20
+ tzinfo (~> 2.0)
21
+ zeitwerk (~> 2.3)
15
22
  ast (2.4.1)
16
23
  byebug (11.1.1)
17
24
  concurrent-ruby (1.1.7)
18
25
  diff-lcs (1.3)
26
+ docile (1.3.2)
19
27
  dry-cli (0.6.0)
20
28
  concurrent-ruby (~> 1.0)
21
- dry-configurable (0.11.6)
29
+ dry-configurable (0.12.0)
22
30
  concurrent-ruby (~> 1.0)
23
- dry-core (~> 0.4, >= 0.4.7)
24
- dry-equalizer (~> 0.2)
31
+ dry-core (~> 0.5, >= 0.5.0)
25
32
  dry-container (0.7.2)
26
33
  concurrent-ruby (~> 1.0)
27
34
  dry-configurable (~> 0.1, >= 0.1.3)
28
- dry-core (0.4.9)
35
+ dry-core (0.5.0)
29
36
  concurrent-ruby (~> 1.0)
30
37
  dry-equalizer (0.3.0)
31
38
  dry-inflector (0.2.0)
32
- dry-initializer (3.0.3)
33
- dry-logic (1.0.7)
39
+ dry-initializer (3.0.4)
40
+ dry-logic (1.1.0)
34
41
  concurrent-ruby (~> 1.0)
35
- dry-core (~> 0.2)
36
- dry-equalizer (~> 0.2)
37
- dry-schema (1.5.3)
42
+ dry-core (~> 0.5, >= 0.5)
43
+ dry-schema (1.6.0)
38
44
  concurrent-ruby (~> 1.0)
39
45
  dry-configurable (~> 0.8, >= 0.8.3)
40
- dry-core (~> 0.4)
41
- dry-equalizer (~> 0.2)
46
+ dry-core (~> 0.5, >= 0.5)
42
47
  dry-initializer (~> 3.0)
43
48
  dry-logic (~> 1.0)
44
- dry-types (~> 1.4)
49
+ dry-types (~> 1.5)
45
50
  dry-struct (1.3.0)
46
51
  dry-core (~> 0.4, >= 0.4.4)
47
52
  dry-equalizer (~> 0.3)
48
53
  dry-types (~> 1.3)
49
54
  ice_nine (~> 0.11)
50
- dry-types (1.4.0)
55
+ dry-types (1.5.0)
51
56
  concurrent-ruby (~> 1.0)
52
57
  dry-container (~> 0.3)
53
- dry-core (~> 0.4, >= 0.4.4)
54
- dry-equalizer (~> 0.3)
58
+ dry-core (~> 0.5, >= 0.5)
55
59
  dry-inflector (~> 0.1, >= 0.1.2)
56
60
  dry-logic (~> 1.0, >= 1.0.2)
57
- dry-validation (1.5.4)
61
+ dry-validation (1.5.6)
58
62
  concurrent-ruby (~> 1.0)
59
63
  dry-container (~> 0.7, >= 0.7.1)
60
64
  dry-core (~> 0.4)
61
65
  dry-equalizer (~> 0.2)
62
66
  dry-initializer (~> 3.0)
63
- dry-schema (~> 1.5)
67
+ dry-schema (~> 1.5, >= 1.5.2)
68
+ factory_bot (6.1.0)
69
+ activesupport (>= 5.0.0)
70
+ git (1.8.1)
71
+ rchardet (~> 1.8)
72
+ i18n (1.8.7)
73
+ concurrent-ruby (~> 1.0)
64
74
  ice_nine (0.11.2)
75
+ json (2.3.1)
76
+ minitest (5.14.3)
65
77
  mustache (1.1.1)
66
78
  parallel (1.19.2)
67
79
  parser (2.7.1.4)
68
80
  ast (~> 2.4.1)
69
81
  rainbow (3.0.0)
70
82
  rake (13.0.1)
83
+ rchardet (1.8.0)
71
84
  regexp_parser (1.7.1)
72
85
  rexml (3.2.4)
73
86
  rspec (3.9.0)
@@ -95,8 +108,16 @@ GEM
95
108
  rubocop-ast (0.0.3)
96
109
  parser (>= 2.7.0.1)
97
110
  ruby-progressbar (1.10.1)
111
+ simplecov (0.17.1)
112
+ docile (~> 1.1)
113
+ json (>= 1.8, < 3)
114
+ simplecov-html (~> 0.10.0)
115
+ simplecov-html (0.10.2)
116
+ tzinfo (2.0.4)
117
+ concurrent-ruby (~> 1.0)
98
118
  unicode-display_width (1.7.0)
99
119
  vseries (0.1.1)
120
+ zeitwerk (2.4.2)
100
121
 
101
122
  PLATFORMS
102
123
  ruby
@@ -105,9 +126,11 @@ DEPENDENCIES
105
126
  bundler (~> 2.0)
106
127
  byebug
107
128
  djin!
129
+ factory_bot
108
130
  rake (~> 13.0)
109
131
  rspec (~> 3.0)
110
132
  rubocop
133
+ simplecov (~> 0.17.0)
111
134
 
112
135
  BUNDLED WITH
113
136
  2.1.4
data/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  ![](https://github.com/catks/djin/workflows/Ruby/badge.svg?branch=master)
4
4
  [![Maintainability](https://api.codeclimate.com/v1/badges/824a2e78399813543212/maintainability)](https://codeclimate.com/github/catks/djin/maintainability)
5
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/824a2e78399813543212/test_coverage)](https://codeclimate.com/github/catks/djin/test_coverage)
5
6
 
6
7
  Djin is a make-like utility for docker containers
7
8
 
@@ -13,7 +14,7 @@ Djin is distributed as a Ruby Gem, to install simple run:
13
14
 
14
15
  ### With Rbenv
15
16
 
16
- If you use Rbenv you can install djin only once and create a alias in your .basrc, .zshrc, etc:
17
+ If you use Rbenv you can install djin only once and create an alias in your .basrc, .zshrc, etc:
17
18
 
18
19
  #### ZSH
19
20
  $ RBENV_VERSION=$(rbenv global) gem install djin && echo "alias djin='RBENV_VERSION=$(rbenv global) djin'" >> ~/.zshrc
@@ -26,7 +27,7 @@ If you use Rbenv you can install djin only once and create a alias in your .basr
26
27
  To use djin first you need to create a djin.yml file:
27
28
 
28
29
  ```yaml
29
- djin_version: '0.8.0'
30
+ djin_version: '0.11.2'
30
31
 
31
32
  tasks:
32
33
  # With a docker image
@@ -53,12 +54,12 @@ You can also set task dependencies with depends_on option:
53
54
 
54
55
 
55
56
  ```yaml
56
- djin_version: '0.8.0'
57
+ djin_version: '0.11.2'
57
58
 
58
59
  _default_run_options: &default_run_options
59
60
  options: "--rm"
60
61
 
61
- tasks:
62
+ tasks:
62
63
  "db:create":
63
64
  docker-compose:
64
65
  service: app
@@ -82,7 +83,7 @@ tasks:
82
83
  Or mix local commands and docker/docker-compose commands:
83
84
 
84
85
  ```yaml
85
- djin_version: '0.8.0'
86
+ djin_version: '0.11.2'
86
87
 
87
88
  _default_run_options: &default_run_options
88
89
  options: "--rm"
@@ -121,7 +122,7 @@ After that you can run `djin {{task_name}}`, like `djin script` or `djin test`
121
122
  You can also use environment variables using the '{{YOUR_ENV_HERE}}' syntax, like so:
122
123
 
123
124
  ```yaml
124
- djin_version: '0.8.0'
125
+ djin_version: '0.11.2'
125
126
 
126
127
  _default_run_options: &default_run_options
127
128
  options: "--rm"
@@ -138,7 +139,7 @@ tasks:
138
139
 
139
140
  Or define some variables to use in multiple locations
140
141
  ```yaml
141
- djin_version: '0.8.0'
142
+ djin_version: '0.11.2'
142
143
 
143
144
  _default_run_options: &default_run_options
144
145
  options: "--rm"
@@ -162,7 +163,7 @@ tasks:
162
163
  It's also possible to pass custom arguments to the command, which means is possible to make a djin task act like the command itself:
163
164
 
164
165
  ```yaml
165
- djin_version: '0.8.0'
166
+ djin_version: '0.11.2'
166
167
 
167
168
  _default_run_options: &default_run_options
168
169
  options: "--rm"
@@ -179,19 +180,145 @@ tasks:
179
180
 
180
181
  ```
181
182
 
182
- With that you can pass custom args after `--`, eg: `djin rubocop -- --parallel`, which wil make djin runs `rubocop --parallel` inside the service `app`.
183
+ With that, you can pass custom args after `--`, eg: `djin rubocop -- --parallel`, which will make djin runs `rubocop --parallel` inside the service `app`.
183
184
 
184
185
  Under the hood djin uses [Mustache](https://mustache.github.io/), so you can use other features like conditionals: `{{#IS_ENABLE}} Enabled {{/IS_ENABLE}}` (for args use the `args?`, eg: `{{#args?}} {{args}} --and-other-thing{{/args?}}`), to see more more options you can access this [Link](https://mustache.github.io/mustache.5.html)
185
186
 
187
+ ### Reusing tasks
188
+
189
+ If you have multiple tasks with similar behavior and with small differences you can use the `include` keyword, so this:
190
+
191
+ ```yaml
192
+ djin_version: '0.11.2'
193
+
194
+ tasks:
195
+ "host1:ssh":
196
+ local:
197
+ run:
198
+ - ssh my_user@host1.com.br
199
+
200
+ "host1:restart":
201
+ local:
202
+ run:
203
+ - ssh -t my_user@host1.com.br restart
204
+
205
+ "host1:logs":
206
+ local:
207
+ run:
208
+ - ssh -t my_user@host1.com.br tail -f /var/log/my_log
209
+
210
+ "host2:ssh":
211
+ local:
212
+ run:
213
+ - ssh my_user@host2.com.br
214
+
215
+ "host2:restart":
216
+ local:
217
+ run:
218
+ - ssh -t my_user@host2.com.br restart
219
+
220
+ "host2:logs":
221
+ local:
222
+ run:
223
+ - ssh -t my_user@host2.com.br tail -f /var/log/my_file
224
+
225
+ ```
226
+
227
+ can become this:
228
+
229
+ ```yaml
230
+ # djin.yml
231
+ djin_version: '0.11.2'
232
+
233
+ include:
234
+ - file: '.djin/server_tasks.yml'
235
+ context:
236
+ variables:
237
+ namespace: host1
238
+ host: host1.com
239
+ ssh_user: my_user
240
+
241
+ - file: '.djin/server_tasks.yml'
242
+ context:
243
+ variables:
244
+ namespace: host2
245
+ host: host2.com
246
+ ssh_user: my_user
247
+
248
+ ```
249
+
250
+
251
+ ```yaml
252
+ # .djin/server_tasks.yml
253
+ djin_version: '0.11.2'
254
+
255
+ tasks:
256
+ "{{namespace}}:ssh":
257
+ local:
258
+ run:
259
+ - ssh {{ssh_user}}@{{host}}
260
+
261
+ "{{namespace}}:restart":
262
+ local:
263
+ run:
264
+ - ssh -t {{ssh_user}}@{{host}} restart
265
+
266
+ "{{namespace}}:logs":
267
+ local:
268
+ run:
269
+ - ssh -t {{ssh_user}}@{{host}} tail -f /var/log/my_log
270
+ ```
271
+
272
+ You can also reuse tasks in some git repository, to do that you need to declare a git source and optionally a version:
273
+
274
+ ```yaml
275
+ djin_version: '0.11.2'
276
+
277
+ include:
278
+ - git: 'https://github.com/catks/djin.git'
279
+ version: 'master'
280
+ file: 'examples/djin_lib/test.yml'
281
+ context:
282
+ variables:
283
+ namespace: 'remote:'
284
+
285
+ ```
286
+
287
+ After that run `djin remote-config fetch` to fetch the repo and you can start using the tasks (All remote repos are cloned in `~/.djin/remote`)
288
+
289
+ See `djin remote-config` to learn more.
290
+
291
+ ### Loading custom files
292
+
293
+ You can also specify a file to be read by djin with `-f`, eg:
294
+
295
+ ```bash
296
+ djin -f my_file.yml # Returns the help for all tasks in my_file
297
+ djin -f my_file.yml build # Execute the build task defined in my_file.yml
298
+ ```
299
+
300
+ You can also specify multiple files to join tasks between files:
301
+
302
+ ```bash
303
+ # Mix the tasks
304
+ djin -f my_file.yml -f my_file2.yml # Returns the help for all tasks in my_file
305
+ djin -f my_file.yml -f my_file2.yml build # Execute the build task defined in my_file.yml or my_file2.yml
306
+ ```
307
+
308
+
186
309
  ## Development
187
310
 
188
311
  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.
189
312
 
190
313
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, run `djin release -- {{increment_option}}` (where {{incremment_option}} can be `--patch`, `--minor` or `major`), which will change version, update the CHANGELOG.md, create a new commit, create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
191
314
 
192
- ## TODO:
193
315
 
194
- 1. Adds a `-f` option to load custom djin files
316
+ ## TODO
317
+
318
+ 1. Enable multiple -f options to merge configuration between files
319
+ 2. Option to export tasks to Makefile
320
+ 3. djin-export docker image to create and sync makefiles
321
+ 4. include a key option to add tasks in git repositories files (maybe with a local cache)
195
322
 
196
323
  ## Contributing
197
324