pig-ci-rails 0.1.1 → 0.1.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: aa85e7daa23732df9df64cf061da94032f1546feeee471e8acb2fc9a371b4ac8
4
- data.tar.gz: 40c1e02b9ebc1e0983341bde07ea117daff01ce9c5c063018c7bc9ca18d4e80c
3
+ metadata.gz: db71bd9b82ebe9f9f4e9d88184f6c85f8883d4f94043df05dfc22acef1ca7a6e
4
+ data.tar.gz: 621ff89d5cdb3cac6b9dbeb51d4f5f4b6d929c9fb7488ecf6b10600add3beff1
5
5
  SHA512:
6
- metadata.gz: 61a77bce177551a4813bde57f4a8485cfc5f1919c738e67030381a7618a9bacdfd69ee157a7a285cae1418d8deb0515abb2409eff53707a17b6a3e6a795d268b
7
- data.tar.gz: 8c238ab03b28ac1b556a466198ae8849f304f372d343deee6d78d75882bde588567479ee72ed7faeda6678f8d587e11c593a8ef6d4ef21c76c515ca8fd09ee21
6
+ metadata.gz: 05f65a26d7dfcf639d28087f530d93b661051d5145afe9906fa8dc07247980dc76096b389e0e44916b5586b27901722c09554b1614b4fe110db70f3b7c55effa
7
+ data.tar.gz: 12bbaa13fa3a727a272220d6cedeabb6758c4c9099835d8a00fb10e7726665ebb092104a4724a319347fb4af05641f3966010d75121e68ffee08c065f0e98ec5
data/CHANGELOG.md CHANGED
@@ -2,14 +2,16 @@
2
2
 
3
3
  ## 0.1.2
4
4
 
5
- * Codacy changes
5
+ * [Improving Codacy Rating](https://github.com/PigCI/pig-ci-rails/pull/4)
6
+ * [Correcting issue where app warm up would negatively affect timezone](https://github.com/PigCI/pig-ci-rails/pull/5)
7
+ * [Adding option to control if app is preloaded or not](https://github.com/PigCI/pig-ci-rails/pull/3)
6
8
 
7
9
  ## 0.1.1
8
10
 
9
- * Updating API Endpoints for PigCI.com
10
- * Adding fallback for if API is down to not fail CI.
11
- * Removing unnecessary JS,
11
+ * Updating API Endpoints for PigCI.com
12
+ * Adding fallback for if API is down to not fail CI.
13
+ * Removing unnecessary JS,
12
14
 
13
15
  ## 0.1.0
14
16
 
15
- * Initial Release
17
+ * Initial Release
data/README.md CHANGED
@@ -42,7 +42,7 @@ require 'pig_ci'
42
42
  PigCI.start
43
43
  ```
44
44
 
45
- ### With [PigCI.com](https://pigci.com) - For sharing runs as a team via CI.
45
+ ### With [PigCI.com](https://pigci.com) - For sharing runs as a team via CI
46
46
 
47
47
  You can hookup your project to PigCI.com, this will fail PRs when metric thresholds are exceeded (e.g. your app see a big increase in memory).
48
48
 
@@ -67,7 +67,7 @@ PigCI.start do |config|
67
67
 
68
68
  # E.g. disable terminal summary output
69
69
  config.generate_terminal_summary = false
70
- end # if RSpec.configuration.files_to_run.count > 1
70
+ end # if ENV['RUN_PIG_CI'] || RSpec.configuration.files_to_run.count > 1
71
71
  ```
72
72
 
73
73
  You can see the full configuration options [lib/pig_ci.rb](https://github.com/PigCI/pig-ci-rails/blob/master/lib/pig_ci.rb#L21).
@@ -78,33 +78,39 @@ Currently this gem only supports Ruby on Rails.
78
78
 
79
79
  ### Metric notes
80
80
 
81
+ Minor fluctuations in memory usage and request time are to be expected and are nothing to worry about. Though any large spike is a signal of something worth investigating.
82
+
81
83
  #### Memory
82
84
 
83
- Minor fluctuations in memory usage and request time are to be expected and are nothing to worry about. Though any large spike is a signal of something worth investigating.
85
+ By default, this gem will tell Rails to eager load your application on startup. This aims to help identify leaks, over just pure bulk.
84
86
 
85
- You can improve its accuracy by updating your `config/environments/test.rb` to have the line:
87
+ You can disable this functionality by setting your configuration to be:
86
88
 
87
89
  ```ruby
88
- config.eager_load = true
90
+ require 'pig_ci'
91
+ PigCI.start do |config|
92
+ config.during_setup_eager_load_application = false
93
+ end
89
94
  ```
90
95
 
91
96
  #### Request Time
92
97
 
93
- Often the first request test will be slow, as rails is loading a full environment. While this metric is useful, I'd suggest focusing on other metrics (like memory, or database requests).
98
+ Often the first request test will be slow, as rails is loading a full environment. To mitigate this issue, this gem will make a blank request to your application before your test suite starts.
94
99
 
95
- Alternatively add:
100
+ You can disable this functionality by setting your configuration to be:
96
101
 
97
102
  ```ruby
98
- Rails.application.call(::Rack::MockRequest.env_for('/'))
103
+ require 'pig_ci'
104
+ PigCI.start do |config|
105
+ config.during_setup_make_blank_application_request = false
106
+ end
99
107
  ```
100
108
 
101
- Before you call `PigCI.start`.
102
-
103
109
  ## Authors
104
110
 
105
- * This gem was made by [@MikeRogers0](https://github.com/MikeRogers0).
106
- * It was originally inspired by [oink](https://github.com/noahd1/oink), after it was used to [monitor acceptance tests](https://mikerogers.io/2015/03/28/monitor-rails-memory-usage-in-integration-tests.html) and it spotted a memory leak. It seemed like something that would be useful to have as part of CI.
107
- * The HTML output was inspired by [simplecov](https://github.com/colszowka/simplecov).
111
+ * This gem was made by [@MikeRogers0](https://github.com/MikeRogers0).
112
+ * It was originally inspired by [oink](https://github.com/noahd1/oink), after it was used to [monitor acceptance tests](https://mikerogers.io/2015/03/28/monitor-rails-memory-usage-in-integration-tests.html) and it spotted a memory leak. It seemed like something that would be useful to have as part of CI.
113
+ * The HTML output was inspired by [simplecov](https://github.com/colszowka/simplecov).
108
114
 
109
115
  ## Development
110
116
 
@@ -116,11 +122,11 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
116
122
 
117
123
  Features I'd like to add at some point:
118
124
 
119
- * HTML output to include branch - Right now they're just timestamps which makes filtering hard.
120
- * Should I disable terminal output by default? It feels like noise.
121
- * Should I reject database requests that have a value of 0? I think so.
122
- * Document setting branch/commit encase of weird CI.
123
- * Add rake rake for submitting reports.
125
+ * HTML output to include branch - Right now they're just timestamps which makes filtering hard.
126
+ * Should I disable terminal output by default? It feels like noise.
127
+ * Should I reject database requests that have a value of 0? I think so.
128
+ * Document setting branch/commit encase of weird CI.
129
+ * Add rake rake for submitting reports.
124
130
 
125
131
  ## Contributing
126
132
 
@@ -18,7 +18,7 @@ class PigCI::Api::Reports < PigCI::Api
18
18
 
19
19
  def post_payload
20
20
  self.class.post(
21
- '/api/v1/reports',
21
+ '/v1/reports',
22
22
  base_uri: PigCI.api_base_uri,
23
23
  verify: PigCI.api_verify_ssl?,
24
24
  body: payload,
@@ -20,7 +20,8 @@ class PigCI::ProfilerEngine::Rails < ::PigCI::ProfilerEngine
20
20
 
21
21
  def setup!
22
22
  super do
23
- eager_load_rails!
23
+ eager_load_rails! if PigCI.during_setup_eager_load_application?
24
+ make_blank_application_request! if PigCI.during_setup_make_blank_application_request?
24
25
  end
25
26
  end
26
27
 
@@ -31,9 +32,14 @@ class PigCI::ProfilerEngine::Rails < ::PigCI::ProfilerEngine
31
32
  ::Rails.application.eager_load!
32
33
  ::Rails::Engine.subclasses.map(&:instance).each(&:eager_load!)
33
34
  ::ActiveRecord::Base.descendants
35
+ end
34
36
 
37
+ def make_blank_application_request!
35
38
  # Make a call to the root path to load up as much of rails as possible
36
- ::Rails.application.call(::Rack::MockRequest.env_for('/'))
39
+ # Done within a timezone block as it affects the timezone.
40
+ Time.use_zone('UTC') do
41
+ ::Rails.application.call(::Rack::MockRequest.env_for('/'))
42
+ end
37
43
  end
38
44
 
39
45
  def attach_listeners!
@@ -1,3 +1,3 @@
1
1
  module PigCI
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.1.2'.freeze
3
3
  end
data/lib/pig_ci.rb CHANGED
@@ -45,6 +45,16 @@ module PigCI
45
45
  @report_memory_precision || 2
46
46
  end
47
47
 
48
+ attr_writer :during_setup_eager_load_application
49
+ def during_setup_eager_load_application?
50
+ @during_setup_eager_load_application.nil? || @during_setup_eager_load_application
51
+ end
52
+
53
+ attr_writer :during_setup_make_blank_application_request
54
+ def during_setup_make_blank_application_request?
55
+ @during_setup_make_blank_application_request.nil? || @during_setup_make_blank_application_request
56
+ end
57
+
48
58
  attr_writer :terminal_report_row_limit
49
59
  def terminal_report_row_limit
50
60
  @terminal_report_row_limit || -1
@@ -73,7 +83,7 @@ module PigCI
73
83
 
74
84
  attr_writer :api_base_uri
75
85
  def api_base_uri
76
- @api_base_uri || 'https://api.pigci.com'
86
+ @api_base_uri || 'https://api.pigci.com/api'
77
87
  end
78
88
 
79
89
  attr_accessor :api_verify_ssl
@@ -88,12 +98,12 @@ module PigCI
88
98
 
89
99
  attr_writer :commit_sha1
90
100
  def commit_sha1
91
- @commit_sha1 || ENV['CIRCLE_SHA1'] || ENV['TRAVIS_COMMIT'] || `git rev-parse HEAD`.strip
101
+ @commit_sha1 || ENV['CI_COMMIT_ID'] || ENV['CIRCLE_SHA1'] || ENV['TRAVIS_COMMIT'] || `git rev-parse HEAD`.strip
92
102
  end
93
103
 
94
104
  attr_writer :head_branch
95
105
  def head_branch
96
- @head_branch || ENV['CIRCLE_BRANCH'] || ENV['TRAVIS_BRANCH'] || `git rev-parse --abbrev-ref HEAD`.strip
106
+ @head_branch || ENV['CI_BRANCH'] || ENV['CIRCLE_BRANCH'] || ENV['TRAVIS_BRANCH'] || `git rev-parse --abbrev-ref HEAD`.strip
97
107
  end
98
108
 
99
109
  attr_writer :locale
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pig-ci-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Rogers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-31 00:00:00.000000000 Z
11
+ date: 2019-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport