ci-helper 0.2.2 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +3 -0
- data/.gitignore +2 -0
- data/.rubocop.yml +4 -0
- data/README.md +10 -2
- data/lib/ci-helper.rb +3 -0
- data/lib/ci_helper.rb +4 -2
- data/lib/ci_helper/railtie.rb +9 -0
- data/lib/ci_helper/version.rb +1 -1
- data/lib/tasks/sequel_management.rake +69 -0
- metadata +5 -3
- data/Gemfile.lock +0 -104
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe12d4e12b312f65bd43218e3443d40c4ab27ce41aeb386bccebf4b9779d292e
|
4
|
+
data.tar.gz: ec3b1f6d22c637c72dd1600672cd1bb8b960e33727ebf3f16c97e6e10ce25e27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0fd1d742b556b1c6c3eac720d0709fb484780c2ac5dfa80f749bd4c4d8a338e6def6082550298c5c768df3fe6a25e65d0bc0333e9a7c2840b8273a30b544328
|
7
|
+
data.tar.gz: c50a69c1bf32a6ebec2299464063d656bd34af81eaf516935d20b9b55953851f293d5ac7bdaa82372fc79ad91f140ef4a65bda3191506d8a62cee5b7a6851f78
|
data/.github/workflows/ruby.yml
CHANGED
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/README.md
CHANGED
@@ -42,8 +42,9 @@ List of available commands:
|
|
42
42
|
* **CheckDBDevelopment** — executes rails db commands (`db:drop`, `db:create`, `db:migrate`)
|
43
43
|
and seeds database. Does not accept flags.
|
44
44
|
* **CheckDBRollback** — executes rails db commands with additional command
|
45
|
-
`db:rollback_new_migrations`, which rollbacks migrations,
|
46
|
-
|
45
|
+
`db:rollback_new_migrations`, which rollbacks migrations, added in tested branch.
|
46
|
+
Does not accept flags. Gem provides this rake task, but only for `Sequel`.
|
47
|
+
If you want to use `ActiveRecord::Migrator`, you'll have to write rake task by your own.
|
47
48
|
* **RubocopLint** — executes rubocop linter. Does not accept flags.
|
48
49
|
* **RunSpecs** — executes `rspec` in project root.
|
49
50
|
Accepted flags: `--node-index`, `node-total`, `with-database`, `split-resultset`.
|
@@ -62,6 +63,13 @@ Accepted flags: `--node-index`, `node-total`, `with-database`, `split-resultset`
|
|
62
63
|
* `--ignored-paths [values]` - accepts path patterns that should be ignored,
|
63
64
|
delimited by coma.
|
64
65
|
|
66
|
+
### Rake Tasks
|
67
|
+
|
68
|
+
As you can see, some commands use generic rake tasks. To make tasks available in your application,
|
69
|
+
you need to require the file `ci_helper/railtie`. Also, you can require it directly in `Gemfile`:
|
70
|
+
`gem "ci-helper", require: "ci_helper/railtie, group: :test`.
|
71
|
+
Or if you haven't set `require` option to `false`, rake tasks loads automatically.
|
72
|
+
|
65
73
|
### Script
|
66
74
|
|
67
75
|
Also, you can write your own script, which can executes this commands by calling classes:
|
data/lib/ci-helper.rb
ADDED
data/lib/ci_helper.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
module CIHelper
|
4
|
+
end
|
5
|
+
|
3
6
|
require "colorized_string"
|
4
7
|
require "delegate"
|
5
8
|
require "dry/inflector"
|
@@ -14,5 +17,4 @@ require "ci_helper/tools/colorize"
|
|
14
17
|
require "ci_helper/tools/inflector"
|
15
18
|
require "ci_helper/version"
|
16
19
|
|
17
|
-
|
18
|
-
end
|
20
|
+
require "ci_helper/railtie" if defined?(Rails)
|
data/lib/ci_helper/version.rb
CHANGED
@@ -0,0 +1,69 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "logger"
|
4
|
+
|
5
|
+
class SequelManagement
|
6
|
+
include Rake::DSL
|
7
|
+
|
8
|
+
MIGRATIONS_PATH = "db/migrate"
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
self.logger = Logger.new(STDOUT)
|
12
|
+
|
13
|
+
define_db_task!
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
attr_accessor :logger
|
19
|
+
|
20
|
+
def migrations_path
|
21
|
+
self.class::MIGRATIONS_PATH
|
22
|
+
end
|
23
|
+
|
24
|
+
def define_db_task!
|
25
|
+
namespace :db do
|
26
|
+
desc "Rollback all migrations, which doesn't exist in master branch"
|
27
|
+
task rollback_new_migrations: :environment do
|
28
|
+
abort "Shouldn't run in production mode!" if Rails.env.production?
|
29
|
+
|
30
|
+
logger.info "Begin rolling back new migrations"
|
31
|
+
|
32
|
+
original_migrations = `#{git_command}`.split.map { |path| File.basename(path) }
|
33
|
+
migrations_to_rollback = (migrator.applied_migrations - original_migrations).sort.reverse
|
34
|
+
|
35
|
+
next if migrations_to_rollback.empty?
|
36
|
+
|
37
|
+
logger.info "Rolling back migrations:"
|
38
|
+
logger.info migrations_to_rollback.join("\n")
|
39
|
+
|
40
|
+
rollback!(migrations_to_rollback)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def git_command
|
46
|
+
"git ls-tree --name-only origin/master #{migrations_path}/"
|
47
|
+
end
|
48
|
+
|
49
|
+
def migrator
|
50
|
+
@migrator ||= begin
|
51
|
+
full_path = Rails.root.join(migrations_path)
|
52
|
+
Sequel::TimestampMigrator.new(DB, full_path, allow_missing_migration_files: true)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def rollback!(migrations)
|
57
|
+
migrations.each do |migration|
|
58
|
+
migrator.undo(migration.to_i)
|
59
|
+
rescue Sequel::Migrator::Error => error
|
60
|
+
if error.message.include?("does not exist in the filesystem")
|
61
|
+
logger.info error.message
|
62
|
+
else
|
63
|
+
raise error
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
SequelManagement.new
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ci-helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JustAnotherDude
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-08-
|
11
|
+
date: 2020-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -164,7 +164,6 @@ files:
|
|
164
164
|
- ".rspec"
|
165
165
|
- ".rubocop.yml"
|
166
166
|
- Gemfile
|
167
|
-
- Gemfile.lock
|
168
167
|
- LICENSE.txt
|
169
168
|
- README.md
|
170
169
|
- Rakefile
|
@@ -172,6 +171,7 @@ files:
|
|
172
171
|
- bin/setup
|
173
172
|
- ci_helper.gemspec
|
174
173
|
- exe/ci-helper
|
174
|
+
- lib/ci-helper.rb
|
175
175
|
- lib/ci_helper.rb
|
176
176
|
- lib/ci_helper/cli.rb
|
177
177
|
- lib/ci_helper/commands.rb
|
@@ -181,9 +181,11 @@ files:
|
|
181
181
|
- lib/ci_helper/commands/check_spec_suffixes.rb
|
182
182
|
- lib/ci_helper/commands/rubocop_lint.rb
|
183
183
|
- lib/ci_helper/commands/run_specs.rb
|
184
|
+
- lib/ci_helper/railtie.rb
|
184
185
|
- lib/ci_helper/tools/colorize.rb
|
185
186
|
- lib/ci_helper/tools/inflector.rb
|
186
187
|
- lib/ci_helper/version.rb
|
188
|
+
- lib/tasks/sequel_management.rake
|
187
189
|
homepage: https://github.com/umbrellio/ci_helper
|
188
190
|
licenses:
|
189
191
|
- MIT
|
data/Gemfile.lock
DELETED
@@ -1,104 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
ci-helper (0.2.2)
|
5
|
-
colorize (~> 0.8)
|
6
|
-
dry-inflector (~> 0.2)
|
7
|
-
|
8
|
-
GEM
|
9
|
-
remote: https://rubygems.org/
|
10
|
-
specs:
|
11
|
-
activesupport (6.0.3.1)
|
12
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
|
-
i18n (>= 0.7, < 2)
|
14
|
-
minitest (~> 5.1)
|
15
|
-
tzinfo (~> 1.1)
|
16
|
-
zeitwerk (~> 2.2, >= 2.2.2)
|
17
|
-
ast (2.4.1)
|
18
|
-
bundler-audit (0.7.0.1)
|
19
|
-
bundler (>= 1.2.0, < 3)
|
20
|
-
thor (>= 0.18, < 2)
|
21
|
-
coderay (1.1.3)
|
22
|
-
colorize (0.8.1)
|
23
|
-
concurrent-ruby (1.1.6)
|
24
|
-
diff-lcs (1.3)
|
25
|
-
docile (1.3.2)
|
26
|
-
dry-inflector (0.2.0)
|
27
|
-
i18n (1.8.3)
|
28
|
-
concurrent-ruby (~> 1.0)
|
29
|
-
jaro_winkler (1.5.4)
|
30
|
-
method_source (1.0.0)
|
31
|
-
minitest (5.14.1)
|
32
|
-
parallel (1.19.2)
|
33
|
-
parser (2.7.1.3)
|
34
|
-
ast (~> 2.4.0)
|
35
|
-
pry (0.13.1)
|
36
|
-
coderay (~> 1.1)
|
37
|
-
method_source (~> 1.0)
|
38
|
-
rack (2.2.3)
|
39
|
-
rainbow (3.0.0)
|
40
|
-
rake (13.0.1)
|
41
|
-
rexml (3.2.4)
|
42
|
-
rspec (3.9.0)
|
43
|
-
rspec-core (~> 3.9.0)
|
44
|
-
rspec-expectations (~> 3.9.0)
|
45
|
-
rspec-mocks (~> 3.9.0)
|
46
|
-
rspec-core (3.9.2)
|
47
|
-
rspec-support (~> 3.9.3)
|
48
|
-
rspec-expectations (3.9.2)
|
49
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
50
|
-
rspec-support (~> 3.9.0)
|
51
|
-
rspec-mocks (3.9.1)
|
52
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
53
|
-
rspec-support (~> 3.9.0)
|
54
|
-
rspec-support (3.9.3)
|
55
|
-
rubocop (0.81.0)
|
56
|
-
jaro_winkler (~> 1.5.1)
|
57
|
-
parallel (~> 1.10)
|
58
|
-
parser (>= 2.7.0.1)
|
59
|
-
rainbow (>= 2.2.2, < 4.0)
|
60
|
-
rexml
|
61
|
-
ruby-progressbar (~> 1.7)
|
62
|
-
unicode-display_width (>= 1.4.0, < 2.0)
|
63
|
-
rubocop-config-umbrellio (0.81.0.78)
|
64
|
-
rubocop (= 0.81.0)
|
65
|
-
rubocop-performance (= 1.5.2)
|
66
|
-
rubocop-rails (= 2.5.0)
|
67
|
-
rubocop-rspec (= 1.38.1)
|
68
|
-
rubocop-performance (1.5.2)
|
69
|
-
rubocop (>= 0.71.0)
|
70
|
-
rubocop-rails (2.5.0)
|
71
|
-
activesupport
|
72
|
-
rack (>= 1.1)
|
73
|
-
rubocop (>= 0.72.0)
|
74
|
-
rubocop-rspec (1.38.1)
|
75
|
-
rubocop (>= 0.68.1)
|
76
|
-
ruby-progressbar (1.10.1)
|
77
|
-
simplecov (0.18.5)
|
78
|
-
docile (~> 1.1)
|
79
|
-
simplecov-html (~> 0.11)
|
80
|
-
simplecov-html (0.12.2)
|
81
|
-
simplecov-lcov (0.8.0)
|
82
|
-
thor (1.0.1)
|
83
|
-
thread_safe (0.3.6)
|
84
|
-
tzinfo (1.2.7)
|
85
|
-
thread_safe (~> 0.1)
|
86
|
-
unicode-display_width (1.7.0)
|
87
|
-
zeitwerk (2.3.0)
|
88
|
-
|
89
|
-
PLATFORMS
|
90
|
-
ruby
|
91
|
-
|
92
|
-
DEPENDENCIES
|
93
|
-
bundler
|
94
|
-
bundler-audit
|
95
|
-
ci-helper!
|
96
|
-
pry
|
97
|
-
rake
|
98
|
-
rspec
|
99
|
-
rubocop-config-umbrellio
|
100
|
-
simplecov
|
101
|
-
simplecov-lcov
|
102
|
-
|
103
|
-
BUNDLED WITH
|
104
|
-
2.1.4
|