ci-helper 0.10.0 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 00bf40738c9997e76bf3f9c7339d1608e7bd706d7a93d4f00322f4f5b5336d4d
4
- data.tar.gz: 6612126f35b0440904ffdada78380edff042b062009d7f51b17df0797c72ee59
3
+ metadata.gz: adbebe67fd86fd92ee630a21009a3c42fe6d4be32d9ebb773539cc92964bab77
4
+ data.tar.gz: ce5e94594b8392d5f0d7b1de9f4fd5c548d5598c0097192a98eb6718f8478493
5
5
  SHA512:
6
- metadata.gz: 5b0404a8c11b9dc5326654f672befed4bf0ed24d898789013b7eb00c7726b1f28f5e0aa9101cd6d0492426bcbcb79266e76064962184d873733ac392e8eec9be
7
- data.tar.gz: c64d2b1b049753074b1fe5aae027c928c30e428f4c1f9b9022385568566a2ddb24be0445f5a3e20f713533ed098f6a2efe139eb06c7dd52825cab2a47e532591
6
+ metadata.gz: b98ad7e1d9b1cfa5a740c01ad854c697b65d41e070dbb132b5da44af2a9ada24140edbf80dca852fd9e0e3132a9ec911c8902dcf319d3120a16e2995eda810b1
7
+ data.tar.gz: 7eb7b22ffacf1b8f0951c8b116edfa67ccd2f55c244626e6d2484332c3dc4de891a7eff91bf0008cf3893be3f9474305076952b1c5ad6c5ce3b70b4b95c0a5fd
@@ -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.10.0)
4
+ ci-helper (0.10.2)
5
5
  colorize (~> 1.1)
6
6
  dry-inflector (~> 1.0)
7
7
  umbrellio-sequel-plugins (~> 0.14)
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 ci_helper
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. Does not accept flags.
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
- Does not accept flags. Gem provides this rake task, but only for `Sequel`.
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`, `node-total`, `with-database`, `split-resultset`.
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 `.resultset.#{node_index}.json`
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: `--extra_paths`, `--ignored_paths`.
70
+ Accepted flags: `--extra-paths`, `--ignored-paths`.
63
71
  * `--extra-paths [values]` - accepts additional path patterns that should be scanned,
64
- delimited by coma.
72
+ delimited by comma.
65
73
  * `--ignored-paths [values]` - accepts path patterns that should be ignored,
66
- delimited by coma.
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 executing specs,
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 `CoolCoomand` class may look something like this:
121
+ Where your `CoolCommand` class may look something like this:
114
122
  ```ruby
115
123
  module CIHelper
116
124
  module Commands
@@ -47,9 +47,14 @@ module CIHelper
47
47
  def example_ids
48
48
  Dir.mktmpdir do |dir|
49
49
  output_file = File.join(dir, "rspec_examples.json")
50
- execute(
51
- "bundle exec rspec --dry-run --format=json --out #{Shellwords.escape(output_file)}",
52
- )
50
+ begin
51
+ execute(
52
+ "bundle exec rspec --dry-run --format=json --out #{Shellwords.escape(output_file)}",
53
+ capture: true,
54
+ )
55
+ rescue Error => error
56
+ fail!("RSpec dry-run failed:\n#{error.output}")
57
+ end
53
58
  JSON.parse(File.read(output_file)).fetch("examples").map { |e| e.fetch("id") }
54
59
  end
55
60
  end
@@ -2,7 +2,14 @@
2
2
 
3
3
  module CIHelper
4
4
  module Commands
5
- class Error < StandardError; end
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
- fail!("Bad exit code #{exit_code} for command #{command.inspect}") unless exit_code.zero?
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, message
67
+ def fail!(message, output: nil)
68
+ raise Error.new(message, output: output)
59
69
  end
60
70
 
61
71
  def boolean_option?(key)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CIHelper
4
- VERSION = "0.10.0"
4
+ VERSION = "0.10.2"
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.10.0
4
+ version: 0.10.2
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"