ci-helper 0.2.6 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -1
- data/lib/ci_helper.rb +2 -0
- data/lib/ci_helper/commands.rb +5 -1
- data/lib/ci_helper/commands/check_coverage.rb +32 -0
- data/lib/ci_helper/commands/check_sidekiq_scheduler_config.rb +44 -0
- data/lib/ci_helper/commands/run_specs.rb +2 -2
- data/lib/ci_helper/tools/inflector.rb +2 -0
- data/lib/ci_helper/version.rb +1 -1
- data/lib/tasks/sequel_management.rake +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b8b84c09ceed862107e1dab8edc94376d88c9dc445edee953d22b098a9c1aec
|
4
|
+
data.tar.gz: 9dc1e0f8108facb2ef0f71396aa87c6e9989679483bb799aaeb96d762908be11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '01491ffa280587336bff05506b3b1bb0261c3b33c70cf2f13467f6cc2e052e70518c82ced20a4ae96d17cd7b8d4f61753d786d42c75ff96c3adbc55ada9ce004'
|
7
|
+
data.tar.gz: ac0468a7cd7aad077cfa8f35b351890fec936f888748d08d91d8fa5dca4a536a1be409ace409a9ce806995e83629be4014b7fce01b5eaea902eef5b6bb60211b
|
data/README.md
CHANGED
@@ -47,7 +47,7 @@ List of available commands:
|
|
47
47
|
If you want to use `ActiveRecord::Migrator`, you'll have to write rake task by your own.
|
48
48
|
* **RubocopLint** — executes rubocop linter. Does not accept flags.
|
49
49
|
* **RunSpecs** — executes `rspec` in project root.
|
50
|
-
Accepted flags: `--node-index`, `node-total`, `with-database`, `split-resultset`.
|
50
|
+
Accepted flags: `--node-index`, `node-total`, `with-database`, `split-resultset`.
|
51
51
|
* `--node-index` — if you run specs in parallel in CI, then you might use this flag.
|
52
52
|
* `--node-total` — if you run specs in parallel in CI, then you might use this flag.
|
53
53
|
* `--with-database` — if you want to prepare database before executing specs,
|
@@ -62,6 +62,20 @@ Accepted flags: `--node-index`, `node-total`, `with-database`, `split-resultset`
|
|
62
62
|
delimited by coma.
|
63
63
|
* `--ignored-paths [values]` - accepts path patterns that should be ignored,
|
64
64
|
delimited by coma.
|
65
|
+
* **CheckCoverage** — checks coverage by executing `SimpleCov::collate`.
|
66
|
+
Accepted flags: `--split-resultset`, `--setup-file-path`.
|
67
|
+
* `--split-resultset` — if you execute command `RunSpecs` with `--split-resultset true`,
|
68
|
+
you also should set this flag to `true`. If this flag set to `true`, final coverage will be
|
69
|
+
calculated by merging results in all files, matching the mask `coverage/resultset.*.json`.
|
70
|
+
By default final coverage is calculated using result from `coverage/.resultset.json`.
|
71
|
+
* `--setup-file-path` — relative path to your `.rb` file, which setups `SimpleCov`.
|
72
|
+
Usually it is `spec_helper.rb`.
|
73
|
+
* **CheckSidekiqSchedulerConfig** — checks `sidekiq_scheduler` config by trying to resolve jobs constants via `rails runner`.
|
74
|
+
Accepted flags: `--config-path`
|
75
|
+
* `--config-path` — relative path to your config yaml file with schedule.
|
76
|
+
Usually it is `config/sidekiq_scheduler.yml`.
|
77
|
+
* `--with-database` — if you want to prepare database before executing specs,
|
78
|
+
you should set this flag to `true`.
|
65
79
|
|
66
80
|
### Rake Tasks
|
67
81
|
|
data/lib/ci_helper.rb
CHANGED
data/lib/ci_helper/commands.rb
CHANGED
@@ -12,7 +12,7 @@ module CIHelper
|
|
12
12
|
|
13
13
|
# :nocov:
|
14
14
|
def process_stdout
|
15
|
-
@process_stdout ||=
|
15
|
+
@process_stdout ||= $stdout
|
16
16
|
end
|
17
17
|
# :nocov:
|
18
18
|
end
|
@@ -54,6 +54,10 @@ module CIHelper
|
|
54
54
|
raise Error, message
|
55
55
|
end
|
56
56
|
|
57
|
+
def boolean_option(key)
|
58
|
+
options[key] == "true"
|
59
|
+
end
|
60
|
+
|
57
61
|
def plural_option(key)
|
58
62
|
return [] unless options.key?(key)
|
59
63
|
options[key].split(",")
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "simplecov"
|
4
|
+
|
5
|
+
module CIHelper
|
6
|
+
module Commands
|
7
|
+
class CheckCoverage < BaseCommand
|
8
|
+
def call
|
9
|
+
require(path.join(setup_file_path)) unless setup_file_path.nil?
|
10
|
+
|
11
|
+
::SimpleCov.collate(files)
|
12
|
+
0
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def files
|
18
|
+
return path.glob("coverage/resultset.*.json") if split_resultset?
|
19
|
+
|
20
|
+
[path.join("coverage/.resultset.json")]
|
21
|
+
end
|
22
|
+
|
23
|
+
def split_resultset?
|
24
|
+
boolean_option(:split_resultset)
|
25
|
+
end
|
26
|
+
|
27
|
+
def setup_file_path
|
28
|
+
options[:setup_file_path]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "yaml"
|
4
|
+
|
5
|
+
module CIHelper
|
6
|
+
module Commands
|
7
|
+
class CheckSidekiqSchedulerConfig < BaseCommand
|
8
|
+
def call
|
9
|
+
return 0 if job_constants.empty?
|
10
|
+
|
11
|
+
create_and_migrate_database! if with_database?
|
12
|
+
cmd = craft_jobs_const_get_cmd
|
13
|
+
execute_with_rails_runner(cmd)
|
14
|
+
0
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def env
|
20
|
+
:development
|
21
|
+
end
|
22
|
+
|
23
|
+
def execute_with_rails_runner(cmd)
|
24
|
+
execute("bundle exec rails runner '#{cmd}'")
|
25
|
+
end
|
26
|
+
|
27
|
+
def craft_jobs_const_get_cmd
|
28
|
+
"#{job_constants}.each { |x| Object.const_get(x) }"
|
29
|
+
end
|
30
|
+
|
31
|
+
def job_constants
|
32
|
+
@job_constants ||= config.values.reject(&:nil?).flat_map(&:keys).uniq
|
33
|
+
end
|
34
|
+
|
35
|
+
def with_database?
|
36
|
+
boolean_option(:with_database)
|
37
|
+
end
|
38
|
+
|
39
|
+
def config
|
40
|
+
@config ||= YAML.load_file(options[:config_path])
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -37,11 +37,11 @@ module CIHelper
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def with_database?
|
40
|
-
|
40
|
+
boolean_option(:with_database)
|
41
41
|
end
|
42
42
|
|
43
43
|
def split_resultset?
|
44
|
-
|
44
|
+
boolean_option(:split_resultset)
|
45
45
|
end
|
46
46
|
end
|
47
47
|
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
|
data/lib/ci_helper/version.rb
CHANGED
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.
|
4
|
+
version: 0.4.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-
|
11
|
+
date: 2020-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -190,8 +190,10 @@ files:
|
|
190
190
|
- lib/ci_helper/cli.rb
|
191
191
|
- lib/ci_helper/commands.rb
|
192
192
|
- lib/ci_helper/commands/bundler_audit.rb
|
193
|
+
- lib/ci_helper/commands/check_coverage.rb
|
193
194
|
- lib/ci_helper/commands/check_db_development.rb
|
194
195
|
- lib/ci_helper/commands/check_db_rollback.rb
|
196
|
+
- lib/ci_helper/commands/check_sidekiq_scheduler_config.rb
|
195
197
|
- lib/ci_helper/commands/check_spec_suffixes.rb
|
196
198
|
- lib/ci_helper/commands/rubocop_lint.rb
|
197
199
|
- lib/ci_helper/commands/run_specs.rb
|