Commit 825124f4 authored by Mark Lapierre's avatar Mark Lapierre Committed by Rémy Coutable

Skip package-and-qa if an MR only quarantines tests

parent 6c0e8406
...@@ -55,8 +55,14 @@ update-qa-cache: ...@@ -55,8 +55,14 @@ update-qa-cache:
before_script: before_script:
- source scripts/utils.sh - source scripts/utils.sh
- install_gitlab_gem - install_gitlab_gem
- tooling/bin/find_change_diffs ${CHANGES_DIFFS_DIR}
script: script:
- ./scripts/trigger-build omnibus - |
if tooling/bin/qa/check_if_only_quarantined_specs ${CHANGES_DIFFS_DIR}; then
exit 0
else
./scripts/trigger-build omnibus
fi
# These jobs often time out, so temporarily use private runners and a long timeout: https://gitlab.com/gitlab-org/gitlab/-/issues/238563 # These jobs often time out, so temporarily use private runners and a long timeout: https://gitlab.com/gitlab-org/gitlab/-/issues/238563
tags: tags:
- prm - prm
...@@ -66,14 +72,19 @@ update-qa-cache: ...@@ -66,14 +72,19 @@ update-qa-cache:
artifacts: false artifacts: false
- job: build-assets-image - job: build-assets-image
artifacts: false artifacts: false
.package-and-qa-ff-base:
needs:
- detect-tests - detect-tests
artifacts:
expire_in: 7d
paths:
- ${CHANGES_FILE}
- ${CHANGES_DIFFS_DIR}/*
variables: variables:
CHANGED_FILES: tmp/changed_files.txt CHANGES_FILE: tmp/changed_files.txt
CHANGES_DIFFS_DIR: tmp/diffs
.package-and-qa-ff-base:
script: script:
- export GITLAB_QA_OPTIONS="--set-feature-flags $(scripts/changed-feature-flags --files $(cat $CHANGED_FILES | tr ' ' ',') --state $QA_FF_STATE)" - export GITLAB_QA_OPTIONS="--set-feature-flags $(scripts/changed-feature-flags --files $(cat $CHANGES_FILE | tr ' ' ',') --state $QA_FF_STATE)"
- echo $GITLAB_QA_OPTIONS - echo $GITLAB_QA_OPTIONS
- ./scripts/trigger-build omnibus - ./scripts/trigger-build omnibus
......
...@@ -1258,7 +1258,7 @@ ...@@ -1258,7 +1258,7 @@
.rails:rules:detect-tests: .rails:rules:detect-tests:
rules: rules:
- changes: *code-backstage-patterns - changes: *code-backstage-qa-patterns
- <<: *if-merge-request-labels-run-all-rspec - <<: *if-merge-request-labels-run-all-rspec
.rails:rules:detect-previous-failed-tests: .rails:rules:detect-previous-failed-tests:
......
...@@ -123,7 +123,7 @@ Naming/FileName: ...@@ -123,7 +123,7 @@ Naming/FileName:
- 'ee/lib/generators/**/*' - 'ee/lib/generators/**/*'
- 'scripts/**/*' - 'scripts/**/*'
- 'spec/**/*' - 'spec/**/*'
- 'tooling/bin/*' - 'tooling/bin/**/*'
- 'ee/spec/**/*' - 'ee/spec/**/*'
- 'jh/spec/**/*' - 'jh/spec/**/*'
- 'qa/bin/*' - 'qa/bin/*'
......
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'gitlab'
require 'pathname'
# This script saves the diffs of changes in an MR to the directory specified as the first argument
gitlab_token = ENV.fetch('PROJECT_TOKEN_FOR_CI_SCRIPTS_API_USAGE')
gitlab_endpoint = ENV.fetch('CI_API_V4_URL')
mr_project_path = ENV.fetch('CI_MERGE_REQUEST_PROJECT_PATH')
mr_iid = ENV.fetch('CI_MERGE_REQUEST_IID')
abort("ERROR: Please specify a directory to write MR diffs into.") if ARGV.empty?
output_diffs_dir = Pathname.new(ARGV.shift).expand_path
Gitlab.configure do |config|
config.endpoint = gitlab_endpoint
config.private_token = gitlab_token
end
Gitlab.merge_request_changes(mr_project_path, mr_iid).changes.each do |change|
next if change['diff'].empty?
output_diffs_dir.join(File.dirname(change['new_path'])).mkpath
output_diffs_dir.join("#{change['new_path']}.diff").write(change['diff'])
end
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'pathname'
# This script assumes the first argument is a directory of files containing diffs of changes from an MR. It exits with a
# success code if all diffs add a line that quarantines a test. If any diffs are not specs, or they are specs that don't
# quarantine a test, it exits with code 1 to indicate failure (i.e., there was _not_ only quarantined specs).
abort("ERROR: Please specify the directory containing MR diffs.") if ARGV.empty?
diffs_dir = Pathname.new(ARGV.shift).expand_path
diffs_dir.glob('**/*').each do |path|
next if path.directory?
exit 1 unless path.to_s.end_with?('_spec.rb.diff')
exit 1 unless path.read.match?(/^\+.*, quarantine:/)
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment