ci-helper 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 61e68cfd07a49efbe7edeedfd4bb579d5359caa0b6660bf00d6a6f8cd653226b
4
- data.tar.gz: 915c87759e1da667c808d7136e4c3dc5fcf4be1ae81f3476b11b4b006542ecf2
3
+ metadata.gz: e63b9bd4d1eedc9ec6cb16d7ad4889017c70d016aef38309e41bdd9f2766fe5b
4
+ data.tar.gz: d583e5d4938c3c031259062de7977377dd449c554a78ebe10d6bd784fb634d50
5
5
  SHA512:
6
- metadata.gz: 4e8d5ecaa8724f9f44df8606ebd1be1d64fe010e8c5f27947ee5e320b43b782ec97baa0e52c82b51190fcb68ef184c0aaa98e08f0cc31a8a5f51087348626572
7
- data.tar.gz: 5c48c38e8847e5a00d6b987a015d580ee1329b1fc32d9ba84963e677f59cff731eb08ffb6d90578277b82883c28bc7bb50484e129dff4de2445ffa59276925c1
6
+ metadata.gz: 6bc0d44ab1199a98b7384ff617559b66beb6ce9bf6785952a3e48b0ca573756257c0ed54ef2289ffd5fae7118ffc4540e9cd2486918e9a7222839b923a95cd6a
7
+ data.tar.gz: 3b5179eeb48c25ae650598e9a024c80954768ff8c8bc579cd57bf9d7986a9e6e62d22559471287b020f3caf16b7368af2794303dcdd27666da54e7700e6a9d3c
@@ -0,0 +1,51 @@
1
+ name: Test
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ pull_request:
7
+ branches: [master]
8
+
9
+ jobs:
10
+ full-check:
11
+ runs-on: ubuntu-latest
12
+
13
+ steps:
14
+ - uses: actions/checkout@v2
15
+ - uses: ruby/setup-ruby@v1
16
+ with:
17
+ ruby-version: "3.1"
18
+ bundler-cache: true
19
+ - name: Build and install gem to systems gems
20
+ run: bundle exec rake install
21
+ - name: Run Linter
22
+ run: bundle exec ci-helper RubocopLint
23
+ - name: Check missed spec suffixes
24
+ run: bundle exec ci-helper CheckSpecSuffixes --extra-paths spec/*.rb --ignored-paths spec/*_helper.rb
25
+ - name: Run specs
26
+ run: bundle exec ci-helper RunSpecs
27
+ - name: Audit
28
+ run: bundle exec ci-helper BundlerAudit
29
+ - name: Coveralls
30
+ uses: coverallsapp/github-action@master
31
+ with:
32
+ github-token: ${{ secrets.GITHUB_TOKEN }}
33
+ specs:
34
+ runs-on: ubuntu-latest
35
+
36
+ env:
37
+ FULL_TEST_COVERAGE_CHECK: false
38
+
39
+ strategy:
40
+ fail-fast: false
41
+ matrix:
42
+ ruby: ["2.7", "3.0"]
43
+
44
+ steps:
45
+ - uses: actions/checkout@v2
46
+ - uses: ruby/setup-ruby@v1
47
+ with:
48
+ ruby-version: ${{ matrix.ruby }}
49
+ bundler-cache: true
50
+ - name: Run specs
51
+ run: bundle exec rspec
data/.gitignore CHANGED
@@ -6,5 +6,3 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
-
10
- Gemfile.lock
data/.rubocop.yml CHANGED
@@ -3,7 +3,7 @@ inherit_gem:
3
3
 
4
4
  AllCops:
5
5
  DisplayCopNames: true
6
- TargetRubyVersion: 2.5
6
+ TargetRubyVersion: 2.7
7
7
 
8
8
  Naming/MethodParameterName:
9
9
  AllowedNames: ["x", "y", "z"]
@@ -14,3 +14,7 @@ RSpec/EmptyLineAfterHook:
14
14
  Naming/FileName:
15
15
  Exclude:
16
16
  - lib/ci-helper.rb
17
+
18
+ Style/HashConversion:
19
+ Exclude:
20
+ - spec/**/*_spec.rb
data/Gemfile.lock ADDED
@@ -0,0 +1,120 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ci-helper (0.5.0)
5
+ colorize (~> 0.8)
6
+ dry-inflector (~> 0.2)
7
+ umbrellio-sequel-plugins (~> 0.4)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ activesupport (7.0.2.4)
13
+ concurrent-ruby (~> 1.0, >= 1.0.2)
14
+ i18n (>= 1.6, < 2)
15
+ minitest (>= 5.1)
16
+ tzinfo (~> 2.0)
17
+ ast (2.4.2)
18
+ bundler-audit (0.9.0.1)
19
+ bundler (>= 1.2.0, < 3)
20
+ thor (~> 1.0)
21
+ coderay (1.1.3)
22
+ colorize (0.8.1)
23
+ concurrent-ruby (1.1.10)
24
+ diff-lcs (1.5.0)
25
+ docile (1.4.0)
26
+ dry-inflector (0.2.1)
27
+ i18n (1.10.0)
28
+ concurrent-ruby (~> 1.0)
29
+ method_source (1.0.0)
30
+ minitest (5.15.0)
31
+ parallel (1.22.1)
32
+ parser (3.1.2.0)
33
+ ast (~> 2.4.1)
34
+ pry (0.14.1)
35
+ coderay (~> 1.1)
36
+ method_source (~> 1.0)
37
+ rack (2.2.3)
38
+ rainbow (3.1.1)
39
+ rake (13.0.6)
40
+ regexp_parser (2.3.1)
41
+ rexml (3.2.5)
42
+ rspec (3.11.0)
43
+ rspec-core (~> 3.11.0)
44
+ rspec-expectations (~> 3.11.0)
45
+ rspec-mocks (~> 3.11.0)
46
+ rspec-core (3.11.0)
47
+ rspec-support (~> 3.11.0)
48
+ rspec-expectations (3.11.0)
49
+ diff-lcs (>= 1.2.0, < 2.0)
50
+ rspec-support (~> 3.11.0)
51
+ rspec-mocks (3.11.1)
52
+ diff-lcs (>= 1.2.0, < 2.0)
53
+ rspec-support (~> 3.11.0)
54
+ rspec-support (3.11.0)
55
+ rubocop (1.25.1)
56
+ parallel (~> 1.10)
57
+ parser (>= 3.1.0.0)
58
+ rainbow (>= 2.2.2, < 4.0)
59
+ regexp_parser (>= 1.8, < 3.0)
60
+ rexml
61
+ rubocop-ast (>= 1.15.1, < 2.0)
62
+ ruby-progressbar (~> 1.7)
63
+ unicode-display_width (>= 1.4.0, < 3.0)
64
+ rubocop-ast (1.17.0)
65
+ parser (>= 3.1.1.0)
66
+ rubocop-config-umbrellio (1.25.0.61)
67
+ rubocop (~> 1.25.0)
68
+ rubocop-performance (~> 1.13.0)
69
+ rubocop-rails (~> 2.13.0)
70
+ rubocop-rake (~> 0.6.0)
71
+ rubocop-rspec (~> 2.7.0)
72
+ rubocop-sequel (~> 0.3.3)
73
+ rubocop-performance (1.13.3)
74
+ rubocop (>= 1.7.0, < 2.0)
75
+ rubocop-ast (>= 0.4.0)
76
+ rubocop-rails (2.13.2)
77
+ activesupport (>= 4.2.0)
78
+ rack (>= 1.1)
79
+ rubocop (>= 1.7.0, < 2.0)
80
+ rubocop-rake (0.6.0)
81
+ rubocop (~> 1.0)
82
+ rubocop-rspec (2.7.0)
83
+ rubocop (~> 1.19)
84
+ rubocop-sequel (0.3.3)
85
+ rubocop (~> 1.0)
86
+ ruby-progressbar (1.11.0)
87
+ sequel (5.56.0)
88
+ simplecov (0.21.2)
89
+ docile (~> 1.1)
90
+ simplecov-html (~> 0.11)
91
+ simplecov_json_formatter (~> 0.1)
92
+ simplecov-html (0.12.3)
93
+ simplecov-lcov (0.8.0)
94
+ simplecov_json_formatter (0.1.4)
95
+ symbiont-ruby (0.7.0)
96
+ thor (1.2.1)
97
+ tzinfo (2.0.4)
98
+ concurrent-ruby (~> 1.0)
99
+ umbrellio-sequel-plugins (0.5.1.27)
100
+ sequel
101
+ symbiont-ruby
102
+ unicode-display_width (2.1.0)
103
+
104
+ PLATFORMS
105
+ ruby
106
+ x86_64-linux
107
+
108
+ DEPENDENCIES
109
+ bundler
110
+ bundler-audit
111
+ ci-helper!
112
+ pry
113
+ rake
114
+ rspec
115
+ rubocop-config-umbrellio
116
+ simplecov
117
+ simplecov-lcov
118
+
119
+ BUNDLED WITH
120
+ 2.3.13
data/README.md CHANGED
@@ -31,8 +31,10 @@ A command can accept list of options (parameters). Option values are passed thro
31
31
  For example, the BundlerAudit command accepts the ignored_advisories option
32
32
  You can set a value of this option by setting the flag `--ignored-advisories ignored-advisory`.
33
33
  It should be noted that all hyphens in flag names are automatically replaced with underscores.
34
+ If command accepts array as option's value, you can separate values with either commas or spaces.
34
35
  ```bash
35
- $ ci-helper BundlerAudit --ignored-advisories first,second
36
+ $ ci-helper BundlerAudit --ignored-advisories first,second # Valid
37
+ $ ci-helper BundlerAudit --ignored-advisories first second # Valid too!
36
38
  ```
37
39
 
38
40
  List of available commands:
@@ -74,6 +76,8 @@ List of available commands:
74
76
  Accepted flags: `--config-path`
75
77
  * `--config-path` — relative path to your config yaml file with schedule.
76
78
  Usually it is `config/sidekiq_scheduler.yml`.
79
+ * `--with-database` — if you want to prepare database before executing specs,
80
+ you should set this flag to `true`.
77
81
 
78
82
  ### Rake Tasks
79
83
 
data/ci_helper.gemspec CHANGED
@@ -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.5.0")
15
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
16
16
 
17
17
  spec.metadata["homepage_uri"] = spec.homepage
18
18
  spec.metadata["source_code_uri"] = "https://github.com/umbrellio/ci_helper"
data/lib/ci_helper/cli.rb CHANGED
@@ -26,13 +26,14 @@ module CIHelper
26
26
  end
27
27
 
28
28
  def parse_options_from(args)
29
- args.each_slice(2).with_object({}) do |args, options|
30
- key = Tools::Inflector.instance.underscore(args.first.split("--").last)
31
- value = args[1] || ""
32
- raise Error, "Not valid options" if key.empty?
33
-
34
- options[key.to_sym] = value
35
- end
29
+ args
30
+ .slice_when { |_el_before, el_after| el_after.start_with?("--") }
31
+ .each_with_object({}) do |commands, options|
32
+ key = Tools::Inflector.instance.underscore(commands.shift.split("--").last)
33
+ raise "Invalid options" if key.empty?
34
+ value = commands.size <= 1 ? commands.first : commands
35
+ options[key.to_sym] = value || ""
36
+ end
36
37
  end
37
38
 
38
39
  def perform_command!
@@ -21,7 +21,7 @@ module CIHelper
21
21
  end
22
22
 
23
23
  def split_resultset?
24
- options[:split_resultset] == "true"
24
+ boolean_option(:split_resultset)
25
25
  end
26
26
 
27
27
  def setup_file_path
@@ -8,6 +8,7 @@ module CIHelper
8
8
  def call
9
9
  return 0 if job_constants.empty?
10
10
 
11
+ create_and_migrate_database! if with_database?
11
12
  cmd = craft_jobs_const_get_cmd
12
13
  execute_with_rails_runner(cmd)
13
14
  0
@@ -15,8 +16,12 @@ module CIHelper
15
16
 
16
17
  private
17
18
 
19
+ def env
20
+ :development
21
+ end
22
+
18
23
  def execute_with_rails_runner(cmd)
19
- execute("bundle exec rails runner \"#{cmd}\"")
24
+ execute("bundle exec rails runner '#{cmd}'")
20
25
  end
21
26
 
22
27
  def craft_jobs_const_get_cmd
@@ -24,11 +29,20 @@ module CIHelper
24
29
  end
25
30
 
26
31
  def job_constants
27
- @job_constants ||= config.values.reject(&:nil?).flat_map(&:keys).uniq
32
+ @job_constants ||= config.values.compact.flat_map(&:keys).uniq
33
+ end
34
+
35
+ def with_database?
36
+ boolean_option(:with_database)
28
37
  end
29
38
 
30
39
  def config
31
- @config ||= YAML.load_file(options[:config_path])
40
+ @config ||= begin
41
+ path = options[:config_path]
42
+ # :nocov:
43
+ YAML.respond_to?(:unsafe_load_file) ? YAML.unsafe_load_file(path) : YAML.load_file(path)
44
+ # :nocov:
45
+ end
32
46
  end
33
47
  end
34
48
  end
@@ -37,11 +37,11 @@ module CIHelper
37
37
  end
38
38
 
39
39
  def with_database?
40
- options[:with_database] == "true"
40
+ boolean_option(:with_database)
41
41
  end
42
42
 
43
43
  def split_resultset?
44
- options[:split_resultset] == "true"
44
+ boolean_option(:split_resultset)
45
45
  end
46
46
  end
47
47
  end
@@ -54,8 +54,15 @@ 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)
63
+ value = options[key]
64
+ return value if value.is_a?(Array)
65
+
59
66
  options[key].split(",")
60
67
  end
61
68
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CIHelper
4
- VERSION = "0.4.0"
4
+ VERSION = "0.5.0"
5
5
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "logger"
4
+ require "open3"
4
5
  require "sequel/timestamp_migrator_undo_extension"
5
6
 
6
7
  class SequelManagement
@@ -30,7 +31,10 @@ class SequelManagement
30
31
 
31
32
  logger.info "Begin rolling back new migrations"
32
33
 
33
- original_migrations = `#{git_command}`.split.map { |path| File.basename(path) }
34
+ migration_files, _, status = Open3.capture3(git_command)
35
+ abort "Can't get list of migration files" unless status.success?
36
+
37
+ original_migrations = migration_files.split.map { |path| File.basename(path) }
34
38
  migrations_to_rollback = (migrator.applied_migrations - original_migrations).sort.reverse
35
39
 
36
40
  next if migrations_to_rollback.empty?
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.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - JustAnotherDude
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-11-30 00:00:00.000000000 Z
11
+ date: 2022-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -173,11 +173,12 @@ extensions: []
173
173
  extra_rdoc_files: []
174
174
  files:
175
175
  - ".editorconfig"
176
- - ".github/workflows/ruby.yml"
176
+ - ".github/workflows/test.yml"
177
177
  - ".gitignore"
178
178
  - ".rspec"
179
179
  - ".rubocop.yml"
180
180
  - Gemfile
181
+ - Gemfile.lock
181
182
  - LICENSE.txt
182
183
  - README.md
183
184
  - Rakefile
@@ -208,7 +209,7 @@ licenses:
208
209
  metadata:
209
210
  homepage_uri: https://github.com/umbrellio/ci_helper
210
211
  source_code_uri: https://github.com/umbrellio/ci_helper
211
- post_install_message:
212
+ post_install_message:
212
213
  rdoc_options: []
213
214
  require_paths:
214
215
  - lib
@@ -216,15 +217,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
216
217
  requirements:
217
218
  - - ">="
218
219
  - !ruby/object:Gem::Version
219
- version: 2.5.0
220
+ version: 2.7.0
220
221
  required_rubygems_version: !ruby/object:Gem::Requirement
221
222
  requirements:
222
223
  - - ">="
223
224
  - !ruby/object:Gem::Version
224
225
  version: '0'
225
226
  requirements: []
226
- rubygems_version: 3.1.4
227
- signing_key:
227
+ rubygems_version: 3.3.12
228
+ signing_key:
228
229
  specification_version: 4
229
230
  summary: Continuous Integration helpers for Ruby
230
231
  test_files: []
@@ -1,84 +0,0 @@
1
- # This workflow uses actions that are not certified by GitHub.
2
- # They are provided by a third-party and are governed by
3
- # separate terms of service, privacy policy, and support
4
- # documentation.
5
- # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
- # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
-
8
- name: Ruby
9
-
10
- on:
11
- push:
12
- branches: [ master ]
13
- pull_request:
14
- branches: [ master ]
15
-
16
- env:
17
- FULL_COVERAGE_CHECK: true
18
-
19
- jobs:
20
- test-latest:
21
-
22
- runs-on: ubuntu-latest
23
-
24
- steps:
25
- - uses: actions/checkout@v2
26
- - name: Set up Ruby
27
- # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
28
- # change this to (see https://github.com/ruby/setup-ruby#versioning):
29
- # uses: ruby/setup-ruby@v1
30
- uses: ruby/setup-ruby@v1
31
- with:
32
- ruby-version: 2.7
33
- - name: Install dependencies
34
- run: bundle install && gem install bundler-audit
35
- - name: Build and install gem to systems gems
36
- run: bundle exec rake install
37
- - name: Run Linter
38
- run: ci-helper RubocopLint
39
- - name: Check missed spec suffixes
40
- run: ci-helper CheckSpecSuffixes --extra-paths spec/*.rb --ignored-paths spec/*_helper.rb
41
- - name: Run specs
42
- run: ci-helper RunSpecs
43
- - name: Audit
44
- run: ci-helper BundlerAudit
45
- - name: Coveralls
46
- uses: coverallsapp/github-action@v1.1.1
47
- with:
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