jiminy 0.1.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/jiminy/cli/exit_codes/base.rb +11 -0
- data/lib/jiminy/cli/exit_codes/pipeline_not_found.rb +11 -0
- data/lib/jiminy/cli/exit_codes/process_timeout.rb +11 -0
- data/lib/jiminy/cli/exit_codes/success.rb +11 -0
- data/lib/jiminy/cli/exit_codes/workflow_not_found.rb +11 -0
- data/lib/jiminy/cli/exit_codes/workflow_not_success.rb +11 -0
- data/lib/jiminy/cli/exit_codes.rb +6 -0
- data/lib/jiminy/cli.rb +21 -6
- data/lib/jiminy/recording/prosopite_ext/tmp_file_recorder.rb +4 -2
- data/lib/jiminy/reporting/ci_providers/circle_ci/api_request.rb +1 -1
- data/lib/jiminy/reporting.rb +3 -0
- data/lib/jiminy/version.rb +1 -1
- data/lib/jiminy.rb +1 -0
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6d04e4d260d197712f1b3772110fd5ef1026ab903838746a7e97b229815c0b3
|
4
|
+
data.tar.gz: afafff4e148443368dc94297beecc151708ecae6f6e4f008b9fb70226d68b3b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 385cc76c40a7954e820d5f3f55a187407fb65934d378b487d0cf22a5efea2a1d56b8082930779332cd4e8e86b4a8c6353535cfba11cdfb97b804d4570ee15bd0
|
7
|
+
data.tar.gz: faa1fc3009eab77ee0237ad42326e1cc86c0ff26441bedcbd299107245299fd1380948a2b98db2968f01e256645482e94eba8e84e3e6548b70b276e6c0270c21
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,6 @@
|
|
1
|
+
require_relative "exit_codes/base"
|
2
|
+
require_relative "exit_codes/pipeline_not_found"
|
3
|
+
require_relative "exit_codes/process_timeout"
|
4
|
+
require_relative "exit_codes/success"
|
5
|
+
require_relative "exit_codes/workflow_not_found"
|
6
|
+
require_relative "exit_codes/workflow_not_success"
|
data/lib/jiminy/cli.rb
CHANGED
@@ -4,6 +4,8 @@ module Jiminy
|
|
4
4
|
require "thor"
|
5
5
|
class CLI < Thor
|
6
6
|
require "jiminy/reporting/ci_providers/circle_ci"
|
7
|
+
require "jiminy/cli/exit_codes"
|
8
|
+
|
7
9
|
include Thor::Actions
|
8
10
|
include Jiminy::Reporting::CIProviders
|
9
11
|
|
@@ -41,8 +43,7 @@ module Jiminy
|
|
41
43
|
pr_number: options[:pr_number],
|
42
44
|
dry_run: options[:dry_run])
|
43
45
|
|
44
|
-
|
45
|
-
exit(0)
|
46
|
+
finish(ExitCodes::Success)
|
46
47
|
end
|
47
48
|
|
48
49
|
desc "Install Jiminy", "Installs jiminy configuration files in your app"
|
@@ -54,6 +55,16 @@ module Jiminy
|
|
54
55
|
no_tasks do
|
55
56
|
attr_accessor :start_time
|
56
57
|
|
58
|
+
def finish(exit_code_klass, *args, **kwargs)
|
59
|
+
exit_code = exit_code_klass.new(*args, **kwargs)
|
60
|
+
if exit_code.value == 0
|
61
|
+
puts exit_code
|
62
|
+
else
|
63
|
+
warn exit_code
|
64
|
+
end
|
65
|
+
exit(exit_code.value)
|
66
|
+
end
|
67
|
+
|
57
68
|
def poll_interval
|
58
69
|
options[:poll_interval] || POLL_INTERVAL_SECONDS
|
59
70
|
end
|
@@ -80,7 +91,7 @@ module Jiminy
|
|
80
91
|
|
81
92
|
def pipeline
|
82
93
|
@_pipeline ||= CircleCI::Pipeline.find_by_revision(git_revision: git_revision, pr_number: pr_number) or
|
83
|
-
|
94
|
+
finish(ExitCodes::PipelineNotFound, git_revision: git_revision)
|
84
95
|
end
|
85
96
|
|
86
97
|
def missing_options
|
@@ -95,14 +106,18 @@ module Jiminy
|
|
95
106
|
@_workflow ||= begin
|
96
107
|
result = CircleCI::Workflow.find(pipeline_id: pipeline.id, workflow_name: Jiminy.config.ci_workflow_name)
|
97
108
|
if result.nil?
|
98
|
-
|
109
|
+
finish(ExitCodes::WorkflowNotFound,
|
110
|
+
workflow_name: Jiminy.config.ci_workflow_name,
|
111
|
+
pipeline_id: pipeline.id)
|
99
112
|
end
|
100
113
|
|
101
114
|
if result.not_run? || result.running?
|
102
115
|
$stdout.puts "Workflow still running..."
|
103
116
|
raise(WorkflowStillRunningError)
|
104
117
|
end
|
105
|
-
|
118
|
+
unless result.success?
|
119
|
+
finish(ExitCodes::WorkflowNotSuccess, status: result.status)
|
120
|
+
end
|
106
121
|
|
107
122
|
result
|
108
123
|
rescue WorkflowStillRunningError
|
@@ -110,7 +125,7 @@ module Jiminy
|
|
110
125
|
$stdout.puts "Retrying..."
|
111
126
|
retry unless timed_out?
|
112
127
|
|
113
|
-
|
128
|
+
finish(ExitCodes::ProcessTimeout, start_time: start_time)
|
114
129
|
end
|
115
130
|
end
|
116
131
|
# rubocop:enable Metrics/AbcSize
|
@@ -6,24 +6,26 @@ module Jiminy
|
|
6
6
|
class TmpFileRecorder
|
7
7
|
require_relative "../n_plus_one"
|
8
8
|
|
9
|
+
# rubocop:disable Metrics/AbcSize
|
9
10
|
def record(location:, queries:)
|
10
11
|
yaml_content = File.read(Jiminy.config.temp_file_location)
|
11
12
|
array = YAML.safe_load(yaml_content)
|
12
13
|
n_plus_one = NPlusOne.new(location: location, queries: queries)
|
13
14
|
|
14
15
|
if filepath_ignored?(n_plus_one.file)
|
15
|
-
Jiminy.logger.debug
|
16
|
+
Jiminy.logger.debug { "Ignoring n+1 instance #{n_plus_one}" }
|
16
17
|
return
|
17
18
|
end
|
18
19
|
|
19
20
|
if location_in_array?(location, array)
|
20
|
-
Jiminy.logger.debug
|
21
|
+
Jiminy.logger.debug { "Already reported n+1 instance #{n_plus_one}" }
|
21
22
|
return
|
22
23
|
end
|
23
24
|
|
24
25
|
array << n_plus_one.to_h
|
25
26
|
File.write(Jiminy.config.temp_file_location, array.to_yaml)
|
26
27
|
end
|
28
|
+
# rubocop:enable Metrics/AbcSize
|
27
29
|
|
28
30
|
private
|
29
31
|
|
data/lib/jiminy/reporting.rb
CHANGED
@@ -21,6 +21,9 @@ module Jiminy
|
|
21
21
|
comment_content = yaml_files.map do |yaml_file|
|
22
22
|
YAMLFileCommentPresenter.new(source_filepath: yaml_file, pr_number: options[:pr_number]).to_s
|
23
23
|
end.join(LINE_SEPARATOR)
|
24
|
+
|
25
|
+
return if comment_content.strip.empty?
|
26
|
+
|
24
27
|
if options[:dry_run]
|
25
28
|
Reporters::DryRunReporter.new(header: COMMENT_HEADER, body: comment_content).report!
|
26
29
|
else
|
data/lib/jiminy/version.rb
CHANGED
data/lib/jiminy.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jiminy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bodacious
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-05-
|
11
|
+
date: 2022-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: octokit
|
@@ -149,6 +149,13 @@ files:
|
|
149
149
|
- jiminy.gemspec
|
150
150
|
- lib/jiminy.rb
|
151
151
|
- lib/jiminy/cli.rb
|
152
|
+
- lib/jiminy/cli/exit_codes.rb
|
153
|
+
- lib/jiminy/cli/exit_codes/base.rb
|
154
|
+
- lib/jiminy/cli/exit_codes/pipeline_not_found.rb
|
155
|
+
- lib/jiminy/cli/exit_codes/process_timeout.rb
|
156
|
+
- lib/jiminy/cli/exit_codes/success.rb
|
157
|
+
- lib/jiminy/cli/exit_codes/workflow_not_found.rb
|
158
|
+
- lib/jiminy/cli/exit_codes/workflow_not_success.rb
|
152
159
|
- lib/jiminy/configuration.rb
|
153
160
|
- lib/jiminy/github_apiable.rb
|
154
161
|
- lib/jiminy/recording.rb
|