1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762
|
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'set' # -- Ruby 3.1 and earlier needs this. Drop this line after Ruby 3.2+ is only supported.
require 'test_file_finder'
# These tests run a sanity check on the mapping file `tests.yml`
# used with the `test_file_finder` gem (`tff`) to identify matching test files.
# The verification depend on the presence of actual test files,
# so they would fail if one of the test files mentioned here is deleted.
# To minimize the chance of this test failing due to unrelated changes,
# the test files are chosen to be critical files that are unlikely to be deleted in a typical merge request
tests = [
{
explanation: 'EE code should map to respective spec',
changed_file: 'ee/app/controllers/admin/licenses_controller.rb',
expected: ['ee/spec/controllers/admin/licenses_controller_spec.rb']
},
{
explanation: 'FOSS code should map to respective spec',
changed_file: 'app/finders/admin/projects_finder.rb',
expected: ['spec/finders/admin/projects_finder_spec.rb']
},
{
explanation: 'EE extension should map to its EE extension spec and its FOSS class spec',
changed_file: 'ee/app/finders/ee/projects_finder.rb',
expected: %w[
ee/spec/finders/ee/projects_finder_spec.rb
spec/finders/projects_finder_spec.rb
]
},
{
explanation: 'EE lib should map to respective spec.',
changed_file: 'ee/lib/world.rb',
expected: ['ee/spec/lib/world_spec.rb']
},
{
explanation: 'FOSS lib should map to respective spec',
changed_file: 'lib/gitaly/server.rb',
expected: ['spec/lib/gitaly/server_spec.rb']
},
{
explanation: 'https://gitlab.com/gitlab-org/gitlab/-/issues/368628',
changed_file: 'lib/gitlab/usage_data_counters/web_ide_counter.rb',
expected: %w[
spec/lib/gitlab/usage_data_spec.rb
spec/lib/gitlab/usage_data_counters/web_ide_counter_spec.rb
]
},
{
explanation: 'https://gitlab.com/gitlab-org/quality/engineering-productivity/master-broken-incidents/-/issues/54#note_1160811638',
changed_file: 'lib/gitlab/ci/config/yaml/tags/base.rb',
expected: ['spec/lib/gitlab/ci/yaml_processor_spec.rb']
},
{
explanation: 'https://gitlab.com/gitlab-org/quality/engineering-productivity/master-broken-incidents/-/issues/54#note_1160811638',
changed_file: 'ee/lib/gitlab/ci/config/entry/pages_path_prefix.rb',
expected: %w[
spec/lib/gitlab/ci/yaml_processor_spec.rb
ee/spec/lib/gitlab/ci/yaml_processor_spec.rb
]
},
{
explanation: 'https://gitlab.com/gitlab-org/gitlab/-/issues/466068#note_1987902951',
changed_file: 'ee/lib/audit_events/strategies/instance/amazon_s3_destination_strategy.rb',
expected: %w[
ee/spec/lib/audit_events/strategies/instance/amazon_s3_destination_strategy_spec.rb
ee/spec/lib/audit_events/external_destination_streamer_spec.rb
]
},
{
explanation: 'Tooling should map to respective spec',
changed_file: 'tooling/danger/specs/project_factory_suggestion.rb',
expected: ['spec/tooling/danger/specs/project_factory_suggestion_spec.rb']
},
{
explanation: 'Map RuboCop related files to respective specs',
changed_file: 'rubocop/cop/gettext/static_identifier.rb',
expected: ['spec/rubocop/cop/gettext/static_identifier_spec.rb']
},
{
explanation: 'Map Ruby config to respective specs',
changed_file: 'config/application.rb',
expected: ['spec/config/application_spec.rb']
},
{
explanation: 'Map YAML config to respective specs',
changed_file: 'config/mail_room.yml',
expected: ['spec/config/mail_room_spec.rb']
},
{
explanation: 'Initializers should map to respective spec',
changed_file: 'config/initializers/action_mailer_hooks.rb',
expected: ['spec/initializers/action_mailer_hooks_spec.rb']
},
{
explanation: 'DB structure should map to schema spec',
changed_file: 'db/structure.sql',
expected: ['spec/db/schema_spec.rb']
},
{
explanation: 'Migration should map to its non-timestamped spec',
changed_file: 'db/migrate/20240228144013_migrate_custom_permissions.rb',
expected: ['spec/migrations/migrate_custom_permissions_spec.rb']
},
{
explanation: 'Migration should map to its timestamped spec',
changed_file: 'db/post_migrate/20231207194620_backfill_catalog_resources_visibility_level.rb',
expected: ['spec/migrations/20231207194620_backfill_catalog_resources_visibility_level_spec.rb']
},
{
explanation: 'FOSS views should map to respective spec',
changed_file: 'app/views/admin/dashboard/index.html.haml',
expected: ['spec/views/admin/dashboard/index.html.haml_spec.rb']
},
{
explanation: 'EE views should map to respective spec',
changed_file: 'ee/app/views/subscriptions/new.html.haml',
expected: ['ee/spec/views/subscriptions/new.html.haml_spec.rb']
},
{
explanation: 'FOSS spec code should map to itself',
changed_file: 'spec/models/issue_spec.rb',
expected: ['spec/models/issue_spec.rb']
},
{
explanation: 'EE spec code should map to itself',
changed_file: 'ee/spec/models/ee/user_spec.rb',
expected: %w[
ee/spec/models/ee/user_spec.rb
spec/models/user_spec.rb
]
},
{
explanation: 'EE extension spec should map to itself and the FOSS class spec',
changed_file: 'ee/spec/services/ee/notification_service_spec.rb',
expected: %w[
ee/spec/services/ee/notification_service_spec.rb
spec/services/notification_service_spec.rb
]
},
{
explanation: 'FOSS factories map to FOSS/EE model specs plural',
changed_file: 'spec/factories/users.rb',
expected: %w[
spec/models/user_spec.rb
ee/spec/models/ee/user_spec.rb
]
},
{
explanation: 'FOSS factories map to FOSS/EE model specs singular',
changed_file: 'spec/factories/ci/build_name.rb',
expected: %w[
spec/models/ci/build_name_spec.rb
]
},
{
explanation: 'EE factories for extensions map to FOSS/EE model specs',
changed_file: 'ee/spec/factories/users.rb',
expected: %w[
spec/models/user_spec.rb
ee/spec/models/ee/user_spec.rb
]
},
{
explanation: 'EE factories map to FOSS/EE model specs',
changed_file: 'ee/spec/factories/licenses.rb',
expected: %w[
ee/spec/models/license_spec.rb
]
},
{
explanation: 'Whats New should map to its respective spec',
changed_file: 'data/whats_new/202101140001_13_08.yml',
expected: ['spec/lib/release_highlights/validator_spec.rb']
},
{
explanation: 'The documentation index page is used in this haml_lint spec',
changed_file: 'doc/index.md',
expected: ['spec/haml_lint/linter/documentation_links_spec.rb']
},
{
explanation: 'Spec for FOSS model',
changed_file: 'app/models/uploads/base.rb',
expected: ['spec/models/every_model_spec.rb']
},
{
explanation: 'Spec for EE model',
changed_file: 'ee/app/models/geo/base_registry.rb',
expected: ['spec/models/every_model_spec.rb']
},
{
explanation: 'Spec for FOSS sidekiq worker',
changed_file: 'app/workers/background_migration/single_database_worker.rb',
expected: ['spec/workers/every_sidekiq_worker_spec.rb']
},
{
explanation: 'Spec for EE sidekiq worker',
changed_file: 'ee/app/workers/concerns/geo/base_registry_sync_worker.rb',
expected: ['spec/workers/every_sidekiq_worker_spec.rb']
},
{
explanation: 'FOSS mailer previews',
changed_file: 'app/mailers/previews/notify_preview.rb',
expected: ['spec/mailers/previews_spec.rb']
},
{
explanation: 'EE mailer previews',
changed_file: 'ee/app/mailers/previews/license_mailer_preview.rb',
expected: ['spec/mailers/previews_spec.rb']
},
{
explanation: 'EE mailer extension previews',
changed_file: 'ee/app/mailers/previews/license_mailer_preview.rb',
expected: ['spec/mailers/previews_spec.rb']
},
{
explanation: 'https://gitlab.com/gitlab-org/quality/engineering-productivity/master-broken-incidents/-/issues/287#note_1192008962',
# Note: The metrics seem to be changed every year or so, so this test will fail once a year or so.
# You will need to change the metric below for another metric present in the project.
changed_file: 'ee/config/metrics/counts_all/20221114065035_delete_merge_request.yml',
expected: %w[
spec/config/metrics/every_metric_definition_spec.rb
ee/spec/config/metrics/every_metric_definition_spec.rb
spec/lib/gitlab/usage/metric_definition_validate_all_spec.rb
]
},
{
explanation: 'FOSS metric definitions map to metric validation specs',
changed_file: 'config/metrics/counts_28d/count_total_merge_request_click_start_review_on_overview_tab_monthly.yml',
expected: %w[
spec/config/metrics/every_metric_definition_spec.rb
ee/spec/config/metrics/every_metric_definition_spec.rb
spec/lib/gitlab/usage/metric_definition_validate_all_spec.rb
]
},
{
explanation: 'Metric schema maps to metric validation spec',
changed_file: 'config/metrics/schema/base.json',
expected: %w[
spec/config/metrics/every_metric_definition_spec.rb
ee/spec/config/metrics/every_metric_definition_spec.rb
spec/lib/gitlab/usage/metric_definition_validate_all_spec.rb
spec/scripts/internal_events/cli_spec.rb
spec/support_specs/matchers/internal_events_matchers_spec.rb
]
},
{
explanation: 'FOSS Snowplow definitions map to event validation spec',
changed_file: 'config/events/status_page_incident_unpublished.yml',
expected: ['spec/lib/gitlab/tracking/event_definition_validator_validate_all_spec.rb']
},
{
explanation: 'EE Snowplow definitions map to event validation spec',
changed_file: 'ee/config/events/licenses_list_viewed.yml',
expected: ['spec/lib/gitlab/tracking/event_definition_validator_validate_all_spec.rb']
},
{
explanation: 'Snowplow schema maps to event validation spec',
changed_file: 'config/events/schema.json',
expected: %w[
spec/lib/gitlab/tracking/event_definition_validator_validate_all_spec.rb
spec/scripts/internal_events/cli_spec.rb
spec/support_specs/matchers/internal_events_matchers_spec.rb
]
},
{
explanation: 'Internal Events application logic maps to internal events tooling',
changed_file: 'lib/gitlab/internal_events.rb',
expected: %w[
spec/lib/gitlab/internal_events_spec.rb
spec/scripts/internal_events/cli_spec.rb
spec/support_specs/matchers/internal_events_matchers_spec.rb
]
},
{
explanation: 'Internal Events CLI entrypoint maps to internal events tooling',
changed_file: 'scripts/internal_events/cli.rb',
expected: %w[
spec/scripts/internal_events/cli_spec.rb
spec/support_specs/matchers/internal_events_matchers_spec.rb
]
},
{
explanation: 'Internal Events CLI logic maps to internal events tooling',
changed_file: 'scripts/internal_events/cli/global_state.rb',
expected: %w[
spec/scripts/internal_events/cli_spec.rb
spec/support_specs/matchers/internal_events_matchers_spec.rb
]
},
{
explanation: 'Internal Events default test setup maps to internal events tooling',
changed_file: 'spec/support/shared_examples/controllers/internal_event_tracking_examples.rb',
expected: %w[
spec/scripts/internal_events/cli_spec.rb
spec/support_specs/matchers/internal_events_matchers_spec.rb
]
},
{
explanation: 'Internal Events custom test setup maps to internal events tooling',
changed_file: 'spec/support/matchers/internal_events_matchers.rb',
expected: %w[
spec/scripts/internal_events/cli_spec.rb
spec/support_specs/matchers/internal_events_matchers_spec.rb
]
},
{
explanation: 'Internal Events test cases map to internal events tooling',
changed_file: 'spec/fixtures/scripts/internal_events/event_definer_examples.yml',
expected: %w[
spec/scripts/internal_events/cli_spec.rb
spec/support_specs/matchers/internal_events_matchers_spec.rb
]
},
{
explanation: 'https://gitlab.com/gitlab-org/quality/engineering-productivity/team/-/issues/146',
changed_file: 'config/feature_categories.yml',
expected: %w[
spec/db/docs_spec.rb
ee/spec/lib/ee/gitlab/database/docs/docs_spec.rb
]
},
{
explanation: 'https://gitlab.com/gitlab-org/quality/engineering-productivity/master-broken-incidents/-/issues/1360',
changed_file: 'vendor/project_templates/android.tar.gz',
expected: ['spec/lib/gitlab/project_template_spec.rb']
},
{
explanation: 'https://gitlab.com/gitlab-org/quality/engineering-productivity/master-broken-incidents/-/issues/1683#note_1385966977',
changed_file: 'app/finders/members_finder.rb',
expected: %w[
spec/finders/members_finder_spec.rb
spec/graphql/types/project_member_relation_enum_spec.rb
]
},
{
explanation: 'New CI templates should run CI template tests: https://gitlab.com/gitlab-org/quality/engineering-productivity/master-broken-incidents/-/issues/4440#note_1675547256',
changed_file: 'lib/gitlab/ci/templates/Diffblue-Cover.gitlab-ci.yml',
expected: %w[
spec/lib/gitlab/ci/templates/templates_spec.rb
ee/spec/lib/ee/gitlab/ci/templates/templates_spec.rb
]
},
{
explanation: 'Map EE rake tasks',
changed_file: 'ee/lib/tasks/geo.rake',
expected: ['ee/spec/tasks/geo_rake_spec.rb']
},
{
explanation: 'Map controllers to request specs',
changed_file: 'app/controllers/admin/abuse_reports_controller.rb',
expected: ['spec/requests/admin/abuse_reports_controller_spec.rb']
},
{
explanation: 'Map EE controllers to controller and request specs',
changed_file: 'ee/app/controllers/gitlab_subscriptions/subscriptions_controller.rb',
expected: %w[
ee/spec/controllers/gitlab_subscriptions/subscriptions_controller_spec.rb
ee/spec/requests/gitlab_subscriptions/subscriptions_controller_spec.rb
]
},
{
explanation: 'Map FOSS GraphQL resolvers to request specs',
changed_file: 'app/graphql/resolvers/abuse_report_labels_resolver.rb',
expected: ['spec/requests/api/graphql/abuse_report_labels_spec.rb']
},
{
explanation: 'Map FOSS GraphQL resolvers to request query specs',
changed_file: 'app/graphql/resolvers/achievements/user_achievements_resolver.rb',
expected: ['spec/requests/api/graphql/achievements/user_achievements_query_spec.rb']
},
{
explanation: 'Map EE GraphQL resolvers to request specs',
changed_file: 'ee/app/graphql/resolvers/geo/registries_resolver.rb',
expected: ['ee/spec/requests/api/graphql/geo/registries_spec.rb']
},
{
explanation: 'Map FOSS GraphQL mutations to request specs',
changed_file: 'app/graphql/mutations/admin/abuse_report_labels/create.rb',
expected: ['spec/requests/api/graphql/mutations/admin/abuse_report_labels/create_spec.rb']
},
{
explanation: 'Map EE GraphQL mutations to request specs',
changed_file: 'ee/app/graphql/mutations/boards/epic_lists/destroy.rb',
expected: ['ee/spec/requests/api/graphql/mutations/boards/epic_lists/destroy_spec.rb']
},
{
explanation: 'Map Remote Development GraphQL mutations to request specs',
changed_file: 'ee/app/graphql/mutations/remote_development/workspace_operations/create.rb',
expected: %w[
ee/spec/requests/api/graphql/mutations/remote_development/workspace_operations/create_spec.rb
]
},
{
explanation: 'Map Remote Development GraphQL cluster_agent workspaces resolvers to request specs',
changed_file: 'ee/app/graphql/resolvers/remote_development/workspaces_for_agent_resolver.rb',
expected: %w[
ee/spec/requests/api/graphql/remote_development/cluster_agent/workspaces/with_actual_states_arg_spec.rb
ee/spec/requests/api/graphql/remote_development/cluster_agent/workspaces/with_ids_arg_spec.rb
ee/spec/requests/api/graphql/remote_development/cluster_agent/workspaces/with_no_args_spec.rb
ee/spec/requests/api/graphql/remote_development/cluster_agent/workspaces/with_project_ids_arg_spec.rb
]
},
{
explanation: 'Map Remote Development GraphQL current_user workspaces resolvers to request specs',
changed_file: 'ee/app/graphql/resolvers/remote_development/workspaces_for_current_user_resolver.rb',
expected: %w[
ee/spec/requests/api/graphql/remote_development/current_user/workspaces/with_actual_states_arg_spec.rb
ee/spec/requests/api/graphql/remote_development/current_user/workspaces/with_agent_ids_arg_spec.rb
ee/spec/requests/api/graphql/remote_development/current_user/workspaces/with_ids_arg_spec.rb
ee/spec/requests/api/graphql/remote_development/current_user/workspaces/with_no_args_spec.rb
ee/spec/requests/api/graphql/remote_development/current_user/workspaces/with_project_ids_arg_spec.rb
]
},
{
explanation: 'Map Remote Development GraphQL query root workspaces resolvers to request specs',
changed_file: 'ee/app/graphql/resolvers/remote_development/workspaces_for_query_root_resolver.rb',
expected: %w[
ee/spec/requests/api/graphql/remote_development/workspaces/with_actual_states_arg_spec.rb
ee/spec/requests/api/graphql/remote_development/workspaces/with_agent_ids_arg_spec.rb
ee/spec/requests/api/graphql/remote_development/workspaces/with_ids_arg_spec.rb
ee/spec/requests/api/graphql/remote_development/workspaces/with_no_args_spec.rb
ee/spec/requests/api/graphql/remote_development/workspaces/with_project_ids_arg_spec.rb
]
},
{
explanation: 'Map Remote Development GraphQL query root workspace type resolver to request specs',
changed_file: 'ee/app/graphql/types/remote_development/workspace_type.rb',
expected: %w[
ee/spec/graphql/types/remote_development/workspace_type_spec.rb
ee/spec/requests/api/graphql/remote_development/workspace/with_id_arg_spec.rb
]
},
{
explanation: 'https://gitlab.com/gitlab-org/gitlab/-/issues/466068#note_1987834618',
changed_file: 'ee/app/replicators/geo/ci_secure_file_replicator.rb',
expected: %w[
ee/spec/replicators/geo/ci_secure_file_replicator_spec.rb
ee/spec/models/geo_node_status_spec.rb
]
},
{
explanation: 'https://gitlab.com/gitlab-org/gitlab/-/issues/466068#note_2131393513',
changed_file: 'ee/app/policies/ee/group_policy.rb',
expected: %w[
spec/policies/group_policy_spec.rb
ee/spec/policies/group_policy_spec.rb
ee/spec/features/groups/groups_security_credentials_spec.rb
]
},
{
explanation: 'https://gitlab.com/gitlab-org/gitlab/-/issues/466068#note_2132805842',
changed_file: 'lib/gitlab/ci/mask_secret.rb',
expected: %w[
ee/spec/lib/gitlab/ci/google_cloud/generate_build_environment_variables_service_spec.rb
ee/spec/models/dast_site_profile_spec.rb
ee/spec/models/ee/project_spec.rb
spec/features/admin_variables_spec.rb
spec/features/group_variables_spec.rb
spec/features/project_group_variables_spec.rb
spec/features/project_variables_spec.rb
spec/lib/expand_variables_spec.rb
spec/lib/gitlab/ci/build/rules/rule/clause/exists_spec.rb
spec/lib/gitlab/ci/config/external/file/artifact_spec.rb
spec/lib/gitlab/ci/config/external/file/base_spec.rb
spec/lib/gitlab/ci/config/external/file/local_spec.rb
spec/lib/gitlab/ci/config/external/file/project_spec.rb
spec/lib/gitlab/ci/config/external/file/remote_spec.rb
spec/lib/gitlab/ci/config/external/file/template_spec.rb
spec/lib/gitlab/ci/config/external/mapper/matcher_spec.rb
spec/lib/gitlab/ci/config/interpolation/functions/expand_vars_spec.rb
spec/lib/gitlab/ci/mask_secret_spec.rb
spec/lib/gitlab/ci/variables/collection/item_spec.rb
spec/models/ci/build_spec.rb
spec/models/clusters/kubernetes_namespace_spec.rb
spec/models/clusters/platforms/kubernetes_spec.rb
spec/models/integrations/apple_app_store_spec.rb
spec/models/integrations/diffblue_cover_spec.rb
spec/models/integrations/google_play_spec.rb
spec/models/integrations/harbor_spec.rb
spec/models/project_spec.rb
spec/requests/api/admin/ci/variables_spec.rb
spec/requests/api/ci/variables_spec.rb
spec/requests/api/graphql/ci/group_variables_spec.rb
spec/requests/api/graphql/ci/inherited_ci_variables_spec.rb
spec/requests/api/graphql/ci/instance_variables_spec.rb
spec/requests/api/graphql/ci/project_variables_spec.rb
spec/requests/api/group_variables_spec.rb
spec/services/ci/change_variable_service_spec.rb
spec/services/ci/create_pipeline_service/creation_errors_and_warnings_spec.rb
]
},
{
explanation: 'https://gitlab.com/gitlab-org/gitlab/-/issues/466068#note_2132808426',
changed_file: 'lib/gitlab/ci/build/rules/rule/clause/changes.rb',
expected: %w[
spec/lib/gitlab/ci/build/rules/rule/clause/changes_spec.rb
spec/lib/gitlab/ci/build/rules/rule_spec.rb
spec/lib/gitlab/ci/config/external/rules_spec.rb
]
},
{
explanation: 'Spec for onboarding changes to company form items',
changed_file: 'ee/app/controllers/registrations/company_controller.rb',
expected: %w[
ee/spec/features/registrations/saas/invite_flow_spec.rb
ee/spec/features/registrations/saas/sso_signin_standard_flow_company_creating_project_spec.rb
ee/spec/features/registrations/saas/standard_flow_company_creating_project_spec.rb
ee/spec/features/registrations/saas/standard_flow_company_joining_project_spec.rb
ee/spec/features/registrations/saas/standard_flow_just_me_creating_project_spec.rb
ee/spec/features/registrations/saas/standard_flow_just_me_importing_project_spec.rb
ee/spec/features/registrations/saas/standard_flow_just_me_joining_project_spec.rb
ee/spec/features/registrations/saas/standard_flow_with_2fa_spec.rb
ee/spec/features/registrations/saas/subscription_flow_company_paid_plan_spec.rb
ee/spec/features/registrations/saas/subscription_flow_just_me_paid_plan_spec.rb
ee/spec/features/registrations/saas/trial_flow_company_creating_project_spec.rb
ee/spec/features/registrations/saas/trial_flow_company_importing_project_spec.rb
ee/spec/features/registrations/saas/trial_flow_just_me_creating_project_spec.rb
ee/spec/features/registrations/saas/trial_flow_just_me_importing_project_spec.rb
ee/spec/controllers/registrations/company_controller_spec.rb
ee/spec/features/registrations/email_opt_in_registration_spec.rb
]
},
{
explanation: 'Spec for in-app ultimate trials',
changed_file: 'ee/app/controllers/gitlab_subscriptions/trials_controller.rb',
expected: %w[
ee/spec/features/gitlab_subscriptions/trials/creation_with_multiple_existing_namespace_flow_spec.rb
ee/spec/features/gitlab_subscriptions/trials/creation_with_no_existing_namespace_flow_spec.rb
ee/spec/features/gitlab_subscriptions/trials/creation_with_one_existing_namespace_flow_spec.rb
ee/spec/requests/gitlab_subscriptions/trials_controller_spec.rb
ee/spec/features/gitlab_subscriptions/trials/access_denied_spec.rb
]
},
{
explanation: 'Spec for in-app duo pro trials',
changed_file: 'ee/app/controllers/gitlab_subscriptions/trials/duo_pro_controller.rb',
expected: %w[
ee/spec/features/gitlab_subscriptions/trials/duo_pro/access_denied_spec.rb
ee/spec/features/gitlab_subscriptions/trials/duo_pro/creation_with_multiple_existing_namespace_flow_spec.rb
ee/spec/features/gitlab_subscriptions/trials/duo_pro/creation_with_one_existing_namespace_flow_spec.rb
ee/spec/requests/gitlab_subscriptions/trials/duo_pro_controller_spec.rb
]
},
{
explanation: 'Spec for in-app duo enterprise trials',
changed_file: 'ee/app/controllers/gitlab_subscriptions/trials/duo_enterprise_controller.rb',
expected: %w[
ee/spec/features/gitlab_subscriptions/trials/duo_enterprise/access_denied_spec.rb
ee/spec/features/gitlab_subscriptions/trials/duo_enterprise/creation_with_multiple_existing_namespace_flow_spec.rb
ee/spec/features/gitlab_subscriptions/trials/duo_enterprise/creation_with_one_existing_namespace_flow_spec.rb
ee/spec/requests/gitlab_subscriptions/trials/duo_enterprise_controller_spec.rb
]
},
{
explanation: 'https://gitlab.com/gitlab-org/gitlab/-/issues/466068#note_2138440847',
changed_file: 'app/services/merge_requests/mergeability/check_open_status_service.rb',
expected: %w[
ee/spec/graphql/ee/types/merge_request_type_spec.rb
spec/services/merge_requests/mergeability/check_open_status_service_spec.rb
]
},
# Why is it commented out?
#
# We cannot uncomment this, as this "spec" would fail as soon as we add/remove a file in
# the "spec/features" folder hierarchy that would contain the word navbar/sidebar.
#
# {
# explanation: 'https://gitlab.com/gitlab-org/gitlab/-/issues/466068#note_1988359861',
# changed_file: 'lib/sidebars/projects/menus/issues_menu.rb',
# expected: %w[
# spec/features/boards/sidebar_spec.rb
# spec/features/dashboard/navbar_spec.rb
# spec/features/explore/navbar_spec.rb
# spec/features/groups/navbar_spec.rb
# spec/features/projects/navbar_spec.rb
# spec/lib/sidebars/projects/menus/issues_menu_spec.rb
# ]
# },
# Why is it commented out?
#
# We cannot uncomment this, as this "spec" would fail as soon as we add/remove a file in
# the "spec/features" folder hierarchy that would contain the word navbar/sidebar.
#
# {
# explanation: 'https://gitlab.com/gitlab-org/gitlab/-/issues/466068#note_1988359861',
# changed_file: 'ee/lib/sidebars/groups/menus/epics_menu.rb',
# expected: %w[
# ee/spec/features/boards/sidebar_spec.rb
# ee/spec/features/dashboard/navbar_spec.rb
# ee/spec/features/groups/navbar_spec.rb
# ee/spec/features/merge_request/sidebar_spec.rb
# ee/spec/features/projects/navbar_spec.rb
# ee/spec/lib/sidebars/groups/menus/epics_menu_spec.rb
# ]
# },
# Why is it commented out?
#
# We cannot uncomment this, as this "spec" would fail as soon as we add/remove a file in
# the "spec/features" folder hierarchy that would contain the word navbar/sidebar.
#
# {
# explanation: 'https://gitlab.com/gitlab-org/gitlab/-/issues/466068#note_1939569462',
# changed_file: 'lib/api/hooks/events.rb',
# expected: %w[
# ee/spec/requests/api/group_hooks_spec.rb
# ee/spec/requests/api/project_hooks_spec.rb
# spec/requests/api/project_hooks_spec.rb
# spec/requests/api/system_hooks_spec.rb
# ]
# }
# Why is it commented out?
#
# We cannot uncomment this, as this "spec" would fail as soon as we add/remove a file in
# the "spec/features" folder hierarchy that would contain the word navbar/sidebar.
#
# {
# explanation: 'https://gitlab.com/gitlab-org/gitlab/-/issues/466068#note_1939569462',
# changed_file: 'ee/lib/api/group_hooks.rb',
# expected: %w[
# ee/spec/requests/api/group_hooks_spec.rb
# ee/spec/requests/api/project_hooks_spec.rb
# spec/requests/api/project_hooks_spec.rb
# spec/requests/api/system_hooks_spec.rb
# ]
# },
{
explanation: 'Run database dictionary related specs on db/docs changes.',
changed_file: 'db/docs/design_management_repositories.yml',
expected: %w[
ee/spec/lib/gitlab/database/desired_sharding_key_spec.rb
spec/db/docs_spec.rb
spec/lib/gitlab/database/dictionary_spec.rb
ee/spec/lib/gitlab/database/inclusion_of_tables_with_gitlab_sec_schema_spec.rb
spec/lib/gitlab/database/no_new_tables_with_gitlab_main_schema_spec.rb
spec/lib/gitlab/database/sharding_key_spec.rb
]
}
]
class MappingTest
def initialize(explanation:, changed_file:, expected:, strategy:)
@explanation = explanation
@changed_file = changed_file
@strategy = strategy
@expected_set = Set.new(expected)
@actual_set = Set.new(actual)
end
def passed?
expected_set == actual_set
end
def failed?
!passed?
end
def failure_message
<<~MESSAGE
#{explanation}:
Changed file #{changed_file}
Expected #{expected_set.to_a}
Actual #{actual_set.to_a}
MESSAGE
end
private
attr_reader :explanation, :changed_file, :expected_set, :actual_set, :mapping
def actual
raise "changed_file must exist: #{changed_file}" unless File.exist?(changed_file)
tff = TestFileFinder::FileFinder.new(paths: [changed_file])
tff.use @strategy
tff.test_files
end
end
mapping_file = 'tests.yml'
strategy = TestFileFinder::MappingStrategies::PatternMatching.load(mapping_file)
results = tests.map { |test| MappingTest.new(strategy: strategy, **test) }
failed_tests = results.select(&:failed?)
if failed_tests.any?
puts <<~MESSAGE
tff mapping verification failed:
#{failed_tests.map(&:failure_message).join("\n")}
MESSAGE
exit 1
end
bad_sources = YAML.load_file(mapping_file)['mapping'].flat_map do |map|
Array(map['source']).filter_map { |source| source.match(/(?<!\\)\.\w+\z/)&.string }
end
if bad_sources.any?
puts "Suspicious metacharacter detected. Are these correct?"
bad_sources.each do |bad|
puts " #{bad} => Did you mean: #{bad.sub(/(\.\w+)\z/, '\\\\\1')}"
end
exit 1
end
puts 'tff mapping verification passed.'
|