From 925b4d2825f9d20b6b1029d153044f029392fdd6 Mon Sep 17 00:00:00 2001 From: David Dieulivol <ddieulivol@gitlab.com> Date: Mon, 4 Mar 2024 15:59:18 +0000 Subject: [PATCH] Add the rspec_section function This will make it easier to wrap the RSpec commands into sections. --- .gitlab/ci/rails.gitlab-ci.yml | 6 +++--- .gitlab/ci/rails/shared.gitlab-ci.yml | 11 +++++++---- scripts/utils.sh | 9 ++++++++- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/.gitlab/ci/rails.gitlab-ci.yml b/.gitlab/ci/rails.gitlab-ci.yml index 9a9688ea1c0ca..2467975ff9a04 100644 --- a/.gitlab/ci/rails.gitlab-ci.yml +++ b/.gitlab/ci/rails.gitlab-ci.yml @@ -320,7 +320,7 @@ rspec fast_spec_helper: script: - fast_spec_helper_specs=$(git grep -l -E '^require.*fast_spec_helper') # Load fast_spec_helper as well just in case there are no specs available. - - bin/rspec --dry-run spec/fast_spec_helper.rb $fast_spec_helper_specs + - rspec_section bin/rspec --dry-run spec/fast_spec_helper.rb ${fast_spec_helper_specs} rspec unit clickhouse: extends: @@ -1236,7 +1236,7 @@ rspec-ee system pg16 es8: stage: test script: - !reference [.base-script, script] - - rspec_fail_fast "${MATCHING_TESTS_PATH}" "--fail-fast=${RSPEC_FAIL_FAST_THRESHOLD} --tag ~quarantine --tag ~zoekt --tag ~click_house" + - rspec_section rspec_fail_fast "${MATCHING_TESTS_PATH}" "--fail-fast=${RSPEC_FAIL_FAST_THRESHOLD} --tag ~quarantine --tag ~zoekt --tag ~click_house" rspec fail-fast: extends: @@ -1315,7 +1315,7 @@ fail-pipeline-early: - job: "detect-previous-failed-tests" script: - !reference [.base-script, script] - - rspec_rerun_previous_failed_tests "${PREVIOUS_FAILED_TESTS_FILE}" + - rspec_section rspec_rerun_previous_failed_tests ${PREVIOUS_FAILED_TESTS_FILE} rspec rspec-pg14-rerun-previous-failed-tests: extends: diff --git a/.gitlab/ci/rails/shared.gitlab-ci.yml b/.gitlab/ci/rails/shared.gitlab-ci.yml index 12a3dde31d8cc..ec2f48b3ac392 100644 --- a/.gitlab/ci/rails/shared.gitlab-ci.yml +++ b/.gitlab/ci/rails/shared.gitlab-ci.yml @@ -27,7 +27,10 @@ include: - section_start "gitaly-test-spawn" "Spawning Gitaly"; scripts/gitaly-test-spawn; section_end "gitaly-test-spawn" # Do not use 'bundle exec' here - export RSPEC_SKIPPED_TESTS_REPORT_PATH="rspec/skipped_tests-${CI_JOB_ID}.txt" - export RSPEC_RETRIED_TESTS_REPORT_PATH="rspec/retried_tests-${CI_JOB_ID}.txt" - - tooling/bin/create_job_metrics_file || true + - | + section_start "job-metrics" "Create Job Metrics file" + tooling/bin/create_job_metrics_file || true + section_end "job-metrics" .no-redis-cluster: variables: @@ -87,7 +90,7 @@ include: # spec/lib, yet background migration tests are also sitting there, # and they should run on their own jobs so we don't need to run them # in unit tests again. - - rspec_parallelized_job "--fail-fast=${RSPEC_FAIL_FAST_THRESHOLD} --tag ~quarantine --tag ~level:background_migration --tag ~click_house --tag ~real_ai_request" + - rspec_section rspec_parallelized_job "--fail-fast=${RSPEC_FAIL_FAST_THRESHOLD} --tag ~quarantine --tag ~level:background_migration --tag ~click_house --tag ~real_ai_request" after_script: - echo -e "\e[0Ksection_start:`date +%s`:report_results_section[collapsed=true]\r\e[0KReport results" - bundle exec gem list gitlab_quality-test_tooling @@ -165,7 +168,7 @@ include: .rspec-base-migration: script: - !reference [.base-script, script] - - rspec_parallelized_job "--fail-fast=${RSPEC_FAIL_FAST_THRESHOLD} --tag ~quarantine --tag ~zoekt --tag ~click_house" + - rspec_section rspec_parallelized_job "--fail-fast=${RSPEC_FAIL_FAST_THRESHOLD} --tag ~quarantine --tag ~zoekt --tag ~click_house" after_script: - !reference [.rspec-base, after_script] @@ -187,7 +190,7 @@ include: - cp config/click_house.yml.example config/click_house.yml - 'sed -i "s|url:.*$|url: http://clickhouse:8123|g" config/click_house.yml' - !reference [.base-script, script] - - rspec_parallelized_job "--fail-fast=${RSPEC_FAIL_FAST_THRESHOLD} --tag click_house" + - rspec_section rspec_parallelized_job "--fail-fast=${RSPEC_FAIL_FAST_THRESHOLD} --tag click_house" .rspec-base-pg14-as-if-foss: extends: diff --git a/scripts/utils.sh b/scripts/utils.sh index 5996fe7724c02..7eca5de1d5378 100644 --- a/scripts/utils.sh +++ b/scripts/utils.sh @@ -67,8 +67,9 @@ function test_url() { function section_start () { local section_title="${1}" local section_description="${2:-$section_title}" + local collapsed="${3:-true}" - echo -e "section_start:`date +%s`:${section_title}[collapsed=true]\r\e[0K${section_description}" + echo -e "section_start:`date +%s`:${section_title}[collapsed=${collapsed}]\r\e[0K${section_description}" } function section_end () { @@ -77,6 +78,12 @@ function section_end () { echo -e "section_end:`date +%s`:${section_title}\r\e[0K" } +function rspec_section() { + section_start "rspec" "RSpec" "false" + "$@" + section_end "rspec" +} + function bundle_install_script() { local extra_install_args="${1}" -- GitLab