ci-helper 0.2.1 → 0.3.1

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: 74d9c6d91a9c591011f272a5a7a8ee39845fba3849a4f47a3392c966fff34de4
4
- data.tar.gz: 49c4c6e8490934d3f4c209a4f9a55b812165b749de6de98e69fb0bcfce48f449
3
+ metadata.gz: 3a3609beaea3add57fcaf6627b214509e48913d1751eef0ef87b27b5d30933ab
4
+ data.tar.gz: 0be1e0e77967f0b9f7d76be546eacce22c3b06f09aa1a3b0d163621c38bc4418
5
5
  SHA512:
6
- metadata.gz: fc4222158600e219585b25ed5e178b459ecc0f705524ed5a805a460d9816747b0b80d1310643ac9645952d37de92b2d6f61e0d766d1def41c0c508293d83f6ec
7
- data.tar.gz: 60d4a95181884382ef2246b303f79abb124b2c40a5f561dd34d99eeca43a23c169db09545badcdc1e4acd3d26b5dba777c6ab6e8e24192c231f7670b63d01adf
6
+ metadata.gz: ccb2b6707629e1c670853009fb5363122213eee7eabc5b860a6130088a9f4b10b1a4bc9c18c8c50c40b78ace7a17b6b46e2da6a9fefe0e5edd0847ef7eb36e29
7
+ data.tar.gz: b548c182c810cea40172b22762179a014b86ca075fa1be0b1328e22c5de4ad55a81dd3f58d9ff9babd840d3de22b39df625f38f34e5fe915417c78af2c3301f3
@@ -13,8 +13,11 @@ on:
13
13
  pull_request:
14
14
  branches: [ master ]
15
15
 
16
+ env:
17
+ FULL_COVERAGE_CHECK: true
18
+
16
19
  jobs:
17
- test:
20
+ test-latest:
18
21
 
19
22
  runs-on: ubuntu-latest
20
23
 
@@ -24,7 +27,7 @@ jobs:
24
27
  # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
25
28
  # change this to (see https://github.com/ruby/setup-ruby#versioning):
26
29
  # uses: ruby/setup-ruby@v1
27
- uses: ruby/setup-ruby@ec106b438a1ff6ff109590de34ddc62c540232e0
30
+ uses: ruby/setup-ruby@v1
28
31
  with:
29
32
  ruby-version: 2.7
30
33
  - name: Install dependencies
@@ -43,3 +46,39 @@ jobs:
43
46
  uses: coverallsapp/github-action@v1.1.1
44
47
  with:
45
48
  github-token: ${{ secrets.GITHUB_TOKEN }}
49
+ specs-for-26:
50
+ runs-on: ubuntu-latest
51
+
52
+ steps:
53
+ - uses: actions/checkout@v2
54
+ - name: Set up Ruby
55
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
56
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
57
+ # uses: ruby/setup-ruby@v1
58
+ uses: ruby/setup-ruby@v1
59
+ with:
60
+ ruby-version: 2.6
61
+ - name: Install dependencies
62
+ run: bundle install && gem install bundler-audit
63
+ - name: Build and install gem to systems gems
64
+ run: bundle exec rake install
65
+ - name: Run specs
66
+ run: ci-helper RunSpecs
67
+ specs-for-25:
68
+ runs-on: ubuntu-latest
69
+
70
+ steps:
71
+ - uses: actions/checkout@v2
72
+ - name: Set up Ruby
73
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
74
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
75
+ # uses: ruby/setup-ruby@v1
76
+ uses: ruby/setup-ruby@v1
77
+ with:
78
+ ruby-version: 2.5
79
+ - name: Install dependencies
80
+ run: bundle install && gem install bundler-audit
81
+ - name: Build and install gem to systems gems
82
+ run: bundle exec rake install
83
+ - name: Run specs
84
+ run: ci-helper RunSpecs
data/.gitignore CHANGED
@@ -6,3 +6,5 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+
10
+ Gemfile.lock
@@ -10,3 +10,7 @@ Naming/MethodParameterName:
10
10
 
11
11
  RSpec/EmptyLineAfterHook:
12
12
  Enabled: false
13
+
14
+ Naming/FileName:
15
+ Exclude:
16
+ - lib/ci-helper.rb
data/README.md CHANGED
@@ -42,11 +42,12 @@ 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
- added in tested branch. Does not accept flags.
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
- Accepted flags: `--node-index`, `node-total`, `with-database`, `split-resultset`.
50
+ Accepted flags: `--node-index`, `node-total`, `with-database`, `split-resultset`.
50
51
  * `--node-index` — if you run specs in parallel in CI, then you might use this flag.
51
52
  * `--node-total` — if you run specs in parallel in CI, then you might use this flag.
52
53
  * `--with-database` — if you want to prepare database before executing specs,
@@ -61,6 +62,20 @@ Accepted flags: `--node-index`, `node-total`, `with-database`, `split-resultset`
61
62
  delimited by coma.
62
63
  * `--ignored-paths [values]` - accepts path patterns that should be ignored,
63
64
  delimited by coma.
65
+ * **CheckCoverage** — checks coverage by executing `SimpleCov::collate`.
66
+ You should set `SimpleCov::minimum_coverage` in your `spec_helper.rb` file.
67
+ Accepted flags: `--split-resultset`.
68
+ * `--split-resultset` — if you execute command `RunSpecs` with `--split-resultset true`,
69
+ you also should set this flag to `true`. If this flag set to `true`, final coverage will be
70
+ calculated by merging results in all files, matching the mask `coverage/resultset.*.json`.
71
+ By default final coverage is calculated using result from `coverage/.resultset.json`.
72
+
73
+ ### Rake Tasks
74
+
75
+ As you can see, some commands use generic rake tasks. To make tasks available in your application,
76
+ you need to require the file `ci_helper/railtie`. Also, you can require it directly in `Gemfile`:
77
+ `gem "ci-helper", require: "ci_helper/railtie, group: :test`.
78
+ Or if you haven't set `require` option to `false`, rake tasks loads automatically.
64
79
 
65
80
  ### Script
66
81
 
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.description = "CIHelper is a gem with Continuous Integration helpers for Ruby"
13
13
  spec.homepage = "https://github.com/umbrellio/ci_helper"
14
14
  spec.license = "MIT"
15
- spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
15
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
16
16
 
17
17
  spec.metadata["homepage_uri"] = spec.homepage
18
18
  spec.metadata["source_code_uri"] = "https://github.com/umbrellio/ci_helper"
@@ -26,6 +26,7 @@ Gem::Specification.new do |spec|
26
26
 
27
27
  spec.add_runtime_dependency "colorize", "~> 0.8"
28
28
  spec.add_runtime_dependency "dry-inflector", "~> 0.2"
29
+ spec.add_runtime_dependency "umbrellio-sequel-plugins", "~> 0.4"
29
30
 
30
31
  spec.add_development_dependency "bundler"
31
32
  spec.add_development_dependency "bundler-audit"
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "./ci_helper"
@@ -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,6 @@ require "ci_helper/tools/colorize"
14
17
  require "ci_helper/tools/inflector"
15
18
  require "ci_helper/version"
16
19
 
17
- module CIHelper
18
- end
20
+ # :nocov:
21
+ require "ci_helper/railtie" if defined?(Rails)
22
+ # :nocov:
@@ -12,7 +12,7 @@ module CIHelper
12
12
 
13
13
  # :nocov:
14
14
  def process_stdout
15
- @process_stdout ||= STDOUT
15
+ @process_stdout ||= $stdout
16
16
  end
17
17
  # :nocov:
18
18
  end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "simplecov"
4
+
5
+ module CIHelper
6
+ module Commands
7
+ class CheckCoverage < BaseCommand
8
+ def call
9
+ ::SimpleCov.collate(files)
10
+ 0
11
+ end
12
+
13
+ private
14
+
15
+ def files
16
+ return path.glob("coverage/resultset.*.json") if split_resultset?
17
+
18
+ [path.join("coverage/.resultset.json")]
19
+ end
20
+
21
+ def split_resultset?
22
+ options[:split_resultset] == "true"
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CIHelper
4
+ class Railtie < Rails::Railtie
5
+ rake_tasks do
6
+ load "tasks/sequel_management.rake"
7
+ end
8
+ end
9
+ end
@@ -5,9 +5,11 @@ module CIHelper
5
5
  class Inflector < Delegator
6
6
  include Singleton
7
7
 
8
+ # rubocop:disable Lint/MissingSuper
8
9
  def initialize
9
10
  @inflector = Dry::Inflector.new { |inflections| inflections.acronym "DB" }
10
11
  end
12
+ # rubocop:enable Lint/MissingSuper
11
13
 
12
14
  def __getobj__
13
15
  @inflector
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CIHelper
4
- VERSION = "0.2.1"
4
+ VERSION = "0.3.1"
5
5
  end
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "logger"
4
+ require "sequel/timestamp_migrator_undo_extension"
5
+
6
+ class SequelManagement
7
+ include Rake::DSL
8
+
9
+ MIGRATIONS_PATH = "db/migrate"
10
+
11
+ def initialize
12
+ self.logger = Logger.new($stdout)
13
+
14
+ define_db_task!
15
+ end
16
+
17
+ private
18
+
19
+ attr_accessor :logger
20
+
21
+ def migrations_path
22
+ self.class::MIGRATIONS_PATH
23
+ end
24
+
25
+ def define_db_task!
26
+ namespace :db do
27
+ desc "Rollback all migrations, which doesn't exist in master branch"
28
+ task rollback_new_migrations: :environment do
29
+ abort "Shouldn't run in production mode!" if Rails.env.production?
30
+
31
+ logger.info "Begin rolling back new migrations"
32
+
33
+ original_migrations = `#{git_command}`.split.map { |path| File.basename(path) }
34
+ migrations_to_rollback = (migrator.applied_migrations - original_migrations).sort.reverse
35
+
36
+ next if migrations_to_rollback.empty?
37
+
38
+ logger.info "Rolling back migrations:"
39
+ logger.info migrations_to_rollback.join("\n")
40
+
41
+ rollback!(migrations_to_rollback)
42
+ end
43
+ end
44
+ end
45
+
46
+ def git_command
47
+ "git ls-tree --name-only origin/master #{migrations_path}/"
48
+ end
49
+
50
+ def migrator
51
+ @migrator ||= begin
52
+ full_path = Rails.root.join(migrations_path)
53
+ Sequel::TimestampMigrator.new(DB, full_path, allow_missing_migration_files: true)
54
+ end
55
+ end
56
+
57
+ def rollback!(migrations)
58
+ migrations.each do |migration|
59
+ migrator.undo(migration.to_i)
60
+ rescue Sequel::Migrator::Error => error
61
+ if error.message.include?("does not exist in the filesystem")
62
+ logger.info error.message
63
+ else
64
+ raise error
65
+ end
66
+ end
67
+ end
68
+ end
69
+
70
+ 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.1
4
+ version: 0.3.1
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-07 00:00:00.000000000 Z
11
+ date: 2020-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: umbrellio-sequel-plugins
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.4'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.4'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: bundler
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -164,7 +178,6 @@ files:
164
178
  - ".rspec"
165
179
  - ".rubocop.yml"
166
180
  - Gemfile
167
- - Gemfile.lock
168
181
  - LICENSE.txt
169
182
  - README.md
170
183
  - Rakefile
@@ -172,18 +185,22 @@ files:
172
185
  - bin/setup
173
186
  - ci_helper.gemspec
174
187
  - exe/ci-helper
188
+ - lib/ci-helper.rb
175
189
  - lib/ci_helper.rb
176
190
  - lib/ci_helper/cli.rb
177
191
  - lib/ci_helper/commands.rb
178
192
  - lib/ci_helper/commands/bundler_audit.rb
193
+ - lib/ci_helper/commands/check_coverage.rb
179
194
  - lib/ci_helper/commands/check_db_development.rb
180
195
  - lib/ci_helper/commands/check_db_rollback.rb
181
196
  - lib/ci_helper/commands/check_spec_suffixes.rb
182
197
  - lib/ci_helper/commands/rubocop_lint.rb
183
198
  - lib/ci_helper/commands/run_specs.rb
199
+ - lib/ci_helper/railtie.rb
184
200
  - lib/ci_helper/tools/colorize.rb
185
201
  - lib/ci_helper/tools/inflector.rb
186
202
  - lib/ci_helper/version.rb
203
+ - lib/tasks/sequel_management.rake
187
204
  homepage: https://github.com/umbrellio/ci_helper
188
205
  licenses:
189
206
  - MIT
@@ -198,14 +215,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
198
215
  requirements:
199
216
  - - ">="
200
217
  - !ruby/object:Gem::Version
201
- version: 2.7.0
218
+ version: 2.5.0
202
219
  required_rubygems_version: !ruby/object:Gem::Requirement
203
220
  requirements:
204
221
  - - ">="
205
222
  - !ruby/object:Gem::Version
206
223
  version: '0'
207
224
  requirements: []
208
- rubygems_version: 3.1.3
225
+ rubygems_version: 3.1.4
209
226
  signing_key:
210
227
  specification_version: 4
211
228
  summary: Continuous Integration helpers for Ruby
@@ -1,104 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- ci-helper (0.2.1)
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