djin 0.3.0 → 0.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 33934f255ebae5d8738c8f0152d1684eb1ece014c275f596d0e9aeea59c1caac
4
- data.tar.gz: 89103ce2b41819ddac02c95b4441eb959ea1d03cd92996deb80012a67c098cc9
3
+ metadata.gz: 2c1694ef43737efb232e0ec9ae802c573fd1b76262a77c4d729c3abb26b2fa14
4
+ data.tar.gz: a2c322c54fd3cfee6dcb3e238bb0c97f2f84ce69a55e0697da38497123840072
5
5
  SHA512:
6
- metadata.gz: 2c0c492492dfd58153ae3ff0ee093b09e1c1e5587d6ed8e68b1e9ab4a5dc7aedee7b3c461262731145307cd095750eec01754094265447a8159e6f8a8dc9842f
7
- data.tar.gz: 0edeedbd0c7f12e7a09e178847923ace1068ccf5c76db43ac61fe7f8fec65332a805a14b0531d967230fe38e94436a4f25e7119e5c759a08f158a483ef76bc87
6
+ metadata.gz: 1951778dbcd47e2f15c2f5cf5300e746b5550f6f1d9284277df61ec567c94f46283673e78b9c7253fa8fe6770ae5ded21b5cec64cf4bff40ad47873fed1a3929
7
+ data.tar.gz: 1dcb9d493713d32acd50c9c3238723a4a5b3c179383dcaea3b30ae80a6727f32466b296d6866e7a611ad2fa634328a1c26f3219702738fd7491fb36bc5f2074f
@@ -18,3 +18,17 @@ jobs:
18
18
  gem install bundler
19
19
  bundle install --jobs 4 --retry 3
20
20
  bundle exec rake
21
+
22
+ lint:
23
+ runs-on: ubuntu-16.04
24
+ name: Lint
25
+ steps:
26
+ - uses: actions/checkout@v2
27
+ - uses: actions/setup-ruby@v1
28
+ with:
29
+ ruby-version: '2.6'
30
+ - run: |
31
+ gem install bundler
32
+ bundle install --jobs 4 --retry 3
33
+ bundle exec rubocop
34
+
@@ -0,0 +1,8 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ Style/Documentation:
4
+ Enabled: false
5
+
6
+ Metrics/BlockLength:
7
+ Exclude:
8
+ - spec/**/*
@@ -0,0 +1,17 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2020-07-14 01:12:35 UTC using RuboCop version 0.86.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 2
10
+ # Configuration parameters: IgnoredMethods.
11
+ Metrics/AbcSize:
12
+ Max: 21
13
+
14
+ # Offense count: 2
15
+ # Configuration parameters: CountComments, ExcludedMethods.
16
+ Metrics/MethodLength:
17
+ Max: 19
@@ -1,3 +1,23 @@
1
+ ## 0.7.0 - 20/08/2020
2
+ * [FEATURE] Adds description option
3
+
4
+ ## 0.6.1 - 11/08/2020
5
+ * [TECH] Better Error Handling
6
+
7
+ ## 0.6.0 - 22/07/2020
8
+ * [FEATURE] Djin Variables
9
+
10
+ ## 0.5.0 - 13/07/2020
11
+ * [FEATURE] Adds local command task
12
+ * [FEATURE] Template Args for entire djin.yml
13
+
14
+ ## 0.4.0 - 25/06/2020
15
+ * [FEATURE] Adds Custom Args and Environment support in djin.yml
16
+
17
+ ## 0.3.1 - 29/05/2020
18
+ * [PATCH] Handles Ctrl + C
19
+ * [TECH] Adds Vertofile
20
+
1
21
  ## 0.3.0 - 19/05/2020
2
22
  * [FEATURE] Adds Version Option
3
23
  * [PATCH] Add task name in djin.yml parse errors
data/Gemfile CHANGED
@@ -1,4 +1,6 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in djin.gemspec
4
6
  gemspec
@@ -1,21 +1,24 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- djin (0.3.0)
5
- dry-cli (~> 0.5.0)
4
+ djin (0.7.0)
5
+ dry-cli (~> 0.6.0)
6
+ dry-equalizer (~> 0.3.0)
6
7
  dry-struct (~> 1.3.0)
7
- dry-validation (~> 1.5.0)
8
+ dry-validation (~> 1.5.1)
9
+ mustache (~> 1.1.1)
8
10
  vseries (~> 0.1.0)
9
11
 
10
12
  GEM
11
13
  remote: https://rubygems.org/
12
14
  specs:
15
+ ast (2.4.1)
13
16
  byebug (11.1.1)
14
- concurrent-ruby (1.1.6)
17
+ concurrent-ruby (1.1.7)
15
18
  diff-lcs (1.3)
16
- dry-cli (0.5.1)
19
+ dry-cli (0.6.0)
17
20
  concurrent-ruby (~> 1.0)
18
- dry-configurable (0.11.5)
21
+ dry-configurable (0.11.6)
19
22
  concurrent-ruby (~> 1.0)
20
23
  dry-core (~> 0.4, >= 0.4.7)
21
24
  dry-equalizer (~> 0.2)
@@ -27,11 +30,11 @@ GEM
27
30
  dry-equalizer (0.3.0)
28
31
  dry-inflector (0.2.0)
29
32
  dry-initializer (3.0.3)
30
- dry-logic (1.0.6)
33
+ dry-logic (1.0.7)
31
34
  concurrent-ruby (~> 1.0)
32
35
  dry-core (~> 0.2)
33
36
  dry-equalizer (~> 0.2)
34
- dry-schema (1.5.0)
37
+ dry-schema (1.5.2)
35
38
  concurrent-ruby (~> 1.0)
36
39
  dry-configurable (~> 0.8, >= 0.8.3)
37
40
  dry-core (~> 0.4)
@@ -51,7 +54,7 @@ GEM
51
54
  dry-equalizer (~> 0.3)
52
55
  dry-inflector (~> 0.1, >= 0.1.2)
53
56
  dry-logic (~> 1.0, >= 1.0.2)
54
- dry-validation (1.5.0)
57
+ dry-validation (1.5.3)
55
58
  concurrent-ruby (~> 1.0)
56
59
  dry-container (~> 0.7, >= 0.7.1)
57
60
  dry-core (~> 0.4)
@@ -59,7 +62,14 @@ GEM
59
62
  dry-initializer (~> 3.0)
60
63
  dry-schema (~> 1.5)
61
64
  ice_nine (0.11.2)
65
+ mustache (1.1.1)
66
+ parallel (1.19.2)
67
+ parser (2.7.1.4)
68
+ ast (~> 2.4.1)
69
+ rainbow (3.0.0)
62
70
  rake (13.0.1)
71
+ regexp_parser (1.7.1)
72
+ rexml (3.2.4)
63
73
  rspec (3.9.0)
64
74
  rspec-core (~> 3.9.0)
65
75
  rspec-expectations (~> 3.9.0)
@@ -73,6 +83,19 @@ GEM
73
83
  diff-lcs (>= 1.2.0, < 2.0)
74
84
  rspec-support (~> 3.9.0)
75
85
  rspec-support (3.9.2)
86
+ rubocop (0.86.0)
87
+ parallel (~> 1.10)
88
+ parser (>= 2.7.0.1)
89
+ rainbow (>= 2.2.2, < 4.0)
90
+ regexp_parser (>= 1.7)
91
+ rexml
92
+ rubocop-ast (>= 0.0.3, < 1.0)
93
+ ruby-progressbar (~> 1.7)
94
+ unicode-display_width (>= 1.4.0, < 2.0)
95
+ rubocop-ast (0.0.3)
96
+ parser (>= 2.7.0.1)
97
+ ruby-progressbar (1.10.1)
98
+ unicode-display_width (1.7.0)
76
99
  vseries (0.1.1)
77
100
 
78
101
  PLATFORMS
@@ -84,6 +107,7 @@ DEPENDENCIES
84
107
  djin!
85
108
  rake (~> 13.0)
86
109
  rspec (~> 3.0)
110
+ rubocop
87
111
 
88
112
  BUNDLED WITH
89
- 2.0.2
113
+ 2.1.4
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Djin
2
2
 
3
3
  ![](https://github.com/catks/djin/workflows/Ruby/badge.svg?branch=master)
4
+ [![Maintainability](https://api.codeclimate.com/v1/badges/824a2e78399813543212/maintainability)](https://codeclimate.com/github/catks/djin/maintainability)
4
5
 
5
6
  Djin is a make-like utility for docker containers
6
7
 
@@ -25,64 +26,164 @@ If you use Rbenv you can install djin only once and create a alias in your .basr
25
26
  To use djin first you need to create a djin.yml file:
26
27
 
27
28
  ```yaml
28
- djin_version: '0.3.0'
29
-
30
- # With a docker image
31
- script:
32
- docker:
33
- image: "ruby:2.6"
34
- run:
35
- commands:
36
- - "ruby /scripts/my_ruby_script.rb"
37
- options: "--rm -v $(pwd)/my_ruby_script.rb:/scripts/my_ruby_script.rb"
38
-
39
- # Using a docker-compose service
40
- test:
29
+ djin_version: '0.7.0'
30
+
31
+ tasks:
32
+ # With a docker image
33
+ script:
34
+ docker:
35
+ image: "ruby:2.6"
36
+ run:
37
+ commands:
38
+ - "ruby /scripts/my_ruby_script.rb"
39
+ options: "--rm -v $(pwd)/my_ruby_script.rb:/scripts/my_ruby_script.rb"
40
+
41
+ # Using a docker-compose service
42
+ test:
41
43
  docker-compose:
42
44
  service: app
43
45
  run:
44
46
  commands: rspec
45
47
  options: "--rm"
46
-
47
48
  ```
48
49
 
49
50
  You can also set task dependencies with depends_on option:
50
51
 
51
52
 
52
53
  ```yaml
53
- djin_version: '0.3.0'
54
+ djin_version: '0.7.0'
54
55
 
55
56
  _default_run_options: &default_run_options
56
57
  options: "--rm"
57
58
 
58
- "db:create":
59
- docker-compose:
60
- service: app
61
- run:
62
- commands: rake db:create
63
- <<: *default_run_options
59
+ tasks:
60
+ "db:create":
61
+ docker-compose:
62
+ service: app
63
+ run:
64
+ commands: rake db:create
65
+ <<: *default_run_options
66
+
67
+ "db:migrate":
68
+ docker-compose:
69
+ service: app
70
+ run:
71
+ commands: rake db:migrate
72
+ <<: *default_run_options
73
+
74
+ "db:setup":
75
+ depends_on:
76
+ - "db:create"
77
+ - "db:migrate"
78
+ ```
64
79
 
65
- "db:migrate":
66
- docker-compose:
67
- service: app
68
- run:
69
- commands: rake db:migrate
70
- <<: *default_run_options
80
+ Or mix local commands and docker/docker-compose commands:
71
81
 
72
- "db:setup":
73
- depends_on:
74
- - "db:create"
75
- - "db:migrate"
82
+ ```yaml
83
+ djin_version: '0.7.0'
76
84
 
85
+ _default_run_options: &default_run_options
86
+ options: "--rm"
87
+
88
+ tasks:
89
+ "db:create":
90
+ docker-compose:
91
+ service: app
92
+ run:
93
+ commands: rake db:create
94
+ <<: *default_run_options
95
+
96
+ "db:migrate":
97
+ docker-compose:
98
+ service: app
99
+ run:
100
+ commands: rake db:migrate
101
+ <<: *default_run_options
102
+
103
+ "setup:copy_samples":
104
+ local:
105
+ run:
106
+ - cp config/database.yml.sample config/database.yml
107
+
108
+ "setup":
109
+ depends_on:
110
+ - "setup:copy_samples"
111
+ - "db:create"
112
+ - "db:migrate"
77
113
  ```
78
114
 
79
115
  After that you can run `djin {{task_name}}`, like `djin script` or `djin test`
80
116
 
117
+ ## Using Environment variables, custom variables and custom args in djin.yml tasks
118
+
119
+ You can also use environment variables using the '{{YOUR_ENV_HERE}}' syntax, like so:
120
+
121
+ ```yaml
122
+ djin_version: '0.7.0'
123
+
124
+ _default_run_options: &default_run_options
125
+ options: "--rm"
126
+
127
+ tasks:
128
+ "db:migrate":
129
+ docker-compose:
130
+ service: app
131
+ run:
132
+ commands: ENV={{ENV}} rake db:migrate
133
+ <<: *default_run_options
134
+
135
+ ```
136
+
137
+ Or define some variables to use in multiple locations
138
+ ```yaml
139
+ djin_version: '0.7.0'
140
+
141
+ _default_run_options: &default_run_options
142
+ options: "--rm"
143
+
144
+ variables:
145
+ my_ssh_user: user
146
+ some_host: test.local
147
+
148
+ tasks:
149
+ "some_host:ssh":
150
+ local:
151
+ run:
152
+ - ssh {{my_ssh_user}}@{{some_host}}
153
+
154
+ "some_host:logs":
155
+ local:
156
+ run:
157
+ - ssh -t {{my_ssh_user}}@{{some_host}} 'tail -f /var/log/syslog'
158
+ ```
159
+
160
+ 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:
161
+
162
+ ```yaml
163
+ djin_version: '0.7.0'
164
+
165
+ _default_run_options: &default_run_options
166
+ options: "--rm"
167
+
168
+ tasks:
169
+ "rubocop":
170
+ docker-compose:
171
+ service: app
172
+ run:
173
+ commands: rubocop {{args}}
174
+ <<: *default_run_options
175
+
176
+ ```
177
+
178
+ With that you can pass custom args after `--`, eg: `djin rubocop -- --parallel`, which wil make djin runs `rubocop --parallel` inside the service `app`.
179
+
180
+ 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)
181
+
81
182
  ## Development
82
183
 
83
184
  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.
84
185
 
85
- 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).
186
+ 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).
86
187
 
87
188
  ## TODO:
88
189
 
data/Rakefile CHANGED
@@ -1,10 +1,12 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
- require_relative "lib/djin"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+ require_relative 'lib/djin'
4
6
 
5
7
  RSpec::Core::RakeTask.new(:spec)
6
8
 
7
- task :default => :spec
9
+ task default: :spec
8
10
 
9
11
  desc 'Djin REPL'
10
12
  task :console do
@@ -0,0 +1,45 @@
1
+ verto_version '0.8.0'
2
+
3
+ config {
4
+ version.prefix = 'v' # Adds a version_prefix
5
+ git.pull_before_tag_creation = true
6
+ git.push_after_tag_creation = true
7
+ }
8
+
9
+ context(branch('master')) {
10
+ before_command_tag_up {
11
+ command_options.add(filter: 'release_only')
12
+ }
13
+
14
+ before_tag_creation {
15
+ version_changes = sh(
16
+ %q#git log --oneline --decorate | grep -B 100 -m 1 "tag:" | grep "pull request" | awk '{print $1}' | xargs git show --format='%b' | grep -v Approved | grep -v "^$" | grep -E "^[[:space:]]*\[.*\]" | sed 's/^[[:space:]]*\(.*\)/ * \1/'#, output: false
17
+ ).output
18
+
19
+ puts "---------------------------"
20
+ version_changes = "## #{new_version} - #{Time.now.strftime('%d/%m/%Y')}\n#{version_changes}\n"
21
+ exit unless confirm("Create new Realease?\n" \
22
+ "---------------------------\n" \
23
+ "#{version_changes}" \
24
+ "---------------------------\n"
25
+ )
26
+
27
+ # CHANGELOG
28
+ file('CHANGELOG.md').prepend(version_changes)
29
+ git!('add CHANGELOG.md')
30
+
31
+ file('lib/djin/version.rb').replace(latest_version.to_s, new_version.to_s)
32
+ file('djin.yml').replace(latest_version.to_s, new_version.to_s)
33
+ file('examples/djin.yml').replace(latest_version.to_s, new_version.to_s)
34
+ file('README.md').replace_all(latest_version.to_s, new_version.to_s)
35
+
36
+ git!('add lib/djin/version.rb djin.yml examples/djin.yml README.md')
37
+
38
+ sh!('bundle install')
39
+ sh!('rake install')
40
+ git!('add Gemfile.lock')
41
+
42
+ git!('commit -m "Bumps Version"')
43
+ }
44
+ }
45
+