diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-20 02:18:09 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-20 02:18:09 +0300 |
commit | 6ed4ec3e0b1340f96b7c043ef51d1b33bbe85fde (patch) | |
tree | dc4d20fe6064752c0bd323187252c77e0a89144b /tooling | |
parent | 9868dae7fc0655bd7ce4a6887d4e6d487690eeed (diff) |
Add latest changes from gitlab-org/gitlab@15-4-stable-eev15.4.0-rc42
Diffstat (limited to 'tooling')
-rwxr-xr-x | tooling/bin/find_changes | 10 | ||||
-rwxr-xr-x | tooling/bin/qa/run_qa_check | 45 | ||||
-rw-r--r-- | tooling/config/CODEOWNERS.yml | 12 | ||||
-rw-r--r-- | tooling/danger/config_files.rb | 43 | ||||
-rw-r--r-- | tooling/danger/project_helper.rb | 4 |
5 files changed, 61 insertions, 53 deletions
diff --git a/tooling/bin/find_changes b/tooling/bin/find_changes index 8ad5011459b..38e1f363dd9 100755 --- a/tooling/bin/find_changes +++ b/tooling/bin/find_changes @@ -46,12 +46,16 @@ class FindChanges # rubocop:disable Gitlab/NamespacedClass config.private_token = gitlab_token end - mr_changes = Gitlab.merge_request_changes(mr_project_path, mr_iid) - - mr_changes.changes.map { |change| change['new_path'] unless change['deleted_file'] }.compact + mr_changes.changes.flat_map do |change| + change.to_h.values_at('old_path', 'new_path') + end.uniq end end + def mr_changes + @mr_changes ||= Gitlab.merge_request_changes(mr_project_path, mr_iid) + end + def test_files return [] if !matched_tests_file || !File.exist?(matched_tests_file) diff --git a/tooling/bin/qa/run_qa_check b/tooling/bin/qa/run_qa_check deleted file mode 100755 index 5b8844ec4fd..00000000000 --- a/tooling/bin/qa/run_qa_check +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env ruby -# frozen_string_literal: true - -require 'pathname' - -# This script checks if the code changes justify running the QA suite. -# -# It assumes the first argument is a directory of files containing diffs of changes from an MR -# (e.g., created by tooling/bin/find_change_diffs). It exits with a success code if there are no diffs, or if the diffs -# are suitable to run QA tests. -# -# The script will abort (exit code 1) if the argument is missing. -# -# The following condition will result in a failure code (2), indicating that QA tests should not run: -# -# - If the changes only include tests being put in quarantine - -abort("ERROR: Please specify the directory containing MR diffs.") if ARGV.empty? -diffs_dir = Pathname.new(ARGV.shift).expand_path - -# Run QA tests if there are no diffs. E.g., in scheduled pipelines -exit 0 if diffs_dir.glob('**/*').empty? - -files_count = 0 -specs_count = 0 -quarantine_specs_count = 0 - -diffs_dir.glob('**/*').each do |path| - next if path.directory? - - files_count += 1 - next unless path.to_s.end_with?('_spec.rb.diff') - - specs_count += 1 - quarantine_specs_count += 1 if path.read.match?(/^\+.*,? quarantine:/) -end - -# Run QA tests if there are no specs. E.g., when the MR changes QA framework files. -exit 0 if specs_count == 0 - -# Skip QA tests if there are only specs being put in quarantine. -exit 2 if quarantine_specs_count == specs_count && quarantine_specs_count == files_count - -# Run QA tests under any other circumstances. E.g., if there are specs being put in quarantine but there are also -# other changes that might need to be tested. diff --git a/tooling/config/CODEOWNERS.yml b/tooling/config/CODEOWNERS.yml index 71818b67ab1..6b24134ea17 100644 --- a/tooling/config/CODEOWNERS.yml +++ b/tooling/config/CODEOWNERS.yml @@ -47,7 +47,7 @@ - 'jira_connect/' - 'kubernetes/' - 'protected_environments/' - - '/config/feature_flags/development/jira_connect_*' + - '/config/feature_flags/**/*' - '/config/metrics/' - '/app/controllers/groups/dependency_proxy_auth_controller.rb' - '/app/finders/ci/auth_job_finder.rb' @@ -65,17 +65,19 @@ keywords: - audit patterns: - - '**%{keyword}**' + - '/{,ee/}app/**/*%{keyword}*' + - '/{,ee/}config/**/*%{keyword}*' + - '/{,ee/}lib/**/*%{keyword}*' deny: keywords: - '*.png' - '*bundler-audit*' - '**/merge_requests/**' - - '/ee/app/services/audit_events/*' + - '/config/feature_flags/**/*' + - '/ee/app/services/audit_events/**/*' - '/ee/config/feature_flags/development/auditor_group_runner_access.yml' - - '/ee/spec/services/audit_events/*' + - '/ee/spec/services/audit_events/**/*' - '/ee/spec/services/ci/*' - '/ee/spec/services/personal_access_tokens/*' - - '/qa/**/*' patterns: - '%{keyword}' diff --git a/tooling/danger/config_files.rb b/tooling/danger/config_files.rb new file mode 100644 index 00000000000..436335bfc06 --- /dev/null +++ b/tooling/danger/config_files.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +require 'yaml' + +module Tooling + module Danger + module ConfigFiles + SUGGEST_INTRODUCED_BY_COMMENT = <<~SUGGEST_COMMENT + ```suggestion + introduced_by_url: "%<url>s" + ``` + SUGGEST_COMMENT + + CONFIG_DIRS = %w[ + config/feature_flags + config/metrics + config/events + ].freeze + + def add_suggestion_for_missing_introduced_by_url + new_config_files.each do |file_name| + config_file_lines = project_helper.file_lines(file_name) + + config_file_lines.each_with_index do |added_line, i| + next unless added_line =~ /^introduced_by_url:\s?$/ + + markdown(format(SUGGEST_INTRODUCED_BY_COMMENT, url: helper.mr_web_url), file: file_name, line: i + 1) + end + end + end + + def new_config_files + helper.added_files.select { |f| in_config_dir?(f) && f.end_with?('yml') } + end + + private + + def in_config_dir?(path) + CONFIG_DIRS.any? { |d| path.start_with?(d) } + end + end + end +end diff --git a/tooling/danger/project_helper.rb b/tooling/danger/project_helper.rb index d8c7d617927..1d052bf6bbd 100644 --- a/tooling/danger/project_helper.rb +++ b/tooling/danger/project_helper.rb @@ -17,6 +17,10 @@ module Tooling # First-match win, so be sure to put more specific regex at the top... CATEGORIES = { + # GitLab Flavored Markdown Specification files. See more context at: https://docs.gitlab.com/ee/development/gitlab_flavored_markdown/specification_guide/#specification-files + %r{\Aglfm_specification/.+prosemirror_json\.yml} => [:frontend], + %r{\Aglfm_specification/.+\.yml} => [:frontend, :backend], + [%r{usage_data\.rb}, %r{^(\+|-).*\s+(count|distinct_count|estimate_batch_distinct_count)\(.*\)(.*)$}] => [:database, :backend, :product_intelligence], %r{\A((ee|jh)/)?config/feature_flags/} => :feature_flag, |