ci-helper 0.10.1 → 0.10.2
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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +20 -12
- data/lib/ci_helper/commands/run_specs.rb +3 -3
- data/lib/ci_helper/commands.rb +16 -6
- data/lib/ci_helper/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: adbebe67fd86fd92ee630a21009a3c42fe6d4be32d9ebb773539cc92964bab77
|
|
4
|
+
data.tar.gz: ce5e94594b8392d5f0d7b1de9f4fd5c548d5598c0097192a98eb6718f8478493
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b98ad7e1d9b1cfa5a740c01ad854c697b65d41e070dbb132b5da44af2a9ada24140edbf80dca852fd9e0e3132a9ec911c8902dcf319d3120a16e2995eda810b1
|
|
7
|
+
data.tar.gz: 7eb7b22ffacf1b8f0951c8b116edfa67ccd2f55c244626e6d2484332c3dc4de891a7eff91bf0008cf3893be3f9474305076952b1c5ad6c5ce3b70b4b95c0a5fd
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -14,7 +14,7 @@ $ bundle install
|
|
|
14
14
|
```
|
|
15
15
|
Or install it yourself as:
|
|
16
16
|
```bash
|
|
17
|
-
$ gem install
|
|
17
|
+
$ gem install ci-helper
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
## Usage
|
|
@@ -42,28 +42,36 @@ List of available commands:
|
|
|
42
42
|
* **BundlerAudit** — executes `bundler-audit`. Accepted flags: `--ignored-advisories`.
|
|
43
43
|
* `--ignored-advisories [values]` — accepts advisory codes, delimited by comma.
|
|
44
44
|
* **CheckDBDevelopment** — executes rails db commands (`db:drop`, `db:create`, `db:migrate`)
|
|
45
|
-
and seeds database.
|
|
45
|
+
and seeds database. Accepted flags: `--with-clickhouse`.
|
|
46
|
+
* `--with-clickhouse` — if set to `true`, also creates and migrates the ClickHouse
|
|
47
|
+
database (`ch:create`, `ch:migrate`).
|
|
46
48
|
* **CheckDBRollback** — executes rails db commands with additional command
|
|
47
49
|
`db:rollback_new_migrations`, which rollbacks migrations, added in tested branch.
|
|
48
|
-
|
|
50
|
+
Gem provides this rake task, but only for `Sequel`.
|
|
49
51
|
If you want to use `ActiveRecord::Migrator`, you'll have to write rake task by your own.
|
|
52
|
+
Accepted flags: `--with-clickhouse`.
|
|
53
|
+
* `--with-clickhouse` — if set to `true`, runs the same create/rollback/migrate cycle
|
|
54
|
+
for the ClickHouse database (`ch:create`, `ch:migrate`, `ch:rollback_new_migrations`).
|
|
50
55
|
* **RubocopLint** — executes rubocop linter. Does not accept flags.
|
|
51
56
|
* **RunSpecs** — executes `rspec` in project root.
|
|
52
|
-
Accepted flags: `--node-index`,
|
|
57
|
+
Accepted flags: `--node-index`, `--node-total`, `--with-database`, `--with-clickhouse`,
|
|
58
|
+
`--split-resultset`.
|
|
53
59
|
* `--node-index` — if you run specs in parallel in CI, then you might use this flag.
|
|
54
60
|
* `--node-total` — if you run specs in parallel in CI, then you might use this flag.
|
|
55
61
|
* `--with-database` — if you want to prepare database before executing specs,
|
|
56
62
|
you should set this flag to `true`.
|
|
63
|
+
* `--with-clickhouse` — if you want to prepare the ClickHouse database before executing
|
|
64
|
+
specs, you should set this flag to `true`.
|
|
57
65
|
* `--split-resultset` — if you run specs in parallel in CI,
|
|
58
66
|
then you might use this flag to `true`. If this flag set to true,
|
|
59
|
-
final `.resultset.json` will be renamed to
|
|
67
|
+
final `.resultset.json` will be renamed to `resultset.#{node_index}.json`
|
|
60
68
|
* **CheckSpecSuffixes** — checks specs in the spec subdirectories for `_spec` suffix,
|
|
61
69
|
by default ignores directories `support`, `factories` and files with `context` suffix.
|
|
62
|
-
Accepted flags: `--
|
|
70
|
+
Accepted flags: `--extra-paths`, `--ignored-paths`.
|
|
63
71
|
* `--extra-paths [values]` - accepts additional path patterns that should be scanned,
|
|
64
|
-
delimited by
|
|
72
|
+
delimited by comma.
|
|
65
73
|
* `--ignored-paths [values]` - accepts path patterns that should be ignored,
|
|
66
|
-
delimited by
|
|
74
|
+
delimited by comma.
|
|
67
75
|
* **CheckCoverage** — checks coverage by executing `SimpleCov::collate`.
|
|
68
76
|
Accepted flags: `--split-resultset`, `--setup-file-path`.
|
|
69
77
|
* `--split-resultset` — if you execute command `RunSpecs` with `--split-resultset true`,
|
|
@@ -73,17 +81,17 @@ List of available commands:
|
|
|
73
81
|
* `--setup-file-path` — relative path to your `.rb` file, which setups `SimpleCov`.
|
|
74
82
|
Usually it is `spec_helper.rb`.
|
|
75
83
|
* **CheckSidekiqSchedulerConfig** — checks `sidekiq_scheduler` config by trying to resolve jobs constants via `rails runner`.
|
|
76
|
-
Accepted flags: `--config-path
|
|
84
|
+
Accepted flags: `--config-path`, `--with-database`.
|
|
77
85
|
* `--config-path` — relative path to your config yaml file with schedule.
|
|
78
86
|
Usually it is `config/sidekiq_scheduler.yml`.
|
|
79
|
-
* `--with-database` — if you want to prepare database before
|
|
87
|
+
* `--with-database` — if you want to prepare the database before resolving job constants,
|
|
80
88
|
you should set this flag to `true`.
|
|
81
89
|
|
|
82
90
|
### Rake Tasks
|
|
83
91
|
|
|
84
92
|
As you can see, some commands use generic rake tasks. To make tasks available in your application,
|
|
85
93
|
you need to require the file `ci_helper/railtie`. Also, you can require it directly in `Gemfile`:
|
|
86
|
-
`gem "ci-helper", require: "ci_helper/railtie, group: :test`.
|
|
94
|
+
`gem "ci-helper", require: "ci_helper/railtie", group: :test`.
|
|
87
95
|
Or if you haven't set `require` option to `false`, rake tasks loads automatically.
|
|
88
96
|
|
|
89
97
|
### Script
|
|
@@ -110,7 +118,7 @@ You just need create gem with following structure:
|
|
|
110
118
|
- cool_command.rb
|
|
111
119
|
```
|
|
112
120
|
|
|
113
|
-
Where your `
|
|
121
|
+
Where your `CoolCommand` class may look something like this:
|
|
114
122
|
```ruby
|
|
115
123
|
module CIHelper
|
|
116
124
|
module Commands
|
|
@@ -50,10 +50,10 @@ module CIHelper
|
|
|
50
50
|
begin
|
|
51
51
|
execute(
|
|
52
52
|
"bundle exec rspec --dry-run --format=json --out #{Shellwords.escape(output_file)}",
|
|
53
|
+
capture: true,
|
|
53
54
|
)
|
|
54
|
-
rescue Error
|
|
55
|
-
|
|
56
|
-
fail!("RSpec dry-run failed. Output file contents:\n#{output}")
|
|
55
|
+
rescue Error => error
|
|
56
|
+
fail!("RSpec dry-run failed:\n#{error.output}")
|
|
57
57
|
end
|
|
58
58
|
JSON.parse(File.read(output_file)).fetch("examples").map { |e| e.fetch("id") }
|
|
59
59
|
end
|
data/lib/ci_helper/commands.rb
CHANGED
|
@@ -2,7 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
module CIHelper
|
|
4
4
|
module Commands
|
|
5
|
-
class Error < StandardError
|
|
5
|
+
class Error < StandardError
|
|
6
|
+
attr_reader :output
|
|
7
|
+
|
|
8
|
+
def initialize(message, output: nil)
|
|
9
|
+
super(message)
|
|
10
|
+
@output = output
|
|
11
|
+
end
|
|
12
|
+
end
|
|
6
13
|
|
|
7
14
|
class BaseCommand
|
|
8
15
|
class << self
|
|
@@ -26,16 +33,19 @@ module CIHelper
|
|
|
26
33
|
execute(*commands)
|
|
27
34
|
end
|
|
28
35
|
|
|
29
|
-
def execute(*commands)
|
|
36
|
+
def execute(*commands, capture: false)
|
|
30
37
|
command = commands.join(" && ")
|
|
31
38
|
|
|
32
39
|
process_stdout.puts(Tools::Colorize.command(command))
|
|
33
40
|
|
|
41
|
+
captured = +"" if capture
|
|
34
42
|
Open3.popen2e(command) do |_stdin, stdout, thread|
|
|
35
|
-
stdout.each_char { |char| process_stdout.print(char) }
|
|
43
|
+
stdout.each_char { |char| capture ? captured << char : process_stdout.print(char) }
|
|
36
44
|
exit_code = thread.value.exitstatus
|
|
37
45
|
|
|
38
|
-
|
|
46
|
+
unless exit_code.zero?
|
|
47
|
+
fail!("Bad exit code #{exit_code} for command #{command.inspect}", output: captured)
|
|
48
|
+
end
|
|
39
49
|
0
|
|
40
50
|
end
|
|
41
51
|
end
|
|
@@ -54,8 +64,8 @@ module CIHelper
|
|
|
54
64
|
execute_with_env("bundle exec rake ch:create ch:migrate")
|
|
55
65
|
end
|
|
56
66
|
|
|
57
|
-
def fail!(message)
|
|
58
|
-
raise Error,
|
|
67
|
+
def fail!(message, output: nil)
|
|
68
|
+
raise Error.new(message, output: output)
|
|
59
69
|
end
|
|
60
70
|
|
|
61
71
|
def boolean_option?(key)
|
data/lib/ci_helper/version.rb
CHANGED