ci-helper 0.9.0 → 0.10.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: 2c5d7ac1dcb58a235887b801308afcfa0e6f4cee4a52c829c769d12424866107
4
- data.tar.gz: 446bfe1be5110ece9d61eec181a4718999bd20e0c7f70e2f3fcf04b3c9b7f72f
3
+ metadata.gz: fae9814d6c5c741111d1ad0c088c82e559de3104654182a4f31eecd899705d6b
4
+ data.tar.gz: f442afb5f64aaf8624e9b7b583b90a86046975570d12dd3a8a1d30b0cf6fd51a
5
5
  SHA512:
6
- metadata.gz: 1b35b1ea59c8fb0eb4bd2c293f807c4a421b6326852f3fb8e7a879f8c6a5a05dc5010e4f494846236c5733f2a59fec89b7994c4295b9254c49bc237a8acb92aa
7
- data.tar.gz: 9cb25a481ea5c3d03afd5fbc45f276454a88c880d1296b24b898941305b50ef1144fd8df84447e897cf8d9edb0757aef4f82a6591a9ff0b3a5f6e40c6a0be9bc
6
+ metadata.gz: df17b45dadbf7707cfcdc143eedacb2b01a210b49f107127541985f882a1f273d7578ff1e3506c0a386b357f486d40c4b5b10896d8f828bbd0eaddd784e1fdc5
7
+ data.tar.gz: 2604f25b03bfc9f2ed0cd654b8d2a0c111da92bfae8379f5b2eea8719af1d4e74ad590a94ffbf5a34d5004ce1b2f419ef453032e6f81fb35d7b03641df8a055d
@@ -0,0 +1,54 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+
8
+ jobs:
9
+ release:
10
+ runs-on: ubuntu-latest
11
+ permissions:
12
+ contents: write
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+
16
+ - name: Extract version
17
+ id: version
18
+ run: |
19
+ version=$(grep -oP '(?<=VERSION = ")[^"]+' lib/ci_helper/version.rb)
20
+ echo "tag=v$version" >> "$GITHUB_OUTPUT"
21
+
22
+ - name: Check if release already exists
23
+ id: check
24
+ run: |
25
+ if gh release view "${{ steps.version.outputs.tag }}" &>/dev/null; then
26
+ echo "exists=true" >> "$GITHUB_OUTPUT"
27
+ else
28
+ echo "exists=false" >> "$GITHUB_OUTPUT"
29
+ fi
30
+ env:
31
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32
+
33
+ - uses: ruby/setup-ruby@v1
34
+ if: steps.check.outputs.exists == 'false'
35
+ with:
36
+ ruby-version: "3.4"
37
+ bundler-cache: true
38
+
39
+ - name: Build gem
40
+ if: steps.check.outputs.exists == 'false'
41
+ run: gem build ci_helper.gemspec
42
+
43
+ - name: Push gem to RubyGems
44
+ if: steps.check.outputs.exists == 'false'
45
+ run: gem push *.gem
46
+ env:
47
+ GEM_HOST_API_KEY: ${{ secrets.GEM_HOST_API_KEY }}
48
+
49
+ - uses: softprops/action-gh-release@v3
50
+ if: steps.check.outputs.exists == 'false'
51
+ with:
52
+ tag_name: ${{ steps.version.outputs.tag }}
53
+ files: "*.gem"
54
+ generate_release_notes: true
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ci-helper (0.9.0)
4
+ ci-helper (0.10.1)
5
5
  colorize (~> 1.1)
6
6
  dry-inflector (~> 1.0)
7
7
  umbrellio-sequel-plugins (~> 0.14)
@@ -9,119 +9,139 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- activesupport (7.1.2)
12
+ activesupport (8.1.3)
13
13
  base64
14
14
  bigdecimal
15
- concurrent-ruby (~> 1.0, >= 1.0.2)
15
+ concurrent-ruby (~> 1.0, >= 1.3.1)
16
16
  connection_pool (>= 2.2.5)
17
17
  drb
18
18
  i18n (>= 1.6, < 2)
19
+ json
20
+ logger (>= 1.4.2)
19
21
  minitest (>= 5.1)
20
- mutex_m
21
- tzinfo (~> 2.0)
22
- ast (2.4.2)
23
- base64 (0.2.0)
24
- benchmark (0.4.1)
25
- bigdecimal (3.1.4)
26
- bundler-audit (0.9.1)
27
- bundler (>= 1.2.0, < 3)
22
+ securerandom (>= 0.3)
23
+ tzinfo (~> 2.0, >= 2.0.5)
24
+ uri (>= 0.13.1)
25
+ ast (2.4.3)
26
+ base64 (0.3.0)
27
+ benchmark (0.5.0)
28
+ bigdecimal (4.1.2)
29
+ bundler-audit (0.9.3)
30
+ bundler (>= 1.2.0)
28
31
  thor (~> 1.0)
29
32
  coderay (1.1.3)
30
33
  colorize (1.1.0)
31
- concurrent-ruby (1.2.2)
32
- connection_pool (2.4.1)
33
- diff-lcs (1.5.0)
34
- docile (1.4.0)
35
- drb (2.2.0)
36
- ruby2_keywords
37
- dry-inflector (1.0.0)
38
- i18n (1.14.1)
34
+ concurrent-ruby (1.3.6)
35
+ connection_pool (3.0.2)
36
+ diff-lcs (1.6.2)
37
+ docile (1.4.1)
38
+ drb (2.2.3)
39
+ dry-inflector (1.3.1)
40
+ i18n (1.14.8)
39
41
  concurrent-ruby (~> 1.0)
40
- json (2.7.1)
41
- method_source (1.0.0)
42
- minitest (5.20.0)
43
- mutex_m (0.2.0)
42
+ io-console (0.8.2)
43
+ json (2.19.4)
44
+ language_server-protocol (3.17.0.5)
45
+ lint_roller (1.1.0)
46
+ logger (1.7.0)
47
+ method_source (1.1.0)
48
+ minitest (6.0.5)
49
+ drb (~> 2.0)
50
+ prism (~> 1.5)
44
51
  ostruct (0.6.3)
45
- parallel (1.23.0)
46
- parser (3.2.2.4)
52
+ parallel (1.28.0)
53
+ parser (3.3.11.1)
47
54
  ast (~> 2.4.1)
48
55
  racc
49
- pry (0.14.2)
56
+ prism (1.9.0)
57
+ pry (0.16.0)
50
58
  coderay (~> 1.1)
51
59
  method_source (~> 1.0)
52
- racc (1.7.3)
53
- rack (3.0.8)
60
+ reline (>= 0.6.0)
61
+ racc (1.8.1)
62
+ rack (3.2.6)
54
63
  rainbow (3.1.1)
55
- rake (13.1.0)
56
- regexp_parser (2.8.3)
57
- rexml (3.2.6)
58
- rspec (3.12.0)
59
- rspec-core (~> 3.12.0)
60
- rspec-expectations (~> 3.12.0)
61
- rspec-mocks (~> 3.12.0)
62
- rspec-core (3.12.2)
63
- rspec-support (~> 3.12.0)
64
- rspec-expectations (3.12.3)
64
+ rake (13.4.2)
65
+ regexp_parser (2.12.0)
66
+ reline (0.6.3)
67
+ io-console (~> 0.5)
68
+ rspec (3.13.2)
69
+ rspec-core (~> 3.13.0)
70
+ rspec-expectations (~> 3.13.0)
71
+ rspec-mocks (~> 3.13.0)
72
+ rspec-core (3.13.6)
73
+ rspec-support (~> 3.13.0)
74
+ rspec-expectations (3.13.5)
65
75
  diff-lcs (>= 1.2.0, < 2.0)
66
- rspec-support (~> 3.12.0)
67
- rspec-mocks (3.12.6)
76
+ rspec-support (~> 3.13.0)
77
+ rspec-mocks (3.13.8)
68
78
  diff-lcs (>= 1.2.0, < 2.0)
69
- rspec-support (~> 3.12.0)
70
- rspec-support (3.12.1)
71
- rubocop (1.50.2)
79
+ rspec-support (~> 3.13.0)
80
+ rspec-support (3.13.7)
81
+ rubocop (1.84.2)
72
82
  json (~> 2.3)
83
+ language_server-protocol (~> 3.17.0.2)
84
+ lint_roller (~> 1.1.0)
73
85
  parallel (~> 1.10)
74
- parser (>= 3.2.0.0)
86
+ parser (>= 3.3.0.2)
75
87
  rainbow (>= 2.2.2, < 4.0)
76
- regexp_parser (>= 1.8, < 3.0)
77
- rexml (>= 3.2.5, < 4.0)
78
- rubocop-ast (>= 1.28.0, < 2.0)
88
+ regexp_parser (>= 2.9.3, < 3.0)
89
+ rubocop-ast (>= 1.49.0, < 2.0)
79
90
  ruby-progressbar (~> 1.7)
80
- unicode-display_width (>= 2.4.0, < 3.0)
81
- rubocop-ast (1.30.0)
82
- parser (>= 3.2.1.0)
83
- rubocop-capybara (2.19.0)
84
- rubocop (~> 1.41)
85
- rubocop-config-umbrellio (1.50.0.85)
86
- rubocop (~> 1.50.0)
87
- rubocop-performance (~> 1.17.0)
88
- rubocop-rails (~> 2.19.0)
89
- rubocop-rake (~> 0.6.0)
90
- rubocop-rspec (~> 2.20.0)
91
- rubocop-sequel (~> 0.3.3)
92
- rubocop-performance (1.17.1)
93
- rubocop (>= 1.7.0, < 2.0)
94
- rubocop-ast (>= 0.4.0)
95
- rubocop-rails (2.19.1)
91
+ unicode-display_width (>= 2.4.0, < 4.0)
92
+ rubocop-ast (1.49.1)
93
+ parser (>= 3.3.7.2)
94
+ prism (~> 1.7)
95
+ rubocop-config-umbrellio (1.84.118)
96
+ rubocop (~> 1.84.0)
97
+ rubocop-factory_bot (~> 2.28.0)
98
+ rubocop-performance (~> 1.26.0)
99
+ rubocop-rails (~> 2.34.0)
100
+ rubocop-rake (~> 0.7.0)
101
+ rubocop-rspec (~> 3.9.0)
102
+ rubocop-sequel (~> 0.4.0)
103
+ rubocop-factory_bot (2.28.0)
104
+ lint_roller (~> 1.1)
105
+ rubocop (~> 1.72, >= 1.72.1)
106
+ rubocop-performance (1.26.1)
107
+ lint_roller (~> 1.1)
108
+ rubocop (>= 1.75.0, < 2.0)
109
+ rubocop-ast (>= 1.47.1, < 2.0)
110
+ rubocop-rails (2.34.3)
96
111
  activesupport (>= 4.2.0)
112
+ lint_roller (~> 1.1)
97
113
  rack (>= 1.1)
98
- rubocop (>= 1.33.0, < 2.0)
99
- rubocop-rake (0.6.0)
100
- rubocop (~> 1.0)
101
- rubocop-rspec (2.20.0)
102
- rubocop (~> 1.33)
103
- rubocop-capybara (~> 2.17)
104
- rubocop-sequel (0.3.4)
105
- rubocop (~> 1.0)
114
+ rubocop (>= 1.75.0, < 2.0)
115
+ rubocop-ast (>= 1.44.0, < 2.0)
116
+ rubocop-rake (0.7.1)
117
+ lint_roller (~> 1.1)
118
+ rubocop (>= 1.72.1)
119
+ rubocop-rspec (3.9.0)
120
+ lint_roller (~> 1.1)
121
+ rubocop (~> 1.81)
122
+ rubocop-sequel (0.4.1)
123
+ lint_roller (~> 1.1)
124
+ rubocop (>= 1.72.1, < 2)
106
125
  ruby-progressbar (1.13.0)
107
- ruby2_keywords (0.0.5)
108
- sequel (5.75.0)
126
+ securerandom (0.4.1)
127
+ sequel (5.103.0)
109
128
  bigdecimal
110
129
  simplecov (0.22.0)
111
130
  docile (~> 1.1)
112
131
  simplecov-html (~> 0.11)
113
132
  simplecov_json_formatter (~> 0.1)
114
- simplecov-html (0.12.3)
115
- simplecov-lcov (0.8.0)
133
+ simplecov-html (0.13.2)
134
+ simplecov-lcov (0.9.0)
116
135
  simplecov_json_formatter (0.1.4)
117
- symbiont-ruby (0.7.0)
118
- thor (1.3.0)
136
+ thor (1.5.0)
119
137
  tzinfo (2.0.6)
120
138
  concurrent-ruby (~> 1.0)
121
- umbrellio-sequel-plugins (0.14.0.189)
139
+ umbrellio-sequel-plugins (0.17.2)
122
140
  sequel
123
- symbiont-ruby
124
- unicode-display_width (2.5.0)
141
+ unicode-display_width (3.2.0)
142
+ unicode-emoji (~> 4.1)
143
+ unicode-emoji (4.2.0)
144
+ uri (1.1.1)
125
145
 
126
146
  PLATFORMS
127
147
  arm64-darwin
data/ci_helper.gemspec CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
25
  spec.require_paths = ["lib"]
26
26
 
27
- spec.add_runtime_dependency "colorize", "~> 1.1"
28
- spec.add_runtime_dependency "dry-inflector", "~> 1.0"
29
- spec.add_runtime_dependency "umbrellio-sequel-plugins", "~> 0.14"
27
+ spec.add_dependency "colorize", "~> 1.1"
28
+ spec.add_dependency "dry-inflector", "~> 1.0"
29
+ spec.add_dependency "umbrellio-sequel-plugins", "~> 0.14"
30
30
  end
data/lib/ci-helper.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "./ci_helper"
3
+ require_relative "ci_helper"
@@ -21,7 +21,7 @@ module CIHelper
21
21
  end
22
22
 
23
23
  def split_resultset?
24
- boolean_option(:split_resultset)
24
+ boolean_option?(:split_resultset)
25
25
  end
26
26
 
27
27
  def setup_file_path
@@ -17,7 +17,7 @@ module CIHelper
17
17
  end
18
18
 
19
19
  def with_clickhouse?
20
- boolean_option(:with_clickhouse)
20
+ boolean_option?(:with_clickhouse)
21
21
  end
22
22
  end
23
23
  end
@@ -23,7 +23,7 @@ module CIHelper
23
23
  end
24
24
 
25
25
  def with_clickhouse?
26
- boolean_option(:with_clickhouse)
26
+ boolean_option?(:with_clickhouse)
27
27
  end
28
28
  end
29
29
  end
@@ -33,7 +33,7 @@ module CIHelper
33
33
  end
34
34
 
35
35
  def with_database?
36
- boolean_option(:with_database)
36
+ boolean_option?(:with_database)
37
37
  end
38
38
 
39
39
  def config
@@ -1,15 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "json"
4
+ require "tmpdir"
5
+
3
6
  module CIHelper
4
7
  module Commands
5
8
  class RunSpecs < BaseCommand
6
9
  def call
7
- files_to_run = job_files
8
- return if files_to_run.empty?
10
+ return if all_spec_files.empty?
9
11
 
10
12
  create_and_migrate_database! if with_database?
11
13
  create_and_migrate_clickhouse_database! if with_clickhouse?
12
- execute("bundle exec rspec #{Shellwords.join(files_to_run)}")
14
+
15
+ specs_to_run = job_count == 1 ? job_files : job_examples
16
+ return 0 if specs_to_run.empty?
17
+
18
+ execute("bundle exec rspec #{Shellwords.join(specs_to_run)}")
13
19
  return 0 unless split_resultset?
14
20
 
15
21
  execute("mv coverage/.resultset.json coverage/resultset.#{job_index}.json")
@@ -21,28 +27,52 @@ module CIHelper
21
27
  :test
22
28
  end
23
29
 
30
+ def all_spec_files
31
+ @all_spec_files ||= path.glob("spec/**/*_spec.rb")
32
+ end
33
+
24
34
  def job_files
25
- all_files = path.glob("spec/**/*_spec.rb")
35
+ heavy_files, std_files = all_spec_files.partition { |f| heavy?(relative(f)) }
36
+ sorted_std = std_files.map { |f| [f.size, relative(f)] }.sort.map(&:last)
37
+ distribute(sorted_std + heavy_files)
38
+ end
26
39
 
27
- heavy_files = []
28
- std_files = []
40
+ def job_examples
41
+ heavy, std = example_ids.partition do |id|
42
+ heavy?(id.split("[", 2).first.delete_prefix("./"))
43
+ end
44
+ distribute(std.sort + heavy.sort)
45
+ end
29
46
 
30
- all_files.each do |file|
31
- relative_path = file.relative_path_from(path).to_s
32
- if heavy_specs_paths.any? { |pattern| File.fnmatch?(pattern, relative_path) }
33
- heavy_files << file
34
- else
35
- std_files << file
47
+ def example_ids
48
+ Dir.mktmpdir do |dir|
49
+ output_file = File.join(dir, "rspec_examples.json")
50
+ begin
51
+ execute(
52
+ "bundle exec rspec --dry-run --format=json --out #{Shellwords.escape(output_file)}",
53
+ )
54
+ rescue Error
55
+ output = File.exist?(output_file) ? File.read(output_file) : "(no output file)"
56
+ fail!("RSpec dry-run failed. Output file contents:\n#{output}")
36
57
  end
58
+ JSON.parse(File.read(output_file)).fetch("examples").map { |e| e.fetch("id") }
37
59
  end
60
+ end
38
61
 
39
- sorted_files =
40
- std_files.map { |x| [x.size, x.relative_path_from(path).to_s] }.sort.map(&:last)
41
- (sorted_files + heavy_files).reverse.select.with_index do |_file, index|
62
+ def distribute(items)
63
+ items.reverse.select.with_index do |_item, index|
42
64
  (index % job_count) == (job_index - 1)
43
65
  end
44
66
  end
45
67
 
68
+ def heavy?(relative_path)
69
+ heavy_specs_paths.any? { |pattern| File.fnmatch?(pattern, relative_path) }
70
+ end
71
+
72
+ def relative(file)
73
+ file.relative_path_from(path).to_s
74
+ end
75
+
46
76
  def heavy_specs_paths
47
77
  @heavy_specs_paths ||=
48
78
  begin
@@ -61,15 +91,15 @@ module CIHelper
61
91
  end
62
92
 
63
93
  def with_database?
64
- boolean_option(:with_database)
94
+ boolean_option?(:with_database)
65
95
  end
66
96
 
67
97
  def with_clickhouse?
68
- boolean_option(:with_clickhouse)
98
+ boolean_option?(:with_clickhouse)
69
99
  end
70
100
 
71
101
  def split_resultset?
72
- boolean_option(:split_resultset)
102
+ boolean_option?(:split_resultset)
73
103
  end
74
104
  end
75
105
  end
@@ -6,8 +6,8 @@ module CIHelper
6
6
 
7
7
  class BaseCommand
8
8
  class << self
9
- def call!(**options)
10
- new(**options).call
9
+ def call!(**)
10
+ new(**).call
11
11
  end
12
12
 
13
13
  # :nocov:
@@ -58,7 +58,7 @@ module CIHelper
58
58
  raise Error, message
59
59
  end
60
60
 
61
- def boolean_option(key)
61
+ def boolean_option?(key)
62
62
  options[key] == "true"
63
63
  end
64
64
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CIHelper
4
- VERSION = "0.9.0"
4
+ VERSION = "0.10.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ci-helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - JustAnotherDude
@@ -60,6 +60,7 @@ extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
62
  - ".editorconfig"
63
+ - ".github/workflows/release.yml"
63
64
  - ".github/workflows/test.yml"
64
65
  - ".gitignore"
65
66
  - ".rspec"
@@ -110,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
111
  - !ruby/object:Gem::Version
111
112
  version: '0'
112
113
  requirements: []
113
- rubygems_version: 3.7.2
114
+ rubygems_version: 3.6.9
114
115
  specification_version: 4
115
116
  summary: Continuous Integration helpers for Ruby
116
117
  test_files: []