pig-ci-rails 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rubocop.yml +24 -0
- data/.travis.yml +21 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE +21 -0
- data/README.md +124 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/config/locales/pig_ci/en.yml +43 -0
- data/lib/pig_ci.rb +146 -0
- data/lib/pig_ci/api.rb +14 -0
- data/lib/pig_ci/api/reports.rb +36 -0
- data/lib/pig_ci/decorator.rb +9 -0
- data/lib/pig_ci/decorator/report_terminal_decorator.rb +19 -0
- data/lib/pig_ci/metric.rb +4 -0
- data/lib/pig_ci/metric/current.rb +30 -0
- data/lib/pig_ci/metric/historial/change_percentage.rb +37 -0
- data/lib/pig_ci/metric/historical.rb +52 -0
- data/lib/pig_ci/profiler.rb +41 -0
- data/lib/pig_ci/profiler/database_request.rb +5 -0
- data/lib/pig_ci/profiler/memory.rb +16 -0
- data/lib/pig_ci/profiler/request_time.rb +17 -0
- data/lib/pig_ci/profiler_engine.rb +40 -0
- data/lib/pig_ci/profiler_engine/rails.rb +61 -0
- data/lib/pig_ci/report.rb +64 -0
- data/lib/pig_ci/report/database_request.rb +2 -0
- data/lib/pig_ci/report/memory.rb +15 -0
- data/lib/pig_ci/report/request_time.rb +2 -0
- data/lib/pig_ci/summary.rb +4 -0
- data/lib/pig_ci/summary/html.rb +49 -0
- data/lib/pig_ci/summary/terminal.rb +30 -0
- data/lib/pig_ci/version.rb +3 -0
- data/lib/pig_ci/views/index.erb +70 -0
- data/lib/pig_ci/views/report.erb +30 -0
- data/pig_ci.gemspec +47 -0
- data/public/assets/application.css +3 -0
- data/public/assets/application.js +109 -0
- metadata +266 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: bf3c447e7716e880cb65a571d903404691cf724e564ee3f7ea6f45bcb2e4579a
|
4
|
+
data.tar.gz: a0fa3bd34791ca87aac66664911e35ff195bbc5425bfbda0f5b729a68fc0145a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9c84c537d59fd9c716c5308c6b268d2fdc3bb60d4edcba2777063de5bd782110e06491906ba33403f31d66ded07ca17a930e3d6185782f43e4e21823f69bb01a
|
7
|
+
data.tar.gz: 7dbbb125ab5fd4a4866bc4d3c1b3e3c58ffa9e118ee2f6ae962beb4a0f640d54f8916af9f2f99be91892c7fd4890b47be1dcc56b84f26b3af213c28615ff4267
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
AllCops:
|
2
|
+
Exclude:
|
3
|
+
- '.git/**/*'
|
4
|
+
- 'bin/*'
|
5
|
+
|
6
|
+
Style/FrozenStringLiteralComment:
|
7
|
+
EnforcedStyle: never
|
8
|
+
|
9
|
+
Style/BracesAroundHashParameters:
|
10
|
+
EnforcedStyle: context_dependent
|
11
|
+
|
12
|
+
Metrics/LineLength:
|
13
|
+
Max: 120
|
14
|
+
|
15
|
+
Metrics/BlockLength:
|
16
|
+
CountComments: true
|
17
|
+
Max: 25
|
18
|
+
ExcludedMethods: []
|
19
|
+
Exclude:
|
20
|
+
- "spec/**/*"
|
21
|
+
- '*.gemspec'
|
22
|
+
|
23
|
+
Style/ClassAndModuleChildren:
|
24
|
+
EnforcedStyle: compact
|
data/.travis.yml
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
---
|
2
|
+
sudo: false
|
3
|
+
|
4
|
+
language: ruby
|
5
|
+
|
6
|
+
cache: bundler
|
7
|
+
|
8
|
+
rvm:
|
9
|
+
- 2.3.8
|
10
|
+
- 2.4.5
|
11
|
+
- 2.5.3
|
12
|
+
- 2.6.3
|
13
|
+
- ruby-head
|
14
|
+
|
15
|
+
before_install:
|
16
|
+
- gem install bundler -v 2.0.1
|
17
|
+
|
18
|
+
script: "bundle exec rake spec"
|
19
|
+
|
20
|
+
notifications:
|
21
|
+
email: false
|
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at me@mikerogers.io. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2019 Mike Rogers
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
# PigCI
|
2
|
+
|
3
|
+
Monitor your Ruby Applications metrics (Memory, SQL Requests & Request Time) as part of your test suite.
|
4
|
+
|
5
|
+
Please consider supporting this project by adding [PigCI](https://pigci.com/) to your GitHub project & using this as part of CI. The CI tool will fail PRs that exceed metric threshold (e.g. a big increase in memory).
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
group :test do
|
13
|
+
gem 'pig-ci-rails'
|
14
|
+
end
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
```bash
|
20
|
+
bundle
|
21
|
+
```
|
22
|
+
|
23
|
+
Or install it yourself as:
|
24
|
+
|
25
|
+
```bash
|
26
|
+
gem install pig-ci-rails
|
27
|
+
```
|
28
|
+
|
29
|
+
## Usage
|
30
|
+
|
31
|
+
### On it's own
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
# In spec/rails_helper.rb
|
35
|
+
require 'pig_ci'
|
36
|
+
PigCI.start
|
37
|
+
```
|
38
|
+
|
39
|
+
### With [PigCI.com](https://pigci.com) - For sharing runs as a team via CI.
|
40
|
+
|
41
|
+
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).
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
# In spec/rails_helper.rb
|
45
|
+
require 'pig_ci'
|
46
|
+
PigCI.start do |config|
|
47
|
+
# When you connect your project, you'll be given an API key.
|
48
|
+
config.api_key = 'you-api-key-here'
|
49
|
+
end
|
50
|
+
```
|
51
|
+
|
52
|
+
### Configuring PigCI
|
53
|
+
|
54
|
+
This gems was setup to be configured by passing a block to the `PigCI.start` method, e.g:
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
# In spec/rails_helper.rb
|
58
|
+
require 'pig_ci'
|
59
|
+
PigCI.start do |config|
|
60
|
+
config.option = 'new_value'
|
61
|
+
|
62
|
+
# E.g. disable terminal summary output
|
63
|
+
config.generate_terminal_summary = false
|
64
|
+
end # if RSpec.configuration.files_to_run.count > 1
|
65
|
+
```
|
66
|
+
|
67
|
+
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).
|
68
|
+
|
69
|
+
### Framework support
|
70
|
+
|
71
|
+
Currently this gem only supports Ruby on Rails.
|
72
|
+
|
73
|
+
### Metric notes
|
74
|
+
|
75
|
+
#### Memory
|
76
|
+
|
77
|
+
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.
|
78
|
+
|
79
|
+
You can improve its accuracy by updating your `config/environments/test.rb` to have the line:
|
80
|
+
|
81
|
+
```ruby
|
82
|
+
config.eager_load = true
|
83
|
+
```
|
84
|
+
|
85
|
+
#### Request Time
|
86
|
+
|
87
|
+
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).
|
88
|
+
|
89
|
+
Alternatively add:
|
90
|
+
|
91
|
+
```ruby
|
92
|
+
Rails.application.call(::Rack::MockRequest.env_for('/'))
|
93
|
+
```
|
94
|
+
|
95
|
+
Before you call `PigCI.start`.
|
96
|
+
|
97
|
+
## Authors
|
98
|
+
|
99
|
+
* This gem was made by [@MikeRogers0](https://github.com/MikeRogers0).
|
100
|
+
* 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.
|
101
|
+
* The HTML output was inspired by [simplecov](https://github.com/colszowka/simplecov).
|
102
|
+
|
103
|
+
## Development
|
104
|
+
|
105
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
106
|
+
|
107
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
108
|
+
|
109
|
+
## TODO
|
110
|
+
|
111
|
+
Features I'd like to add at some point:
|
112
|
+
|
113
|
+
* HTML output to include branch - Right now they're just timestamps which makes filtering hard.
|
114
|
+
* Should I disable terminal output by default? It feels like noise.
|
115
|
+
* Should I reject database requests that have a value of 0? I think so.
|
116
|
+
* Document setting branch/commit encase of weird CI.
|
117
|
+
|
118
|
+
## Contributing
|
119
|
+
|
120
|
+
Bug reports and pull requests are welcome on GitHub at [PigCI/pig-ci-rails](https://github.com/PigCI/pig-ci-rails). This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
121
|
+
|
122
|
+
## Code of Conduct
|
123
|
+
|
124
|
+
Everyone interacting in the PigCI project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/PigCI/pig-ci-rails/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "pig_ci"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
en:
|
2
|
+
pig_ci:
|
3
|
+
api:
|
4
|
+
reports:
|
5
|
+
error: 'Unable to connect to PigCI API: %{error}'
|
6
|
+
summary:
|
7
|
+
saved_successfully: PigCI report generated to %{output_directory}
|
8
|
+
title: PigCI Results
|
9
|
+
view_historic_reports: 'Historic Reports'
|
10
|
+
footer_html: |
|
11
|
+
<p>Generated <time datetime="%{generated_at}">%{generated_at}</time> by PigCI.</p>
|
12
|
+
<p>Support <a href="https://pigci.com/" target="_blank" rel="noopener">PigCI</a> by <a href="https://github.com/apps/pigci/installations/new" target="_blank" rel="noopener">adding us on GitHub</a>.</p>
|
13
|
+
|
14
|
+
report:
|
15
|
+
memory:
|
16
|
+
name: Peak memory per a request
|
17
|
+
attributes:
|
18
|
+
key: Key
|
19
|
+
max: Max (MB)
|
20
|
+
min: Min (MB)
|
21
|
+
mean: Mean (MB)
|
22
|
+
number_of_requests: Requests
|
23
|
+
max_change_percentage: "% Change"
|
24
|
+
|
25
|
+
request_time:
|
26
|
+
name: Request Time
|
27
|
+
attributes:
|
28
|
+
key: Key
|
29
|
+
max: Max (ms)
|
30
|
+
min: Min (ms)
|
31
|
+
mean: Mean (ms)
|
32
|
+
number_of_requests: Requests
|
33
|
+
max_change_percentage: "% Change"
|
34
|
+
|
35
|
+
database_request:
|
36
|
+
name: Queries to the database
|
37
|
+
attributes:
|
38
|
+
key: Key
|
39
|
+
max: Max
|
40
|
+
min: Min
|
41
|
+
mean: Mean
|
42
|
+
number_of_requests: Requests
|
43
|
+
max_change_percentage: "% Change"
|
data/lib/pig_ci.rb
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
require 'active_support'
|
2
|
+
require 'active_support/core_ext/string/inflections'
|
3
|
+
|
4
|
+
require 'pig_ci/version'
|
5
|
+
require 'pig_ci/api'
|
6
|
+
require 'pig_ci/decorator'
|
7
|
+
require 'pig_ci/summary'
|
8
|
+
require 'pig_ci/profiler_engine'
|
9
|
+
require 'pig_ci/profiler'
|
10
|
+
require 'pig_ci/metric'
|
11
|
+
require 'pig_ci/report'
|
12
|
+
|
13
|
+
module PigCI
|
14
|
+
extend self
|
15
|
+
|
16
|
+
attr_accessor :pid
|
17
|
+
|
18
|
+
attr_writer :tmp_directory
|
19
|
+
def tmp_directory
|
20
|
+
@tmp_directory || Pathname.new(Dir.getwd).join('tmp', 'pig-ci')
|
21
|
+
end
|
22
|
+
|
23
|
+
attr_writer :output_directory
|
24
|
+
def output_directory
|
25
|
+
@output_directory || Pathname.new(Dir.getwd).join('pig-ci')
|
26
|
+
end
|
27
|
+
|
28
|
+
attr_accessor :generate_terminal_summary
|
29
|
+
def generate_terminal_summary?
|
30
|
+
@generate_terminal_summary.nil? || @generate_terminal_summary
|
31
|
+
end
|
32
|
+
|
33
|
+
attr_accessor :generate_html_summary
|
34
|
+
def generate_html_summary?
|
35
|
+
@generate_html_summary.nil? || @generate_html_summary
|
36
|
+
end
|
37
|
+
|
38
|
+
attr_writer :max_change_percentage_precision
|
39
|
+
def max_change_percentage_precision
|
40
|
+
@max_change_percentage_precision || 1
|
41
|
+
end
|
42
|
+
|
43
|
+
attr_writer :report_memory_precision
|
44
|
+
def report_memory_precision
|
45
|
+
@report_memory_precision || 2
|
46
|
+
end
|
47
|
+
|
48
|
+
attr_writer :terminal_report_row_limit
|
49
|
+
def terminal_report_row_limit
|
50
|
+
@terminal_report_row_limit || -1
|
51
|
+
end
|
52
|
+
|
53
|
+
# PigCI.report_row_sort_by = Proc.new { |d| d[:max_change_percentage] * -1 }
|
54
|
+
attr_writer :report_row_sort_by
|
55
|
+
def report_row_sort_by(data)
|
56
|
+
(@report_row_sort_by || proc { |d| d[:max].to_i * -1 }).call(data)
|
57
|
+
end
|
58
|
+
|
59
|
+
attr_writer :historical_data_run_limit
|
60
|
+
def historical_data_run_limit
|
61
|
+
@historical_data_run_limit ||= 10
|
62
|
+
end
|
63
|
+
|
64
|
+
attr_writer :run_timestamp
|
65
|
+
def run_timestamp
|
66
|
+
@run_timestamp ||= Time.now.to_i.to_s
|
67
|
+
end
|
68
|
+
|
69
|
+
attr_writer :profiler_engine
|
70
|
+
def profiler_engine
|
71
|
+
@profiler_engine ||= PigCI::ProfilerEngine::Rails.new
|
72
|
+
end
|
73
|
+
|
74
|
+
attr_writer :api_base_uri
|
75
|
+
def api_base_uri
|
76
|
+
@api_base_uri || 'https://api.pigci.com'
|
77
|
+
end
|
78
|
+
|
79
|
+
attr_accessor :api_verify_ssl
|
80
|
+
def api_verify_ssl?
|
81
|
+
!@api_verify_ssl.nil? ? @api_verify_ssl : true
|
82
|
+
end
|
83
|
+
|
84
|
+
attr_accessor :api_key
|
85
|
+
def api_key?
|
86
|
+
!@api_key.nil? && @api_key != ''
|
87
|
+
end
|
88
|
+
|
89
|
+
attr_writer :commit_sha1
|
90
|
+
def commit_sha1
|
91
|
+
@commit_sha1 || ENV['CIRCLE_SHA1'] || ENV['TRAVIS_COMMIT'] || `git rev-parse HEAD`.strip
|
92
|
+
end
|
93
|
+
|
94
|
+
attr_writer :head_branch
|
95
|
+
def head_branch
|
96
|
+
@head_branch || ENV['CIRCLE_BRANCH'] || ENV['TRAVIS_BRANCH'] || `git rev-parse --abbrev-ref HEAD`.strip
|
97
|
+
end
|
98
|
+
|
99
|
+
attr_writer :locale
|
100
|
+
def locale
|
101
|
+
@locale || :en
|
102
|
+
end
|
103
|
+
|
104
|
+
module_function
|
105
|
+
|
106
|
+
def start(&block)
|
107
|
+
self.pid = Process.pid
|
108
|
+
|
109
|
+
block.call(self) if block_given?
|
110
|
+
|
111
|
+
# Add our translations
|
112
|
+
load_i18ns!
|
113
|
+
|
114
|
+
# Make sure our directories exist
|
115
|
+
Dir.mkdir(tmp_directory) unless File.exist?(tmp_directory)
|
116
|
+
Dir.mkdir(output_directory) unless File.exist?(output_directory)
|
117
|
+
|
118
|
+
# Purge any previous logs and attach some listeners
|
119
|
+
profiler_engine.setup!
|
120
|
+
end
|
121
|
+
|
122
|
+
def load_i18ns!
|
123
|
+
I18n.available_locales << PigCI.locale
|
124
|
+
I18n.load_path += Dir["#{File.expand_path('../config/locales/pig_ci', __dir__)}/*.{rb,yml}"]
|
125
|
+
end
|
126
|
+
|
127
|
+
def run_exit_tasks!
|
128
|
+
return if PigCI.pid != Process.pid || !PigCI.profiler_engine.request_captured?
|
129
|
+
|
130
|
+
# Save all the reports as JSON
|
131
|
+
profiler_engine.profilers.each(&:save!)
|
132
|
+
|
133
|
+
# Print the report summary to Terminal
|
134
|
+
PigCI::Summary::Terminal.new(reports: profiler_engine.reports).print! if PigCI.generate_terminal_summary?
|
135
|
+
|
136
|
+
# Save the report summary to the project root.
|
137
|
+
PigCI::Summary::HTML.new(reports: profiler_engine.reports).save! if PigCI.generate_html_summary?
|
138
|
+
|
139
|
+
# If they have an API key, share it with PigCI.com
|
140
|
+
PigCI::Api::Reports.new(reports: profiler_engine.reports).share! if PigCI.api_key?
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
at_exit do
|
145
|
+
PigCI.run_exit_tasks!
|
146
|
+
end
|