diff --git a/Gemfile.lock b/Gemfile.lock index b90ea49..c1a7f14 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - pack_stats (0.1.3) + pack_stats (0.2.0) code_ownership code_teams dogapi diff --git a/docs/dashboard.json b/docs/dashboard.json index 345649e..ad1a1ef 100644 --- a/docs/dashboard.json +++ b/docs/dashboard.json @@ -53,7 +53,7 @@ { "definition": { "background_color": "white", - "content": "# Template Variables\nAt the top, there are some template variables you can set to filter the entire dashboard by...\n\n| Key | Default | Examples |\n|---|---|---|\n| *app* (required) | `my_app` | `my_app` |\n| *max_enforcements* | `false` | `false`, `true` |\n| *package* | `*` | `packs/background_jobs` |\n| *team* | `*` | `payments` |\n| *violation_type* | `dependency`,`privacy` | `architecture`,`visibility` |\n\nFor `max_enforcement`, \n - `false` means: Violation counts without changing `enforce_x` in `package.yml` files. Used to track violations we care about.\n - `true` means: Violation counts after changing `enforce_x` to `true` for all packages. Used for \"what if\" scenarios.\n\n# Pro-Tip: Split graph by variables\nClick \"split graph\" in the \"full-screen\" mode of a widget to see a graph broken up by team, violation type, or package. Here's an [example (violations over time)](https://app.datadoghq.com/dashboard/s3q-cb3-bed?fullscreen_end_ts=1683557460383&fullscreen_paused=false&fullscreen_section=split%20graph&fullscreen_start_ts=1683543060383&fullscreen_widget=452601886481639&from_ts=1683543021000&to_ts=1683557421000&live=true).\n\n# Additional Documentation\nMore information at [https://go/packs](https://docs.google.com/document/d/1OGYqV1pt1r6g6LimCDs8RSIR7hBZ7BVO1yohk2Jnu0M/edit#heading=h.4cufcvb5oqvd)\n", + "content": "# Template Variables\nAt the top, there are some template variables you can set to filter the entire dashboard by...\n\n| Key | Default | Examples |\n|---|---|---|\n| *app* (required) | `my_app` | `my_app` |\n| *max_enforcements* | `false` | `false`, `true` |\n| *package* | `*` | `packs/background_jobs` |\n| *team* | `*` | `payments` |\n| *violation_type* | `dependency`,`privacy` | `layer`,`visibility` |\n\nFor `max_enforcement`, \n - `false` means: Violation counts without changing `enforce_x` in `package.yml` files. Used to track violations we care about.\n - `true` means: Violation counts after changing `enforce_x` to `true` for all packages. Used for \"what if\" scenarios.\n\n# Pro-Tip: Split graph by variables\nClick \"split graph\" in the \"full-screen\" mode of a widget to see a graph broken up by team, violation type, or package. Here's an [example (violations over time)](https://app.datadoghq.com/dashboard/s3q-cb3-bed?fullscreen_end_ts=1683557460383&fullscreen_paused=false&fullscreen_section=split%20graph&fullscreen_start_ts=1683543060383&fullscreen_widget=452601886481639&from_ts=1683543021000&to_ts=1683557421000&live=true).\n\n# Additional Documentation\nMore information at [https://go/packs](https://docs.google.com/document/d/1OGYqV1pt1r6g6LimCDs8RSIR7hBZ7BVO1yohk2Jnu0M/edit#heading=h.4cufcvb5oqvd)\n", "font_size": "14", "has_padding": true, "show_tick": false, diff --git a/lib/pack_stats/private/metrics/packwerk_checker_usage.rb b/lib/pack_stats/private/metrics/packwerk_checker_usage.rb index 37833d9..2e9d7fa 100644 --- a/lib/pack_stats/private/metrics/packwerk_checker_usage.rb +++ b/lib/pack_stats/private/metrics/packwerk_checker_usage.rb @@ -9,7 +9,7 @@ module Metrics class PackwerkCheckerUsage extend T::Sig - # Some violations (e.g. dependency, visibility, architecture) matter for the referencing (outbound) package. + # Some violations (e.g. dependency, visibility, layer) matter for the referencing (outbound) package. # Other violations (e.g. privacy) matter for the referenced (inbound) package. class Direction < T::Enum enums do @@ -38,7 +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_architecture', violation_type: 'architecture', direction: Direction::Outbound), + 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]) diff --git a/pack_stats.gemspec b/pack_stats.gemspec index f9e84e4..b0d1c48 100644 --- a/pack_stats.gemspec +++ b/pack_stats.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |spec| spec.name = 'pack_stats' - spec.version = '0.1.3' + spec.version = '0.2.0' spec.authors = ['Gusto Engineers'] spec.email = ['dev@gusto.com'] diff --git a/spec/pack_stats_spec.rb b/spec/pack_stats_spec.rb index e06780b..39344cd 100644 --- a/spec/pack_stats_spec.rb +++ b/spec/pack_stats_spec.rb @@ -994,7 +994,7 @@ module PackStats # rubocop:disable RSpec/DescribedClassModuleWrapping write_file('packs/my_pack/package.yml', <<~CONTENTS) enforce_dependencies: false enforce_privacy: false - enforce_architecture: true + enforce_layers: true enforce_visibility: true layer: utilities metadata: @@ -1013,7 +1013,7 @@ module PackStats # rubocop:disable RSpec/DescribedClassModuleWrapping packs/other_pack: "SomeConstant": violations: - - architecture + - layer - visibility files: - some_file.rb @@ -1022,29 +1022,29 @@ module PackStats # rubocop:disable RSpec/DescribedClassModuleWrapping 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:architecture'])) - expect(metrics).to include_metric GaugeMetric.for('all_packages.packwerk_checkers.true.count', 1, Tags.for(['app:MyApp', 'violation_type:architecture'])) + expect(metrics).to include_metric GaugeMetric.for('all_packages.packwerk_checkers.strict.count', 0, Tags.for(['app:MyApp', 'violation_type:layer'])) + expect(metrics).to include_metric GaugeMetric.for('all_packages.packwerk_checkers.true.count', 1, Tags.for(['app:MyApp', 'violation_type:layer'])) expect(metrics).to include_metric GaugeMetric.for('all_packages.packwerk_checkers.strict.count', 0, Tags.for(['app:MyApp', 'violation_type:visibility'])) expect(metrics).to include_metric GaugeMetric.for('all_packages.packwerk_checkers.true.count', 1, Tags.for(['app:MyApp', 'violation_type:visibility'])) expect(metrics).to include_metric GaugeMetric.for('all_packages.packwerk_checkers.true.count', 1, Tags.for(['app:MyApp', 'violation_type:visibility'])) - expect(metrics).to include_metric GaugeMetric.for('all_packages.violations.count', 1, Tags.for(['app:MyApp', 'violation_type:architecture'])) + expect(metrics).to include_metric GaugeMetric.for('all_packages.violations.count', 1, Tags.for(['app:MyApp', 'violation_type:layer'])) expect(metrics).to include_metric GaugeMetric.for('all_packages.violations.count', 1, Tags.for(['app:MyApp', 'violation_type:visibility'])) - expect(metrics).to include_metric GaugeMetric.for('by_team.violations.count', 1, Tags.for(['app:MyApp', 'team:Bar Team', 'violation_type:architecture'])) + expect(metrics).to include_metric GaugeMetric.for('by_team.violations.count', 1, Tags.for(['app:MyApp', 'team:Bar Team', 'violation_type:layer'])) expect(metrics).to include_metric GaugeMetric.for('by_team.violations.count', 1, Tags.for(['app:MyApp', 'team:Bar Team', 'violation_type:visibility'])) - expect(metrics).to include_metric GaugeMetric.for('by_package.violations.count', 1, Tags.for(['app:MyApp', 'package:packs/my_pack', 'team:Bar Team', 'violation_type:architecture', 'layer:utilities'])) + expect(metrics).to include_metric GaugeMetric.for('by_package.violations.count', 1, Tags.for(['app:MyApp', 'package:packs/my_pack', 'team:Bar Team', 'violation_type:layer', 'layer:utilities'])) expect(metrics).to include_metric GaugeMetric.for('by_package.violations.count', 1, Tags.for(['app:MyApp', 'package:packs/my_pack', 'team:Bar Team', 'violation_type:visibility', 'layer:utilities'])) - expect(metrics).to include_metric GaugeMetric.for('by_package.violations.count', 0, Tags.for(['app:MyApp', 'package:packs/other_pack', 'team:Foo Team', 'violation_type:architecture', 'layer:product'])) + expect(metrics).to include_metric GaugeMetric.for('by_package.violations.count', 0, Tags.for(['app:MyApp', 'package:packs/other_pack', 'team:Foo Team', 'violation_type:layer', 'layer:product'])) expect(metrics).to include_metric GaugeMetric.for('by_package.violations.count', 0, Tags.for(['app:MyApp', 'package:packs/other_pack', 'team:Foo Team', 'violation_type:visibility', 'layer:product'])) - expect(metrics).to include_metric GaugeMetric.for('by_package.violations.by_other_package.count', 1, Tags.for(['app:MyApp', 'package:packs/my_pack', 'other_package:packs/other_pack', 'team:Bar Team', 'other_team:Foo Team', 'violation_type:architecture', 'layer:utilities'])) + expect(metrics).to include_metric GaugeMetric.for('by_package.violations.by_other_package.count', 1, Tags.for(['app:MyApp', 'package:packs/my_pack', 'other_package:packs/other_pack', 'team:Bar Team', 'other_team:Foo Team', 'violation_type:layer', 'layer:utilities'])) expect(metrics).to include_metric GaugeMetric.for('by_package.violations.by_other_package.count', 1, Tags.for(['app:MyApp', 'package:packs/my_pack', 'other_package:packs/other_pack', 'team:Bar Team', 'other_team:Foo Team', 'violation_type:visibility', 'layer:utilities'])) - expect(metrics).to_not include_metric GaugeMetric.for('by_package.violations.by_other_package.count', 0, Tags.for(['app:MyApp', 'package:packs/other_pack', 'other_package:packs/my_pack', 'team:Foo Team', 'other_team:Bar Team', 'violation_type:architecture', 'layer:product'])) + expect(metrics).to_not include_metric GaugeMetric.for('by_package.violations.by_other_package.count', 0, Tags.for(['app:MyApp', 'package:packs/other_pack', 'other_package:packs/my_pack', 'team:Foo Team', 'other_team:Bar Team', 'violation_type:layer', 'layer:product'])) expect(metrics).to_not include_metric GaugeMetric.for('by_package.violations.by_other_package.count', 0, Tags.for(['app:MyApp', 'package:packs/other_pack', 'other_package:packs/my_pack', 'team:Foo Team', 'other_team:Bar Team', 'violation_type:visibility', 'layer:product'])) - expect(metrics).to_not include_metric GaugeMetric.for('by_team.violations.by_other_team.count', 0, Tags.for(['app:MyApp', 'team:Foo Team', 'other_team:Bar Team', 'violation_type:architecture'])) + expect(metrics).to_not include_metric GaugeMetric.for('by_team.violations.by_other_team.count', 0, Tags.for(['app:MyApp', 'team:Foo Team', 'other_team:Bar Team', 'violation_type:layer'])) expect(metrics).to_not include_metric GaugeMetric.for('by_team.violations.by_other_team.count', 0, Tags.for(['app:MyApp', 'team:Foo Team', 'other_team:Bar Team', 'violation_type:visibility'])) - 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:architecture'])) + 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:layer'])) 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