From c01791446eb47e0acc9cbb9f286651661409ee46 Mon Sep 17 00:00:00 2001 From: Winnie Hellmann Date: Wed, 20 Feb 2019 18:06:26 +0100 Subject: Run only feature specs for frontend branches --- .gitlab-ci.yml | 1 + scripts/knapsack_file_pattern.rb | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100755 scripts/knapsack_file_pattern.rb diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c5cd006a289..9a24011bbae 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -140,6 +140,7 @@ stages: script: - JOB_NAME=( $CI_JOB_NAME ) - TEST_TOOL=${JOB_NAME[0]} + - export KNAPSACK_TEST_FILE_PATTERN=$(scripts/knapsack_file_pattern.rb) - export KNAPSACK_REPORT_PATH=knapsack/${CI_PROJECT_NAME}/${TEST_TOOL}_node_${CI_NODE_INDEX}_${CI_NODE_TOTAL}_report.json - export KNAPSACK_GENERATE_REPORT=true - export SUITE_FLAKY_RSPEC_REPORT_PATH=${FLAKY_RSPEC_SUITE_REPORT_PATH} diff --git a/scripts/knapsack_file_pattern.rb b/scripts/knapsack_file_pattern.rb new file mode 100755 index 00000000000..69c5f22e006 --- /dev/null +++ b/scripts/knapsack_file_pattern.rb @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby + +# Change test file pattern to match only feature specs for branches ending with "-frontend" +class KnapsackFilePattern + def run + frontend_branch = ENV['CI_COMMIT_REF_NAME'] =~ /-frontend(-ee)?$/ + + if ENV['CI_PROJECT_NAMESPACE'] == 'gitlab-org' && frontend_branch + warn 'Running only feature specs for frontend branch...' + puts 'spec/features/**{,/*/**}/*_spec.rb' + else + puts 'spec/**{,/*/**}/*_spec.rb' + end + end +end + +KnapsackFilePattern.new.run -- cgit v1.2.1