Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
pack_stats (0.2.0)
pack_stats (0.2.1)
code_ownership
code_teams
dogapi
Expand Down
1 change: 1 addition & 0 deletions lib/pack_stats/private/metrics/packwerk_checker_usage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def violation_type_tag
CHECKERS = T.let([
PackwerkChecker.new(key: 'enforce_dependencies', violation_type: 'dependency', direction: Direction::Outbound),
PackwerkChecker.new(key: 'enforce_privacy', violation_type: 'privacy', direction: Direction::Inbound),
PackwerkChecker.new(key: 'enforce_folder_privacy', violation_type: 'folder_privacy', direction: Direction::Inbound),
PackwerkChecker.new(key: 'enforce_layers', violation_type: 'layer', direction: Direction::Outbound),
PackwerkChecker.new(key: 'enforce_visibility', violation_type: 'visibility', direction: Direction::Outbound),
], T::Array[PackwerkChecker])
Expand Down
2 changes: 1 addition & 1 deletion pack_stats.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |spec|
spec.name = 'pack_stats'
spec.version = '0.2.0'
spec.version = '0.2.1'
spec.authors = ['Gusto Engineers']
spec.email = ['dev@gusto.com']

Expand Down
51 changes: 49 additions & 2 deletions spec/pack_stats_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ module PackStats # rubocop:disable RSpec/DescribedClassModuleWrapping
end
end

context 'in app that does not use package protectiosn with a simple package owned by one team' do
context 'in app that does not use package protection with a simple package owned by one team' do
include_context 'only one team'

before do
Expand Down Expand Up @@ -981,7 +981,7 @@ module PackStats # rubocop:disable RSpec/DescribedClassModuleWrapping
expect(metrics).to include_metric GaugeMetric.new(name: 'modularization.by_package.public_files.count', count: 0, tags: Tags.for(['package:packs/only_package', 'app:MyApp', 'team:Unknown', 'max_enforcements:true'])) end
end

context 'in app with architectural enforcements' do
context 'in app with layer enforcements' do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

before do
write_file('config/teams/Foo Team.yml', <<~CONTENTS)
name: Foo Team
Expand Down Expand Up @@ -1048,6 +1048,53 @@ module PackStats # rubocop:disable RSpec/DescribedClassModuleWrapping
expect(metrics).to include_metric GaugeMetric.for('by_team.violations.by_other_team.count', 1, Tags.for(['app:MyApp', 'team:Bar Team', 'other_team:Foo Team', 'violation_type:visibility']))
end
end

context 'in app with folder_privacy enforcements' do
before do
write_file('config/teams/Foo Team.yml', <<~CONTENTS)
name: Foo Team
CONTENTS

write_file('config/teams/Bar Team.yml', <<~CONTENTS)
name: Bar Team
CONTENTS

write_file('packs/my_pack/package.yml', <<~CONTENTS)
enforce_dependencies: false
enforce_privacy: false
enforce_folder_privacy: true
enforce_visibility: true
layer: utilities
metadata:
owner: Bar Team
CONTENTS

write_file('packs/other_pack/package.yml', <<~CONTENTS)
enforce_dependencies: false
metadata:
owner: Foo Team
CONTENTS

write_file('packs/my_pack/package_todo.yml', <<~CONTENTS)
---
packs/other_pack:
"SomeConstant":
violations:
- folder_privacy
- visibility
files:
- some_file.rb
CONTENTS

end

it 'emits the right metrics' do
expect(metrics).to include_metric GaugeMetric.for('all_packages.packwerk_checkers.strict.count', 0, Tags.for(['app:MyApp', 'violation_type:folder_privacy']))
expect(metrics).to include_metric GaugeMetric.for('all_packages.packwerk_checkers.true.count', 1, Tags.for(['app:MyApp', 'violation_type:folder_privacy']))
expect(metrics).to include_metric GaugeMetric.for('all_packages.violations.count', 1, Tags.for(['app:MyApp', 'violation_type:folder_privacy']))
expect(metrics).to include_metric GaugeMetric.for('by_team.violations.count', 1, Tags.for(['app:MyApp', 'team:Bar Team', 'violation_type:folder_privacy']))
end
end
end
end
end