ci-helper 0.1.1 → 0.2.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 +4 -4
- data/.github/workflows/ruby.yml +2 -0
- data/Gemfile.lock +6 -6
- data/README.md +105 -9
- data/lib/ci_helper/commands.rb +5 -0
- data/lib/ci_helper/commands/bundler_audit.rb +2 -2
- data/lib/ci_helper/commands/check_spec_suffixes.rb +40 -0
- data/lib/ci_helper/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 16a693137d6056e1974c2a2d23200ef231fa4f47daf5089e7d864b4d5a000c8f
|
|
4
|
+
data.tar.gz: bb295befcb67ffadbc7bee5aa27fd741aae1ceb086074eeefa31e954fc3a4b2a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3b45bbdc2a858c9ed54f5f239cf901907fec77daf441c5df537cf2b733e9ce5ba4292c9b527ff67cb761e54163fc9dd0481413f112ea1742d285f9f2de5a3dad
|
|
7
|
+
data.tar.gz: 4bc6630a050a3c37143cedcf22ca7c6328fc3603cca3d6f9a4d04b59d5c402c0648ccc72de7fa2a4d414d7aa0c93de612233c99a0b4424f516fc7a091388fd7c
|
data/.github/workflows/ruby.yml
CHANGED
|
@@ -33,6 +33,8 @@ jobs:
|
|
|
33
33
|
run: bundle exec rake install
|
|
34
34
|
- name: Run Linter
|
|
35
35
|
run: ci-helper RubocopLint
|
|
36
|
+
- name: Check missed spec suffixes
|
|
37
|
+
run: ci-helper CheckSpecSuffixes --extra-paths spec/*.rb --ignored-paths spec/*_helper.rb
|
|
36
38
|
- name: Run specs
|
|
37
39
|
run: ci-helper RunSpecs
|
|
38
40
|
- name: Audit
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
ci-helper (0.
|
|
4
|
+
ci-helper (0.2.0)
|
|
5
5
|
colorize (~> 0.8)
|
|
6
6
|
dry-inflector (~> 0.2)
|
|
7
7
|
|
|
@@ -15,9 +15,9 @@ GEM
|
|
|
15
15
|
tzinfo (~> 1.1)
|
|
16
16
|
zeitwerk (~> 2.2, >= 2.2.2)
|
|
17
17
|
ast (2.4.1)
|
|
18
|
-
bundler-audit (0.
|
|
18
|
+
bundler-audit (0.7.0.1)
|
|
19
19
|
bundler (>= 1.2.0, < 3)
|
|
20
|
-
thor (
|
|
20
|
+
thor (>= 0.18, < 2)
|
|
21
21
|
coderay (1.1.3)
|
|
22
22
|
colorize (0.8.1)
|
|
23
23
|
concurrent-ruby (1.1.6)
|
|
@@ -29,13 +29,13 @@ GEM
|
|
|
29
29
|
jaro_winkler (1.5.4)
|
|
30
30
|
method_source (1.0.0)
|
|
31
31
|
minitest (5.14.1)
|
|
32
|
-
parallel (1.19.
|
|
32
|
+
parallel (1.19.2)
|
|
33
33
|
parser (2.7.1.3)
|
|
34
34
|
ast (~> 2.4.0)
|
|
35
35
|
pry (0.13.1)
|
|
36
36
|
coderay (~> 1.1)
|
|
37
37
|
method_source (~> 1.0)
|
|
38
|
-
rack (2.2.
|
|
38
|
+
rack (2.2.3)
|
|
39
39
|
rainbow (3.0.0)
|
|
40
40
|
rake (13.0.1)
|
|
41
41
|
rexml (3.2.4)
|
|
@@ -79,7 +79,7 @@ GEM
|
|
|
79
79
|
simplecov-html (~> 0.11)
|
|
80
80
|
simplecov-html (0.12.2)
|
|
81
81
|
simplecov-lcov (0.8.0)
|
|
82
|
-
thor (0.
|
|
82
|
+
thor (1.0.1)
|
|
83
83
|
thread_safe (0.3.6)
|
|
84
84
|
tzinfo (1.2.7)
|
|
85
85
|
thread_safe (~> 0.1)
|
data/README.md
CHANGED
|
@@ -1,26 +1,114 @@
|
|
|
1
|
-
# CIHelper [](https://github.com/umbrellio/ci_helper/actions) [](https://coveralls.io/github/umbrellio/ci_helper?branch=master)
|
|
2
|
-
|
|
3
|
-
Documentation about gem here.
|
|
1
|
+
# CIHelper [](https://github.com/umbrellio/ci_helper/actions) [](https://coveralls.io/github/umbrellio/ci_helper?branch=master) [](https://badge.fury.io/rb/ci-helper)
|
|
4
2
|
|
|
5
3
|
## Installation
|
|
6
4
|
|
|
7
5
|
Add this line to your application's Gemfile:
|
|
8
6
|
|
|
9
7
|
```ruby
|
|
10
|
-
gem
|
|
8
|
+
gem "ci-helper", require: false
|
|
11
9
|
```
|
|
12
10
|
|
|
13
11
|
And then execute:
|
|
12
|
+
```bash
|
|
13
|
+
$ bundle install
|
|
14
|
+
```
|
|
15
|
+
Or install it yourself as:
|
|
16
|
+
```bash
|
|
17
|
+
$ gem install ci_helper
|
|
18
|
+
```
|
|
14
19
|
|
|
15
|
-
|
|
20
|
+
## Usage
|
|
16
21
|
|
|
17
|
-
|
|
22
|
+
### Command Line
|
|
18
23
|
|
|
19
|
-
|
|
24
|
+
You can use this gem as command line utility. For example, to lint project by rubocop,
|
|
25
|
+
execute the following command in the project root:
|
|
26
|
+
```bash
|
|
27
|
+
$ ci-helper RubocopLint # Here's RubocopLint is a command
|
|
28
|
+
```
|
|
20
29
|
|
|
21
|
-
|
|
30
|
+
A command can accept list of options (parameters). Option values are passed through flags.
|
|
31
|
+
For example, the BundlerAudit command accepts the ignored_advisories option
|
|
32
|
+
You can set a value of this option by setting the flag `--ignored-advisories ignored-advisory`.
|
|
33
|
+
It should be noted that all hyphens in flag names are automatically replaced with underscores.
|
|
34
|
+
```bash
|
|
35
|
+
$ ci-helper BundlerAudit --ignored-advisories first,second
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
List of available commands:
|
|
39
|
+
|
|
40
|
+
* **BundlerAudit** — executes `bundler-audit`. Accepted flags: `--ignored-advisories`.
|
|
41
|
+
* `--ignored-advisories [values]` — accepts advisory codes, delimited by comma.
|
|
42
|
+
* **CheckDBDevelopment** — executes rails db commands (`db:drop`, `db:create`, `db:migrate`)
|
|
43
|
+
and seeds database. Does not accept flags.
|
|
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.
|
|
47
|
+
* **RubocopLint** — executes rubocop linter. Does not accept flags.
|
|
48
|
+
* **RunSpecs** — executes `rspec` in project root.
|
|
49
|
+
Accepted flags: `--node-index`, `node-total`, `with-database`, `split-resultset`.
|
|
50
|
+
* `--node-index` — if you run specs in parallel in CI, then you might use this flag.
|
|
51
|
+
* `--node-total` — if you run specs in parallel in CI, then you might use this flag.
|
|
52
|
+
* `--with-database` — if you want to prepare database before executing specs,
|
|
53
|
+
you should set this flag to `true`.
|
|
54
|
+
* `--split-resultset` — if you run specs in parallel in CI,
|
|
55
|
+
then you might use this flag to `true`. If this flag set to true,
|
|
56
|
+
final `.resultset.json` will be renamed to `.resultset.#{node_index}.json`
|
|
57
|
+
* **CheckSpecSuffixes** — checks specs in the spec subdirectories for `_spec` suffix,
|
|
58
|
+
by default ignores directories `support`, `factories` and files with `context` suffix.
|
|
59
|
+
Accepted flags: `--extra_paths`, `--ignored_paths`.
|
|
60
|
+
* `--extra-paths [values]` - accepts additional path patterns that should be scanned,
|
|
61
|
+
delimited by coma.
|
|
62
|
+
* `--ignored-paths [values]` - accepts path patterns that should be ignored,
|
|
63
|
+
delimited by coma.
|
|
64
|
+
|
|
65
|
+
### Script
|
|
66
|
+
|
|
67
|
+
Also, you can write your own script, which can executes this commands by calling classes:
|
|
68
|
+
`CIHelper::Commands::#{command_name}`. For example,
|
|
69
|
+
if you want to execute `RunSpecs` command in your script, you can write following lines:
|
|
70
|
+
```ruby
|
|
71
|
+
begin
|
|
72
|
+
CIHelper::Commands::RunSpecs.call!(with_database: "true") # returned value is exit code.
|
|
73
|
+
rescue CIHelper::Commands::Error => e # Command raise error with this class if something went wrong.
|
|
74
|
+
abort e.message
|
|
75
|
+
end
|
|
76
|
+
```
|
|
22
77
|
|
|
23
|
-
|
|
78
|
+
## Adding your own commands
|
|
79
|
+
|
|
80
|
+
You can write plugins (gems) that add new commands.
|
|
81
|
+
You just need create gem with following structure:
|
|
82
|
+
```
|
|
83
|
+
- lib
|
|
84
|
+
- ci_helper
|
|
85
|
+
- commands
|
|
86
|
+
- cool_command.rb
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Where your `CoolCoomand` class may look something like this:
|
|
90
|
+
```ruby
|
|
91
|
+
module CIHelper
|
|
92
|
+
module Commands
|
|
93
|
+
class CoolCommand < BaseCommand
|
|
94
|
+
def call
|
|
95
|
+
execute("ls #{options[:cool_options]}")
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Then you add your gem to a Gemfile:
|
|
103
|
+
```ruby
|
|
104
|
+
gem "ci-helper", require: false
|
|
105
|
+
gem "ci-helper-plugin-gem", require: false
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
And now, you can use your custom command with command line tool:
|
|
109
|
+
```bash
|
|
110
|
+
$ ci-helper CoolCommand --cool-options option_value
|
|
111
|
+
```
|
|
24
112
|
|
|
25
113
|
## Contributing
|
|
26
114
|
|
|
@@ -30,3 +118,11 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/umbrel
|
|
|
30
118
|
## License
|
|
31
119
|
|
|
32
120
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
121
|
+
|
|
122
|
+
## Authors
|
|
123
|
+
|
|
124
|
+
Created by Ivan Chernov.
|
|
125
|
+
|
|
126
|
+
<a href="https://github.com/umbrellio/">
|
|
127
|
+
<img style="float: left;" src="https://umbrellio.github.io/Umbrellio/supported_by_umbrellio.svg" alt="Supported by Umbrellio" width="439" height="72">
|
|
128
|
+
</a>
|
data/lib/ci_helper/commands.rb
CHANGED
|
@@ -11,14 +11,14 @@ module CIHelper
|
|
|
11
11
|
|
|
12
12
|
def audit_cmd
|
|
13
13
|
(+"bundle exec bundler-audit check --update").tap do |audit_cmd|
|
|
14
|
-
if ignored_advisories
|
|
14
|
+
if ignored_advisories.any?
|
|
15
15
|
audit_cmd << " --ignore #{ignored_advisories.join(" ")}"
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
def ignored_advisories
|
|
21
|
-
@ignored_advisories ||=
|
|
21
|
+
@ignored_advisories ||= plural_option(:ignored_advisories)
|
|
22
22
|
end
|
|
23
23
|
end
|
|
24
24
|
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module CIHelper
|
|
4
|
+
module Commands
|
|
5
|
+
class CheckSpecSuffixes < BaseCommand
|
|
6
|
+
def call
|
|
7
|
+
paths = target_paths.reject { |path| path.end_with?("_spec.rb") }
|
|
8
|
+
fail!("Detected specs without _spec suffix: #{paths.join(" ")}") if paths.any?
|
|
9
|
+
0
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
private
|
|
13
|
+
|
|
14
|
+
def target_paths
|
|
15
|
+
spec_paths + extra_paths - ignored_paths
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def spec_paths
|
|
19
|
+
base_paths.select do |path|
|
|
20
|
+
next if path.start_with?("spec/support")
|
|
21
|
+
next if path.start_with?("spec/factories")
|
|
22
|
+
next if path.end_with?("context.rb")
|
|
23
|
+
true
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def base_paths
|
|
28
|
+
Dir["spec/*/**/*.rb"]
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def extra_paths
|
|
32
|
+
@extra_paths ||= plural_option(:extra_paths).flat_map { |path| Dir[path] }
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def ignored_paths
|
|
36
|
+
@ignored_paths ||= plural_option(:ignored_paths).flat_map { |path| Dir[path] }
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
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.2.0
|
|
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-08-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: colorize
|
|
@@ -178,6 +178,7 @@ files:
|
|
|
178
178
|
- lib/ci_helper/commands/bundler_audit.rb
|
|
179
179
|
- lib/ci_helper/commands/check_db_development.rb
|
|
180
180
|
- lib/ci_helper/commands/check_db_rollback.rb
|
|
181
|
+
- lib/ci_helper/commands/check_spec_suffixes.rb
|
|
181
182
|
- lib/ci_helper/commands/rubocop_lint.rb
|
|
182
183
|
- lib/ci_helper/commands/run_specs.rb
|
|
183
184
|
- lib/ci_helper/tools/colorize.rb
|