feature_map 1.2.4 → 1.2.5
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/README.md +2 -2
- data/bin/docs +18 -0
- data/lib/feature_map/cli.rb +45 -7
- data/lib/feature_map/code_features.rb +1 -0
- data/lib/feature_map/commit.rb +1 -0
- data/lib/feature_map/configuration.rb +1 -0
- data/lib/feature_map/constants.rb +1 -0
- data/lib/feature_map/mapper.rb +1 -0
- data/lib/feature_map/output_color.rb +1 -0
- data/lib/feature_map/private/additional_metrics_file.rb +1 -0
- data/lib/feature_map/private/assignment_applicator.rb +1 -0
- data/lib/feature_map/private/assignment_mappers/feature_definition_assignment.rb +14 -0
- data/lib/feature_map/private/assignments_file.rb +1 -0
- data/lib/feature_map/private/code_cov.rb +1 -0
- data/lib/feature_map/private/cyclomatic_complexity_calculator.rb +1 -0
- data/lib/feature_map/private/docs/index.html +99 -94
- data/lib/feature_map/private/documentation_site.rb +1 -0
- data/lib/feature_map/private/extension_loader.rb +1 -0
- data/lib/feature_map/private/feature_assigner.rb +1 -0
- data/lib/feature_map/private/feature_metrics_calculator.rb +1 -0
- data/lib/feature_map/private/feature_plugins/assignment.rb +1 -0
- data/lib/feature_map/private/glob_cache.rb +1 -0
- data/lib/feature_map/private/health_calculator.rb +1 -0
- data/lib/feature_map/private/lines_of_code_calculator.rb +1 -0
- data/lib/feature_map/private/metrics_file.rb +1 -0
- data/lib/feature_map/private/percentile_metrics_calculator.rb +1 -0
- data/lib/feature_map/private/release_notification_builder.rb +1 -0
- data/lib/feature_map/private/simple_cov_resultsets.rb +30 -0
- data/lib/feature_map/private/test_coverage_file.rb +1 -0
- data/lib/feature_map/private/test_pyramid_file.rb +1 -0
- data/lib/feature_map/private/todo_inspector.rb +1 -0
- data/lib/feature_map/private.rb +9 -0
- data/lib/feature_map/validator.rb +1 -0
- data/lib/feature_map.rb +5 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 735b90dee1fa2dbc01d10b57bb2b53a8350edb3465c04e11760f19f6613893ce
|
4
|
+
data.tar.gz: f1bdfbdd9cca2a4f384b60c1598ef3fc0add164607cb51cd7aadc9e06fda1407
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d763d8fa726924f6d90653b748ae50d8d82849de44f20cc2de72affa2ddddd20d537d2dab2079767a72cdc33bd7fd6442c3d3cb93275b8ddfd34392001182b7
|
7
|
+
data.tar.gz: 7c21f6d7e0d9e1da75fd0ec638041e20c0be5997af75ed0fb8ac49be213c7066b2c2bf488f84939c6b0eb741435325946859c66bc5fd14d3b91a13c90c7832e4
|
data/README.md
CHANGED
@@ -42,13 +42,13 @@ The documentation site is a React application which is built on the Vite framewo
|
|
42
42
|
|
43
43
|
Compilation of the build asset is done via `npm run build` from within the [docs](./docs) folder. This compiles the React app into a single static file which is placed in [./lib/feature_map/private/docs/index.html](./lib/feature_map/private/docs/index.html]).
|
44
44
|
|
45
|
-
The documentation site may be run locally to aid in development via `bin/docs`. It
|
45
|
+
The documentation site may be run locally to aid in development via `bin/docs`. It will generate test coverage and metrics data, and make it available to the docs site running in development mode.
|
46
46
|
|
47
47
|
More information on the development of the documentation site may be found in the [Docs Readme](./docs/README.md).
|
48
48
|
|
49
49
|
### README Site
|
50
50
|
|
51
|
-
The README site is built with Jekyll and TailwindCSS and is hosted via GitHub Pages at:
|
51
|
+
The README site is built with Jekyll and TailwindCSS and is hosted via GitHub Pages at: [https://beyond-finance.github.io/feature_map](https://beyond-finance.github.io/feature_map/). It can be run locally to aid in development via `bin/readme`.
|
52
52
|
|
53
53
|
### Publication
|
54
54
|
|
data/bin/docs
CHANGED
@@ -5,5 +5,23 @@ if ! gem list foreman -i --silent; then
|
|
5
5
|
gem install foreman
|
6
6
|
fi
|
7
7
|
|
8
|
+
COVERAGE_FILE="coverage/.resultset.json"
|
9
|
+
|
10
|
+
if [ ! -f $COVERAGE_FILE ] || [ $(find $COVERAGE_FILE -mtime +7 -print 2>/dev/null) ]; then
|
11
|
+
echo "###############################################"
|
12
|
+
echo "# No test coverage file found. Regenerating. #"
|
13
|
+
echo "###############################################"
|
14
|
+
|
15
|
+
bundle exec rspec
|
16
|
+
bundle exec featuremap test_coverage --use-simplecov --simplecov-path $COVERAGE_FILE
|
17
|
+
else
|
18
|
+
echo "#############################################################"
|
19
|
+
echo "# Using recent coverage file. If you'd like to regenerate: #"
|
20
|
+
echo "# > rm $COVERAGE_FILE #"
|
21
|
+
echo "#############################################################"
|
22
|
+
fi
|
23
|
+
|
24
|
+
bundle exec featuremap docs
|
25
|
+
cat .feature_map/docs/feature-map-config.js | sed 's/window\.FEATURE_MAP_CONFIG = /export const sampleConfig = /' > docs/sample_config.js
|
8
26
|
cd docs && npm install && cd ..
|
9
27
|
exec foreman start -f Procfile.docs "$@"
|
data/lib/feature_map/cli.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# @feature Core Library
|
1
2
|
require 'optparse'
|
2
3
|
require 'pathname'
|
3
4
|
require 'fileutils'
|
@@ -152,30 +153,67 @@ module FeatureMap
|
|
152
153
|
end
|
153
154
|
|
154
155
|
def self.test_coverage!(argv)
|
156
|
+
options = {
|
157
|
+
source: :codecov,
|
158
|
+
simplecov_paths: []
|
159
|
+
}
|
160
|
+
|
155
161
|
parser = OptionParser.new do |opts|
|
156
162
|
opts.banner = <<~MSG
|
157
163
|
Usage: bin/featuremap test_coverage [options] [code_cov_commit_sha].
|
158
|
-
|
164
|
+
|
165
|
+
Options:
|
166
|
+
--use-simplecov Use SimpleCov instead of CodeCov
|
167
|
+
--simplecov-path PATH Path to a SimpleCov resultset.json file (can be specified multiple times)
|
168
|
+
|
169
|
+
Note:#{' '}
|
170
|
+
- CodeCov mode requires environment variable `CODECOV_API_TOKEN`
|
171
|
+
- CodeCov mode uses the provided commit SHA or defaults to the latest commit on main
|
172
|
+
- SimpleCov mode requires at least one path to be specified with --simplecov-path
|
173
|
+
- SimpleCov and CodeCov modes cannot be used together
|
159
174
|
MSG
|
160
175
|
|
176
|
+
opts.on('--use-simplecov', 'Use SimpleCov instead of CodeCov') do
|
177
|
+
options[:source] = :simplecov
|
178
|
+
end
|
179
|
+
|
180
|
+
opts.on('--simplecov-path PATH', 'Use SimpleCov JSON resultset file instead of CodeCov. May be specified multiple times.') do |path|
|
181
|
+
options[:simplecov_paths] << path
|
182
|
+
end
|
183
|
+
|
161
184
|
opts.on('--help', 'Shows this prompt') do
|
162
185
|
puts opts
|
163
186
|
exit
|
164
187
|
end
|
165
188
|
end
|
189
|
+
|
166
190
|
args = parser.order!(argv)
|
167
191
|
parser.parse!(args)
|
168
192
|
non_flag_args = argv.reject { |arg| arg.start_with?('--') }
|
169
193
|
custom_commit_sha = non_flag_args[0]
|
170
194
|
|
171
|
-
|
172
|
-
|
195
|
+
case options[:source]
|
196
|
+
when :codecov
|
197
|
+
code_cov_token = ENV.fetch('CODECOV_API_TOKEN', '')
|
198
|
+
raise 'Please specify a CodeCov API token in your environment as `CODECOV_API_TOKEN`' if code_cov_token.empty?
|
199
|
+
|
200
|
+
# If no commit SHA was provided in the CLI command args, use the most recent commit of the main branch in the upstream remote.
|
201
|
+
commit_sha = custom_commit_sha || `git log -1 --format=%H origin/main`.chomp
|
202
|
+
puts "Pulling test coverage statistics for commit #{commit_sha}"
|
173
203
|
|
174
|
-
|
175
|
-
|
176
|
-
|
204
|
+
FeatureMap.gather_test_coverage!(commit_sha, code_cov_token)
|
205
|
+
when :simplecov
|
206
|
+
missing_paths = options[:simplecov_paths].reject { |path| File.exist?(path) }
|
207
|
+
raise 'Error: When using --use-simplecov, you must specify at least one path with --simplecov-path.' if options[:simplecov_paths].empty?
|
208
|
+
raise "SimpleCov results file not found: #{missing_paths.join(', ')}" if missing_paths.any?
|
209
|
+
raise 'Error: Cannot specify a commit SHA when using --simplecov. These options are incompatible.' if custom_commit_sha
|
177
210
|
|
178
|
-
|
211
|
+
puts "Gathering test coverage statistics from SimpleCov files: #{options[:simplecov_paths].join(', ')}"
|
212
|
+
|
213
|
+
FeatureMap.gather_simplecov_test_coverage!(options[:simplecov_paths])
|
214
|
+
else
|
215
|
+
raise 'Invalid source'
|
216
|
+
end
|
179
217
|
|
180
218
|
puts OutputColor.green('FeatureMap test coverage statistics collected.')
|
181
219
|
puts 'View the resulting test coverage for each feature in .feature_map/test-coverage.yml'
|
data/lib/feature_map/commit.rb
CHANGED
data/lib/feature_map/mapper.rb
CHANGED
@@ -13,6 +13,13 @@ module FeatureMap
|
|
13
13
|
return @@map_files_to_features if @@map_files_to_features&.keys && @@map_files_to_features.keys.count.positive?
|
14
14
|
|
15
15
|
@@map_files_to_features = CodeFeatures.all.each_with_object({}) do |feature, map| # rubocop:disable Style/ClassVars
|
16
|
+
# NOTE: The FeatureDefinitionAssignment naively assumes that all
|
17
|
+
# features will have a definition yaml file. This comes from
|
18
|
+
# the CodeOwnership implementation which does require these
|
19
|
+
# files to exist. This is not true in repositories using the
|
20
|
+
# feature_definitions.csv style of feature definition.
|
21
|
+
next if feature.config_yml.nil?
|
22
|
+
|
16
23
|
map[feature.config_yml] = feature
|
17
24
|
end
|
18
25
|
end
|
@@ -27,6 +34,13 @@ module FeatureMap
|
|
27
34
|
return {} if Private.configuration.ignore_feature_definitions
|
28
35
|
|
29
36
|
CodeFeatures.all.each_with_object({}) do |feature, map|
|
37
|
+
# NOTE: The FeatureDefinitionAssignment naively assumes that all
|
38
|
+
# features will have a definition yaml file. This comes from
|
39
|
+
# the CodeOwnership implementation which does require these
|
40
|
+
# files to exist. This is not true in repositories using the
|
41
|
+
# feature_definitions.csv style of feature definition.
|
42
|
+
next if feature.config_yml.nil?
|
43
|
+
|
30
44
|
map[feature.config_yml] = feature
|
31
45
|
end
|
32
46
|
end
|