Commit a6c166a8 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'ml-fix-package-and-qa-in-master' into 'master'

Always run `package-and-qa` in scheduled pipelines

See merge request gitlab-org/gitlab!73900
parents 9659e770 c62a0085
......@@ -58,10 +58,13 @@ update-qa-cache:
- tooling/bin/find_change_diffs ${CHANGES_DIFFS_DIR}
script:
- |
if tooling/bin/qa/check_if_only_quarantined_specs ${CHANGES_DIFFS_DIR}; then
exit 0
else
tooling/bin/qa/package_and_qa_check ${CHANGES_DIFFS_DIR} && exit_code=$?
if [ $exit_code -eq 0 ]; then
./scripts/trigger-build omnibus
elif [ $exit_code -eq 1 ]; then
exit 1
else
echo "Downstream jobs will not be triggered because package_and_qa_check exited with code: $exit_code"
fi
# These jobs often time out, so temporarily use private runners and a long timeout: https://gitlab.com/gitlab-org/gitlab/-/issues/238563
tags:
......
......@@ -5,11 +5,22 @@ require 'gitlab'
require 'pathname'
# This script saves the diffs of changes in an MR to the directory specified as the first argument
#
# It exits with a success code if diffs are found and saved, or if there are no changes, including if the script runs in
# a pipeline that is not for a merge request.
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')
mr_project_path = ENV['CI_MERGE_REQUEST_PROJECT_PATH']
mr_iid = ENV['CI_MERGE_REQUEST_IID']
puts "CI_MERGE_REQUEST_PROJECT_PATH is missing." if mr_project_path.to_s.empty?
puts "CI_MERGE_REQUEST_IID is missing." if mr_iid.to_s.empty?
unless mr_project_path && mr_iid
puts "Exiting as this does not appear to be a merge request pipeline."
exit
end
abort("ERROR: Please specify a directory to write MR diffs into.") if ARGV.empty?
output_diffs_dir = Pathname.new(ARGV.shift).expand_path
......
#!/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
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'pathname'
# This script checks if the package-and-qa job should trigger downstream pipelines to run 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 package-and-qa 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 package-and-qa 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 package-and-qa if there are no specs. E.g., when the MR changes QA framework files.
exit 0 if specs_count == 0
# Skip package-and-qa if there are only specs being put in quarantine.
exit 2 if quarantine_specs_count == specs_count && quarantine_specs_count == files_count
# Run package-and-qa 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.
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