rspec_profiling 0.0.8 → 0.0.9
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 +4 -4
- data/.github/workflows/release.yaml +12 -9
- data/CHANGELOG.md +16 -0
- data/README.md +13 -0
- data/lib/rspec_profiling/collectors/csv.rb +1 -0
- data/lib/rspec_profiling/collectors/json.rb +1 -0
- data/lib/rspec_profiling/config.rb +1 -0
- data/lib/rspec_profiling/example.rb +36 -0
- data/lib/rspec_profiling/run.rb +1 -0
- data/lib/rspec_profiling/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9b5f4ed5db1ef327545a3609ecaa955c0e9c438842c36c2efd1f0c5fdcf6753
|
4
|
+
data.tar.gz: 4012c683e52eb5ae99766d904b9b89fea1c5163c88aaf353f70ed8faa2c3e592
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 428016ee95be0dd84792839f468d1da94dba1e17dd02197c3b077b7fc486457d9c67a763bba11b8a25802e834f34d9a7fef9713b04e4ec6099ceb944062f3989
|
7
|
+
data.tar.gz: 3b6f6731030a443fe2bc3860f4ac1c8a9a9d91818b147a1867ed898e39004fc434e04b1eab0e3f353493ef76b1bdd7c1dc8f8512777a3bf31c8b2f3c2e8de35b
|
@@ -6,35 +6,38 @@ on:
|
|
6
6
|
branches: [main]
|
7
7
|
workflow_dispatch: # allow manual deployment through GitHub Action UI
|
8
8
|
jobs:
|
9
|
-
|
9
|
+
version-check:
|
10
10
|
runs-on: ubuntu-latest
|
11
11
|
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
|
12
|
+
outputs:
|
13
|
+
changed: ${{ steps.check.outputs.any_changed }}
|
12
14
|
steps:
|
13
15
|
- uses: actions/checkout@v4
|
14
|
-
- name:
|
15
|
-
id:
|
16
|
+
- name: Check if version has been updated
|
17
|
+
id: check
|
16
18
|
uses: tj-actions/changed-files@v42
|
17
19
|
with:
|
18
20
|
files: lib/rspec_profiling/version.rb
|
21
|
+
release:
|
22
|
+
runs-on: ubuntu-latest
|
23
|
+
needs: version-check
|
24
|
+
if: ${{ github.event_name == 'workflow_dispatch' || needs.version-check.outputs.changed == 'true' }}
|
25
|
+
steps:
|
26
|
+
- uses: actions/checkout@v4
|
19
27
|
- name: Set up Ruby
|
20
|
-
if: ${{ github.event_name == 'workflow_dispatch' || steps.version-file-changed.outputs.any_changed == 'true' }}
|
21
28
|
uses: ruby/setup-ruby@v1
|
22
29
|
with:
|
23
30
|
ruby-version: 3.2
|
24
31
|
bundler-cache: true
|
25
32
|
- name: Installing dependencies
|
26
|
-
|
27
|
-
run: bundle check --path=vendor/bundle || bundle install --path=vendor/bundle
|
33
|
+
run: bundle install
|
28
34
|
- name: Build gem file
|
29
|
-
if: ${{ github.event_name == 'workflow_dispatch' || steps.version-file-changed.outputs.any_changed == 'true' }}
|
30
35
|
run: bundle exec rake build
|
31
36
|
- uses: fac/ruby-gem-setup-credentials-action@v2
|
32
|
-
if: ${{ github.event_name == 'workflow_dispatch' || steps.version-file-changed.outputs.any_changed == 'true' }}
|
33
37
|
with:
|
34
38
|
user: ""
|
35
39
|
key: rubygems
|
36
40
|
token: ${{secrets.RUBY_GEMS_API_KEY}}
|
37
41
|
- uses: fac/ruby-gem-push-action@v2
|
38
|
-
if: ${{ github.event_name == 'workflow_dispatch' || steps.version-file-changed.outputs.any_changed == 'true' }}
|
39
42
|
with:
|
40
43
|
key: rubygems
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
## 0.0.9
|
2
|
+
|
3
|
+
* feat: Add support for ownership tagging via magic comment [#10]
|
4
|
+
* chore: simplify release Github Action [#9]
|
5
|
+
|
6
|
+
## 0.0.8
|
7
|
+
|
8
|
+
* chore: add badges to README and add gemspec metadata [#6]
|
9
|
+
* chore: setup local development [#3]
|
10
|
+
* chore: upgrade ruby [#4]
|
11
|
+
* chore: standardize repository for procore open-source[#2]
|
12
|
+
|
13
|
+
## 0.0.7
|
14
|
+
|
15
|
+
* Migrate to procore-oss/rspec_profiling repo [#1]
|
16
|
+
|
1
17
|
## 0.0.6
|
2
18
|
|
3
19
|
* Create indexes for DB collectors [#26]
|
data/README.md
CHANGED
@@ -87,6 +87,18 @@ RspecProfiling.configure do |config|
|
|
87
87
|
end
|
88
88
|
```
|
89
89
|
|
90
|
+
#### Custom Ownership Tracking
|
91
|
+
|
92
|
+
If the repo you are running the profiler on has many teams working on it, you can use the `magic_comment` option to specify a comment at the top of files to scan for ownership tracking. In the example below,
|
93
|
+
the profiler will look for `#team: <owner>` comments at the top of each file and add <owner> to the results.
|
94
|
+
The default is `team` but can be configured to any comment you want.
|
95
|
+
|
96
|
+
```Ruby
|
97
|
+
RspecProfiling.configure do |config|
|
98
|
+
config.magic_comment = 'team'
|
99
|
+
end
|
100
|
+
```
|
101
|
+
|
90
102
|
#### Custom Event Subscriptions
|
91
103
|
|
92
104
|
```Ruby
|
@@ -204,6 +216,7 @@ end
|
|
204
216
|
- `table_name` - the database table name in which results are stored
|
205
217
|
- `csv_path` - the directory in which CSV files are dumped
|
206
218
|
- `collector` - collector to use
|
219
|
+
- `magic_comment` - comment to scan top of files to enable ownership tracking (EX: `#team: tooling`)
|
207
220
|
|
208
221
|
### Usage in a script
|
209
222
|
|
@@ -1,4 +1,9 @@
|
|
1
1
|
require "benchmark"
|
2
|
+
require "rspec_profiling/vcs/git"
|
3
|
+
require "rspec_profiling/vcs/svn"
|
4
|
+
require "rspec_profiling/vcs/git_svn"
|
5
|
+
require "rspec_profiling/collectors/csv"
|
6
|
+
require "rspec_profiling/collectors/json"
|
2
7
|
|
3
8
|
module RspecProfiling
|
4
9
|
class Example
|
@@ -50,6 +55,10 @@ module RspecProfiling
|
|
50
55
|
execution_result.run_time
|
51
56
|
end
|
52
57
|
|
58
|
+
def owner_tag
|
59
|
+
ownership_for_file(metadata[:file_path])
|
60
|
+
end
|
61
|
+
|
53
62
|
def query_count
|
54
63
|
counts[:query_count]
|
55
64
|
end
|
@@ -112,5 +121,32 @@ module RspecProfiling
|
|
112
121
|
def verbose_record_event?(event_name)
|
113
122
|
metadata[:record_events].to_a.include?(event_name)
|
114
123
|
end
|
124
|
+
|
125
|
+
def ownership_for_file(file_path)
|
126
|
+
return nil if RspecProfiling.config.magic_comment.empty?
|
127
|
+
ownership_regex = /(^#\s*#{RspecProfiling.config.magic_comment}:\s*)\K(?<#{RspecProfiling.config.magic_comment}>.*$)/.freeze
|
128
|
+
comments = top_comments_from_file(file_path)
|
129
|
+
matching_line = comments.detect { |line| line.match?(ownership_regex) }
|
130
|
+
extract_ownership(matching_line, ownership_regex) if matching_line
|
131
|
+
end
|
132
|
+
|
133
|
+
def top_comments_from_file(file_path)
|
134
|
+
with_file(file_path) do |f|
|
135
|
+
f.take_while { |line| line.start_with?('#', "\n") }
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
def with_file(file_path)
|
140
|
+
if File.exist?(file_path)
|
141
|
+
File.open(file_path)
|
142
|
+
else
|
143
|
+
puts "File not found: #{file_path}"
|
144
|
+
[]
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
def extract_ownership(matching_line, regex)
|
149
|
+
matching_line.match(regex)[RspecProfiling.config.magic_comment.to_sym]
|
150
|
+
end
|
115
151
|
end
|
116
152
|
end
|
data/lib/rspec_profiling/run.rb
CHANGED
@@ -42,6 +42,7 @@ module RspecProfiling
|
|
42
42
|
status: @current_example.status,
|
43
43
|
exception: @current_example.exception,
|
44
44
|
time: @current_example.time,
|
45
|
+
owner_tag: @current_example.owner_tag,
|
45
46
|
query_count: @current_example.query_count,
|
46
47
|
query_time: @current_example.query_time,
|
47
48
|
request_count: @current_example.request_count,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec_profiling
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Procore Technologies, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|