djin 0.1.0 → 0.5.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: 43fa5ed070cc953adb7ad4864322e97cf8ef59d9fc514d65d2a4f8800a3f1a0a
4
- data.tar.gz: 0ade4fdef165250abfbb8c80f46d6f67ec89eb7a2f60482402f5b0609ee12425
3
+ metadata.gz: a40e01844f1a9b034d592696cf6af915622c834a9e231f0c56209c03d11660ad
4
+ data.tar.gz: facbe98a7362ec81b5f819af27a554807790a1445c7cc47161a85d5f0d5b7276
5
5
  SHA512:
6
- metadata.gz: d7d80c7af51b9ce35249c5b57d2820947d43d5872a9ef59d619e47969dabfb1b0055888b650be5e7ea15444786eebe7d518543db0f180c0afe568992a162af64
7
- data.tar.gz: 2968f433099a2df4b4449b45f2a94dfa889976e1bdb17dc96ebcca0c8c52f7b099426f5d0bdbac0921b4527bc96e8d0c0a29edf0b14c92d2921e44debff2a832
6
+ metadata.gz: 72f5ea393c498311acf74a482b02670d94f11704a75032e31e914e68b947de694bec077ba03e22b75fd73c9307f9f98242ea35009f5341c2ab9b3d1af0314901
7
+ data.tar.gz: 4bf6650c80d7defc1dd3b2850c21b74c54ecdb7f4dd374c0a98dd3bfe2610c7175f7102a71de53d6367a4dfd1fcdae47437a2db24bee83bc1c195a4c0fea9da7
@@ -0,0 +1,34 @@
1
+ name: Ruby
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-16.04
8
+ strategy:
9
+ matrix:
10
+ ruby: [ '2.4', '2.5', '2.6' ]
11
+ name: Ruby ${{ matrix.ruby }}
12
+ steps:
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
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
@@ -0,0 +1,15 @@
1
+ ## 0.5.0 - 13/07/2020
2
+ * [FEATURE] Adds local command task
3
+ * [FEATURE] Template Args for entire djin.yml
4
+
5
+ ## 0.4.0 - 25/06/2020
6
+ * [FEATURE] Adds Custom Args and Environment support in djin.yml
7
+
8
+ ## 0.3.1 - 29/05/2020
9
+ * [PATCH] Handles Ctrl + C
10
+ * [TECH] Adds Vertofile
11
+
12
+ ## 0.3.0 - 19/05/2020
13
+ * [FEATURE] Adds Version Option
14
+ * [PATCH] Add task name in djin.yml parse errors
15
+
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,20 +1,23 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- djin (0.1.0)
5
- dry-cli (~> 0.5.0)
4
+ djin (0.5.0)
5
+ dry-cli (~> 0.6.0)
6
6
  dry-struct (~> 1.3.0)
7
- dry-validation (~> 1.4.0)
7
+ dry-validation (~> 1.5.1)
8
+ mustache (~> 1.1.1)
9
+ vseries (~> 0.1.0)
8
10
 
9
11
  GEM
10
12
  remote: https://rubygems.org/
11
13
  specs:
14
+ ast (2.4.1)
12
15
  byebug (11.1.1)
13
16
  concurrent-ruby (1.1.6)
14
17
  diff-lcs (1.3)
15
- dry-cli (0.5.1)
18
+ dry-cli (0.6.0)
16
19
  concurrent-ruby (~> 1.0)
17
- dry-configurable (0.11.3)
20
+ dry-configurable (0.11.6)
18
21
  concurrent-ruby (~> 1.0)
19
22
  dry-core (~> 0.4, >= 0.4.7)
20
23
  dry-equalizer (~> 0.2)
@@ -30,35 +33,42 @@ GEM
30
33
  concurrent-ruby (~> 1.0)
31
34
  dry-core (~> 0.2)
32
35
  dry-equalizer (~> 0.2)
33
- dry-schema (1.4.3)
36
+ dry-schema (1.5.2)
34
37
  concurrent-ruby (~> 1.0)
35
38
  dry-configurable (~> 0.8, >= 0.8.3)
36
39
  dry-core (~> 0.4)
37
40
  dry-equalizer (~> 0.2)
38
41
  dry-initializer (~> 3.0)
39
42
  dry-logic (~> 1.0)
40
- dry-types (~> 1.2)
43
+ dry-types (~> 1.4)
41
44
  dry-struct (1.3.0)
42
45
  dry-core (~> 0.4, >= 0.4.4)
43
46
  dry-equalizer (~> 0.3)
44
47
  dry-types (~> 1.3)
45
48
  ice_nine (~> 0.11)
46
- dry-types (1.3.1)
49
+ dry-types (1.4.0)
47
50
  concurrent-ruby (~> 1.0)
48
51
  dry-container (~> 0.3)
49
52
  dry-core (~> 0.4, >= 0.4.4)
50
53
  dry-equalizer (~> 0.3)
51
54
  dry-inflector (~> 0.1, >= 0.1.2)
52
55
  dry-logic (~> 1.0, >= 1.0.2)
53
- dry-validation (1.4.2)
56
+ dry-validation (1.5.1)
54
57
  concurrent-ruby (~> 1.0)
55
58
  dry-container (~> 0.7, >= 0.7.1)
56
59
  dry-core (~> 0.4)
57
60
  dry-equalizer (~> 0.2)
58
61
  dry-initializer (~> 3.0)
59
- dry-schema (~> 1.4, >= 1.4.3)
62
+ dry-schema (~> 1.5)
60
63
  ice_nine (0.11.2)
61
- rake (10.5.0)
64
+ mustache (1.1.1)
65
+ parallel (1.19.2)
66
+ parser (2.7.1.4)
67
+ ast (~> 2.4.1)
68
+ rainbow (3.0.0)
69
+ rake (13.0.1)
70
+ regexp_parser (1.7.1)
71
+ rexml (3.2.4)
62
72
  rspec (3.9.0)
63
73
  rspec-core (~> 3.9.0)
64
74
  rspec-expectations (~> 3.9.0)
@@ -72,6 +82,20 @@ GEM
72
82
  diff-lcs (>= 1.2.0, < 2.0)
73
83
  rspec-support (~> 3.9.0)
74
84
  rspec-support (3.9.2)
85
+ rubocop (0.86.0)
86
+ parallel (~> 1.10)
87
+ parser (>= 2.7.0.1)
88
+ rainbow (>= 2.2.2, < 4.0)
89
+ regexp_parser (>= 1.7)
90
+ rexml
91
+ rubocop-ast (>= 0.0.3, < 1.0)
92
+ ruby-progressbar (~> 1.7)
93
+ unicode-display_width (>= 1.4.0, < 2.0)
94
+ rubocop-ast (0.0.3)
95
+ parser (>= 2.7.0.1)
96
+ ruby-progressbar (1.10.1)
97
+ unicode-display_width (1.7.0)
98
+ vseries (0.1.1)
75
99
 
76
100
  PLATFORMS
77
101
  ruby
@@ -80,8 +104,9 @@ DEPENDENCIES
80
104
  bundler (~> 2.0)
81
105
  byebug
82
106
  djin!
83
- rake (~> 10.0)
107
+ rake (~> 13.0)
84
108
  rspec (~> 3.0)
109
+ rubocop
85
110
 
86
111
  BUNDLED WITH
87
- 2.0.2
112
+ 2.1.4
data/README.md CHANGED
@@ -1,16 +1,32 @@
1
1
  # Djin
2
2
 
3
+ ![](https://github.com/catks/djin/workflows/Ruby/badge.svg?branch=master)
4
+
5
+ Djin is a make-like utility for docker containers
6
+
3
7
  ## Installation
4
8
 
5
9
  Djin is distributed as a Ruby Gem, to install simple run:
6
10
 
7
11
  $ gem install djin
8
12
 
13
+ ### With Rbenv
14
+
15
+ If you use Rbenv you can install djin only once and create a alias in your .basrc, .zshrc, etc:
16
+
17
+ #### ZSH
18
+ $ RBENV_VERSION=$(rbenv global) gem install djin && echo "alias djin='RBENV_VERSION=$(rbenv global) djin'" >> ~/.zshrc
19
+
20
+ ### Bash
21
+ $ RBENV_VERSION=$(rbenv global) gem install djin && echo "alias djin='RBENV_VERSION=$(rbenv global) djin'" >> ~/.bashrc
22
+
9
23
  ## Usage
10
24
 
11
25
  To use djin first you need to create a djin.yml file:
12
26
 
13
27
  ```yaml
28
+ djin_version: '0.5.0'
29
+
14
30
  # With a docker image
15
31
  script:
16
32
  docker:
@@ -25,12 +41,117 @@ test:
25
41
  docker-compose:
26
42
  service: app
27
43
  run:
28
- command: rspec
44
+ commands: rspec
29
45
  options: "--rm"
30
46
 
31
47
  ```
32
48
 
33
- After that you can run djin {{task_name}}, like djin script or djin test
49
+ You can also set task dependencies with depends_on option:
50
+
51
+
52
+ ```yaml
53
+ djin_version: '0.5.0'
54
+
55
+ _default_run_options: &default_run_options
56
+ options: "--rm"
57
+
58
+ "db:create":
59
+ docker-compose:
60
+ service: app
61
+ run:
62
+ commands: rake db:create
63
+ <<: *default_run_options
64
+
65
+ "db:migrate":
66
+ docker-compose:
67
+ service: app
68
+ run:
69
+ commands: rake db:migrate
70
+ <<: *default_run_options
71
+
72
+ "db:setup":
73
+ depends_on:
74
+ - "db:create"
75
+ - "db:migrate"
76
+
77
+ ```
78
+
79
+ Or mix local commands and docker/docker-compose commands:
80
+
81
+ ```yaml
82
+ djin_version: '0.5.0'
83
+
84
+ _default_run_options: &default_run_options
85
+ options: "--rm"
86
+
87
+ "db:create":
88
+ docker-compose:
89
+ service: app
90
+ run:
91
+ commands: rake db:create
92
+ <<: *default_run_options
93
+
94
+ "db:migrate":
95
+ docker-compose:
96
+ service: app
97
+ run:
98
+ commands: rake db:migrate
99
+ <<: *default_run_options
100
+
101
+ "setup:copy_samples":
102
+ local:
103
+ run:
104
+ - cp config/database.yml.sample config/database.yml
105
+
106
+ "setup":
107
+ depends_on:
108
+ - "setup:copy_samples"
109
+ - "db:create"
110
+ - "db:migrate"
111
+
112
+ ```
113
+
114
+ After that you can run `djin {{task_name}}`, like `djin script` or `djin test`
115
+
116
+ ## Using Environment variables and custom args in djin.yml run tasks
117
+
118
+ You can also use environment variables using the '{{YOUR_ENV_HERE}}' syntax, like so:
119
+
120
+ ```yaml
121
+ djin_version: '0.5.0'
122
+
123
+ _default_run_options: &default_run_options
124
+ options: "--rm"
125
+
126
+ "db:migrate":
127
+ docker-compose:
128
+ service: app
129
+ run:
130
+ commands: ENV={{ENV}} rake db:migrate
131
+ <<: *default_run_options
132
+
133
+ ```
134
+
135
+ It's also possible to pass custom arguments to the command, wich means is possible to make a djin task act like the command itself:
136
+
137
+ ```yaml
138
+ djin_version: '0.5.0'
139
+
140
+ _default_run_options: &default_run_options
141
+ options: "--rm"
142
+
143
+ "rubocop":
144
+ docker-compose:
145
+ service: app
146
+ run:
147
+ commands: rubocop {{args}}
148
+ <<: *default_run_options
149
+
150
+ ```
151
+
152
+ With that you can pass custom args after `--`, eg: `djin rubocop -- --parallel`, which wil make djin runs `rubocop --parallel` inside the service `app`.
153
+
154
+ 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)
34
155
 
35
156
  ## Development
36
157
 
@@ -38,10 +159,9 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
38
159
 
39
160
  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).
40
161
 
41
- # TODO:
162
+ ## TODO:
42
163
 
43
- 1. Add depends_on to run dependent tasks
44
- 2. Adds a -f option to load custom djin files
164
+ 1. Adds a `-f` option to load custom djin files
45
165
 
46
166
  ## Contributing
47
167
 
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
+
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "djin"
4
+ require 'bundler/setup'
5
+ require 'djin'
5
6
 
6
7
  # You can add fixtures and/or initialization code here to make experimenting
7
8
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +11,5 @@ require "djin"
10
11
  # require "pry"
11
12
  # Pry.start
12
13
 
13
- require "irb"
14
+ require 'irb'
14
15
  IRB.start(__FILE__)