diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-30 12:12:25 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-30 12:12:25 +0000 |
commit | 60273ebb302dabd6e724e4b7baf9ed7b39de5c09 (patch) | |
tree | 094133ffdc73d53c56e9779cfeb4f3a548d255c3 /scripts | |
parent | 0c918eb567a29de7ecfc890e8e2dd90e900e7e58 (diff) | |
download | gitlab-ce-60273ebb302dabd6e724e4b7baf9ed7b39de5c09.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/determine-qa-tests | 106 | ||||
-rwxr-xr-x | scripts/generate-e2e-pipeline | 33 | ||||
-rwxr-xr-x | scripts/trigger-build.rb | 8 |
3 files changed, 35 insertions, 112 deletions
diff --git a/scripts/determine-qa-tests b/scripts/determine-qa-tests deleted file mode 100755 index b1e9d8e9312..00000000000 --- a/scripts/determine-qa-tests +++ /dev/null @@ -1,106 +0,0 @@ -#!/usr/bin/env ruby -# frozen_string_literal: true - -require 'optparse' - -# This script returns end-to-end tests or test directories. The returned value is stored in QA_TESTS -# variable for executing only those tests. - -class DetermineQATests # rubocop:disable Gitlab/NamespacedClass - def initialize(options) - @changed_files = options.delete(:changed_files) - @mr_labels = options.delete(:mr_labels) || [] - end - - def execute - # If only e2e test files have changed, run only those tests - qa_tests = if has_qa_spec_only_changes? - changed_files - - # If only non qa files have changed, use the devops MR label to run the files in the related directory - # However, if a feature flag file has changed, do not return any specific test/test directory - elsif has_non_qa_only_changes? && mr_labels.any? && !has_dev_ops_feature_flag_changes? - devops_stage = devops_stage_from_mr_labels - - qa_spec_directories_for_devops_stage(devops_stage) if devops_stage - end - - trim_path(qa_tests).join(' ') if qa_tests - end - - private - - attr_reader :changed_files, :mr_labels - - # Are the changed files only qa specs? - # - # @return [Boolean] whether the changes files are only qa specs - def has_qa_spec_only_changes? - changed_files.all? { |file_path| file_path =~ %r{^qa/qa/specs/features/} } - end - - # Are the changed files only outside the qa directory? - # - # @return [Boolean] whether the changes files are outside of qa directory - def has_non_qa_only_changes? - changed_files.none? { |file_path| file_path =~ %r{^qa/} } - end - - # Are the changed files for development and ops feature flags? - # - # @return [Boolean] whether the changes files are for development and ops feature flags - def has_dev_ops_feature_flag_changes? - changed_files.any? { |file_path| file_path =~ %r{/feature_flags/(development|ops)/.*\.yml} } - end - - # Remove the leading `qa/` from the file or directory paths - # - # @param [Array] paths Array of file or directory paths - # @return [Array] Array of files or directories with the first occurance of `qa/` removed - def trim_path(paths) - paths.map { |path| path.delete_prefix("qa/") } - end - - # Extract devops stage from MR labels - # - # @return [String] a devops stage - def devops_stage_from_mr_labels - mr_labels.find { |label| label =~ /^devops::/ }&.delete_prefix('devops::') - end - - # Get qa spec directories for devops stage - # - # @param [String] devops_stage a devops stage - # @return [Array] qa spec directories - def qa_spec_directories_for_devops_stage(devops_stage) - Dir.glob("qa/qa/specs/**/*/").select { |dir| dir =~ %r{\d+_#{devops_stage}/$} } - end -end - -if $0 == __FILE__ - options = {} - - OptionParser.new do |opts| - opts.on("-f", "--files CHANGED_FILES_PATH", String, - "A path to a file containing a list of changed files") do |value| - changed_files_path = value - abort("ERROR: The specified changed files path does not exist") unless File.exist?(changed_files_path) - - changed_files = File.read(changed_files_path).split(' ') - abort("ERROR: There are no changed files") if changed_files.empty? - - options[:changed_files] = changed_files - end - - opts.on("-l", "--labels MR_LABELS", String, "A comma separated list of MR labels") do |value| - options[:mr_labels] = Array(value&.split(',')).compact - end - - opts.on("-h", "--help", "Prints this help") do - puts opts - exit - end - end.parse! - - puts DetermineQATests.new(options).execute -end diff --git a/scripts/generate-e2e-pipeline b/scripts/generate-e2e-pipeline new file mode 100755 index 00000000000..0fa940d69af --- /dev/null +++ b/scripts/generate-e2e-pipeline @@ -0,0 +1,33 @@ +#!/bin/bash + +set -e + +# Script to generate e2e test child pipeline +# This is required because environment variables that are generated dynamically are not picked up by rules in child pipelines + +pipeline_yml="${1:-package-and-test.yml}" + +if [ "$QA_SKIP_ALL_TESTS" == "true" ]; then + echo "Generated no-op child pipeline due to QA_SKIP_ALL_TESTS set to 'true'" + cp .gitlab/ci/package-and-test/skip.gitlab-ci.yml $pipeline_yml + exit +fi + +variables=$(cat <<YML +variables: + RELEASE: "${CI_REGISTRY}/gitlab-org/build/omnibus-gitlab-mirror/gitlab-ee:${CI_MERGE_REQUEST_SOURCE_BRANCH_SHA:-$CI_COMMIT_SHA}" + SKIP_REPORT_IN_ISSUES: "${SKIP_REPORT_IN_ISSUES:-true}" + COLORIZED_LOGS: "true" + QA_LOG_LEVEL: "info" + QA_TESTS: "$QA_TESTS" + QA_FEATURE_FLAGS: "${QA_FEATURE_FLAGS}" + QA_FRAMEWORK_CHANGES: "${QA_FRAMEWORK_CHANGES:-false}" + QA_SUITES: "$QA_SUITES" +YML +) + +echo "$variables" >$pipeline_yml +cat .gitlab/ci/package-and-test/main.gitlab-ci.yml >>$pipeline_yml + +echo "Generated e2e:package-and-test pipeline with following variables section:" +echo "$variables" diff --git a/scripts/trigger-build.rb b/scripts/trigger-build.rb index 57cc6a8551e..8183a816b26 100755 --- a/scripts/trigger-build.rb +++ b/scripts/trigger-build.rb @@ -194,16 +194,12 @@ module Trigger { 'GITLAB_VERSION' => source_sha, 'IMAGE_TAG' => source_sha, - 'QA_IMAGE' => ENV['QA_IMAGE'], 'SKIP_QA_DOCKER' => 'true', + 'SKIP_QA_TEST' => 'true', 'ALTERNATIVE_SOURCES' => 'true', 'SECURITY_SOURCES' => Trigger.security? ? 'true' : 'false', 'ee' => Trigger.ee? ? 'true' : 'false', - 'QA_BRANCH' => ENV['QA_BRANCH'] || 'master', - 'CACHE_UPDATE' => ENV['OMNIBUS_GITLAB_CACHE_UPDATE'], - 'GITLAB_QA_OPTIONS' => ENV['GITLAB_QA_OPTIONS'], - 'QA_TESTS' => ENV['QA_TESTS'], - 'ALLURE_JOB_NAME' => ENV['ALLURE_JOB_NAME'] + 'CACHE_UPDATE' => ENV['OMNIBUS_GITLAB_CACHE_UPDATE'] } end end |