Skip to content
代码片段 群组 项目
提交 d07c6e34 编辑于 作者: Lin Jen-Shin's avatar Lin Jen-Shin
浏览文件

Also write Crystalball coverage strategy mapping data

This should not affect any actual behaviour because it should still read
and write with the described strategy. We just additionally also write
another mapping file for coverage strategy so that we can compare them.
上级 94760285
No related branches found
No related tags found
无相关合并请求
......@@ -193,9 +193,11 @@ variables:
RSPEC_MATCHING_TESTS_FOSS_PATH: rspec/matching_tests-foss.txt
RSPEC_MATCHING_TESTS_PATH: rspec/matching_tests.txt
RSPEC_PACKED_TESTS_MAPPING_PATH: crystalball/packed-mapping.json
RSPEC_PACKED_TESTS_MAPPING_ALT_PATH: crystalball/packed-mapping-alt.json
RSPEC_PREDICTIVE_PIPELINE_TEMPLATE_YML: .gitlab/ci/rails/rspec-predictive.gitlab-ci.yml.erb
RSPEC_PROFILING_FOLDER_PATH: rspec/profiling
RSPEC_TESTS_MAPPING_PATH: crystalball/mapping.json
RSPEC_TESTS_MAPPING_ALT_PATH: crystalball/mapping-alt.json
RSPEC_VIEWS_INCLUDING_PARTIALS_PATH: rspec/views_including_partials.txt
RSPEC_AUTO_EXPLAIN_LOG_PATH: auto_explain/auto_explain.ndjson.gz
TMP_TEST_FOLDER: "${CI_PROJECT_DIR}/tmp/tests"
......
......@@ -21,15 +21,16 @@ pages:
script:
- mv public/ .public/
- mkdir public/
- mkdir -p public/$(dirname "$KNAPSACK_RSPEC_SUITE_REPORT_PATH") public/$(dirname "$FLAKY_RSPEC_SUITE_REPORT_PATH") public/$(dirname "$RSPEC_PACKED_TESTS_MAPPING_PATH") public/$(dirname "$FRONTEND_FIXTURES_MAPPING_PATH")
- mkdir -p public/$(dirname "$KNAPSACK_RSPEC_SUITE_REPORT_PATH") public/$(dirname "$FLAKY_RSPEC_SUITE_REPORT_PATH") public/$(dirname "$RSPEC_PACKED_TESTS_MAPPING_PATH") public/$(dirname "$RSPEC_PACKED_TESTS_MAPPING_ALT_PATH") public/$(dirname "$FRONTEND_FIXTURES_MAPPING_PATH")
- mv coverage/ public/coverage-ruby/ || true
- mv coverage-frontend/ public/coverage-frontend/ || true
- mv storybook/public public/storybook || true
- cp .public/assets/application-*.css public/application.css || true
- mv $KNAPSACK_RSPEC_SUITE_REPORT_PATH public/$KNAPSACK_RSPEC_SUITE_REPORT_PATH || true
- mv $FLAKY_RSPEC_SUITE_REPORT_PATH public/$FLAKY_RSPEC_SUITE_REPORT_PATH || true
- mv $RSPEC_PACKED_TESTS_MAPPING_PATH.gz public/$RSPEC_PACKED_TESTS_MAPPING_PATH.gz || true
- mv $FRONTEND_FIXTURES_MAPPING_PATH public/$FRONTEND_FIXTURES_MAPPING_PATH || true
- mv $RSPEC_PACKED_TESTS_MAPPING_PATH.gz public/ || true
- mv $RSPEC_PACKED_TESTS_MAPPING_ALT_PATH.gz public/ || true
- mv $FRONTEND_FIXTURES_MAPPING_PATH public/ || true
- *compress-public
artifacts:
paths:
......
......@@ -2993,6 +2993,12 @@
changes:
- ".gitlab/ci/test-metadata.gitlab-ci.yml"
- "scripts/rspec_helpers.sh"
- <<: *if-merge-request
changes:
- ".gitlab/ci/test-metadata.gitlab-ci.yml"
- "scripts/rspec_helpers.sh"
when: manual
allow_failure: true
- <<: *if-merge-request-not-approved
when: never
- <<: *if-merge-request
......
......@@ -29,23 +29,23 @@ update-tests-metadata:
- .tests-metadata-state
- .test-metadata:rules:update-tests-metadata
stage: post-test
dependencies:
- retrieve-tests-metadata
- generate-frontend-fixtures-mapping
- setup-test-env
- rspec migration pg14
- rspec-all frontend_fixture
- rspec unit pg14
- rspec unit clickhouse
- rspec integration pg14
- rspec system pg14
- rspec background_migration pg14
- rspec-ee migration pg14
- rspec-ee unit pg14
- rspec-ee unit clickhouse
- rspec-ee integration pg14
- rspec-ee system pg14
- rspec-ee background_migration pg14
needs:
- job: retrieve-tests-metadata
optional: true
- job: generate-frontend-fixtures-mapping
optional: true
- job: setup-test-env
optional: true
- job: rspec:artifact-collector unit
optional: true
- job: rspec:artifact-collector part-a
optional: true
- job: rspec:artifact-collector part-b
optional: true
- job: rspec:artifact-collector ee unit
optional: true
- job: rspec:artifact-collector ee remainder
optional: true
script:
- run_timed_command "retry gem install fog-aws mime-types activesupport rspec_profiling postgres-copy --no-document"
- source ./scripts/rspec_helpers.sh
......
......@@ -72,19 +72,25 @@ function retrieve_frontend_fixtures_mapping() {
}
function update_tests_mapping() {
if ! crystalball_rspec_data_exists; then
echo "No crystalball rspec data found."
return 0
fi
pack_and_gzip_mapping "${RSPEC_TESTS_MAPPING_PATH}" "${RSPEC_PACKED_TESTS_MAPPING_PATH}" crystalball/described/rspec*.yml
scripts/generate-test-mapping "${RSPEC_TESTS_MAPPING_PATH:-unknown_file}" crystalball/rspec*.yml
scripts/pack-test-mapping "${RSPEC_TESTS_MAPPING_PATH:-unknown_file}" "${RSPEC_PACKED_TESTS_MAPPING_PATH:-unknown_file}"
gzip "${RSPEC_PACKED_TESTS_MAPPING_PATH:-unknown_file}"
rm -f crystalball/rspec*.yml "${RSPEC_PACKED_TESTS_MAPPING_PATH:-unknown_file}"
pack_and_gzip_mapping "${RSPEC_TESTS_MAPPING_ALT_PATH}" "${RSPEC_PACKED_TESTS_MAPPING_ALT_PATH}" crystalball/coverage/rspec*.yml
}
function crystalball_rspec_data_exists() {
compgen -G "crystalball/rspec*.yml" >/dev/null
function pack_and_gzip_mapping() {
local mapping_path="${1}"
local packed_path="${2}"
local crystal_yaml_files=("${@:3}")
if test -z "${crystal_yaml_files[1]}"; then
echo "No crystalball rspec data for ${mapping_path}"
return 0
fi
scripts/generate-test-mapping "${mapping_path}" "${crystal_yaml_files[@]}"
scripts/pack-test-mapping "${mapping_path}" "${packed_path}"
gzip "${packed_path}"
rm -f "${packed_path}" "${mapping_path}" "${crystal_yaml_files[@]}"
}
function retrieve_failed_tests() {
......
......@@ -9,13 +9,16 @@ def start!
return unless ENV['CRYSTALBALL'] == 'true'
require 'crystalball'
require_relative '../tooling/lib/tooling/crystalball/described_class_execution_detector'
map_storage_path_base = ENV['CI_JOB_NAME'] || 'crystalball_data'
map_storage_path = "crystalball/#{map_storage_path_base.gsub(%r{[/ ]}, '_')}.yml"
enable_described_strategy # We use this for writing and reading
enable_coverage_strategy # We use this only for writing for now
end
def enable_described_strategy
require_relative '../tooling/lib/tooling/crystalball/described_class_execution_detector'
Crystalball::MapGenerator.start! do |config|
config.map_storage_path = map_storage_path
config.map_storage_path = "crystalball/described/#{map_storage_name}.yml"
# https://toptal.github.io/crystalball/map_generators/#describedclassstrategy
described_class_execution_detector = Tooling::Crystalball::DescribedClassExecutionDetector.new(
......@@ -25,18 +28,30 @@ def start!
config.register Crystalball::MapGenerator::DescribedClassStrategy.new(
execution_detector: described_class_execution_detector
)
end
end
# Modified version of https://toptal.github.io/crystalball/map_generators/#coveragestrategy
#
# require_relative '../tooling/lib/tooling/crystalball/coverage_lines_execution_detector'
# require_relative '../tooling/lib/tooling/crystalball/coverage_lines_strategy'
# execution_detector = Tooling::Crystalball::CoverageLinesExecutionDetector.new(
# exclude_prefixes: EXCLUDED_PREFIXES
# )
# config.register Tooling::Crystalball::CoverageLinesStrategy.new(execution_detector)
def enable_coverage_strategy
# Modified version of https://toptal.github.io/crystalball/map_generators/#coveragestrategy
require_relative '../tooling/lib/tooling/crystalball/coverage_lines_execution_detector'
require_relative '../tooling/lib/tooling/crystalball/coverage_lines_strategy'
Crystalball::MapGenerator.start! do |config|
config.map_storage_path = "crystalball/coverage/#{map_storage_name}.yml"
execution_detector = Tooling::Crystalball::CoverageLinesExecutionDetector
.new(exclude_prefixes: EXCLUDED_PREFIXES)
config.register Tooling::Crystalball::CoverageLinesStrategy
.new(execution_detector)
# https://toptal.github.io/crystalball/map_generators/#actionviewstrategy
# require 'crystalball/rails/map_generator/action_view_strategy'
# config.register Crystalball::Rails::MapGenerator::ActionViewStrategy.new
end
end
def map_storage_name
(ENV['CI_JOB_NAME'] || 'crystalball_data').gsub(%r{[/ ]}, '_')
end
end
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册