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: ...@@ -193,9 +193,11 @@ variables:
RSPEC_MATCHING_TESTS_FOSS_PATH: rspec/matching_tests-foss.txt RSPEC_MATCHING_TESTS_FOSS_PATH: rspec/matching_tests-foss.txt
RSPEC_MATCHING_TESTS_PATH: rspec/matching_tests.txt RSPEC_MATCHING_TESTS_PATH: rspec/matching_tests.txt
RSPEC_PACKED_TESTS_MAPPING_PATH: crystalball/packed-mapping.json 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_PREDICTIVE_PIPELINE_TEMPLATE_YML: .gitlab/ci/rails/rspec-predictive.gitlab-ci.yml.erb
RSPEC_PROFILING_FOLDER_PATH: rspec/profiling RSPEC_PROFILING_FOLDER_PATH: rspec/profiling
RSPEC_TESTS_MAPPING_PATH: crystalball/mapping.json 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_VIEWS_INCLUDING_PARTIALS_PATH: rspec/views_including_partials.txt
RSPEC_AUTO_EXPLAIN_LOG_PATH: auto_explain/auto_explain.ndjson.gz RSPEC_AUTO_EXPLAIN_LOG_PATH: auto_explain/auto_explain.ndjson.gz
TMP_TEST_FOLDER: "${CI_PROJECT_DIR}/tmp/tests" TMP_TEST_FOLDER: "${CI_PROJECT_DIR}/tmp/tests"
......
...@@ -21,15 +21,16 @@ pages: ...@@ -21,15 +21,16 @@ pages:
script: script:
- mv public/ .public/ - mv public/ .public/
- mkdir 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/ public/coverage-ruby/ || true
- mv coverage-frontend/ public/coverage-frontend/ || true - mv coverage-frontend/ public/coverage-frontend/ || true
- mv storybook/public public/storybook || true - mv storybook/public public/storybook || true
- cp .public/assets/application-*.css public/application.css || true - cp .public/assets/application-*.css public/application.css || true
- mv $KNAPSACK_RSPEC_SUITE_REPORT_PATH public/$KNAPSACK_RSPEC_SUITE_REPORT_PATH || 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 $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 $RSPEC_PACKED_TESTS_MAPPING_PATH.gz public/ || true
- mv $FRONTEND_FIXTURES_MAPPING_PATH public/$FRONTEND_FIXTURES_MAPPING_PATH || true - mv $RSPEC_PACKED_TESTS_MAPPING_ALT_PATH.gz public/ || true
- mv $FRONTEND_FIXTURES_MAPPING_PATH public/ || true
- *compress-public - *compress-public
artifacts: artifacts:
paths: paths:
......
...@@ -2993,6 +2993,12 @@ ...@@ -2993,6 +2993,12 @@
changes: changes:
- ".gitlab/ci/test-metadata.gitlab-ci.yml" - ".gitlab/ci/test-metadata.gitlab-ci.yml"
- "scripts/rspec_helpers.sh" - "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 - <<: *if-merge-request-not-approved
when: never when: never
- <<: *if-merge-request - <<: *if-merge-request
......
...@@ -29,23 +29,23 @@ update-tests-metadata: ...@@ -29,23 +29,23 @@ update-tests-metadata:
- .tests-metadata-state - .tests-metadata-state
- .test-metadata:rules:update-tests-metadata - .test-metadata:rules:update-tests-metadata
stage: post-test stage: post-test
dependencies: needs:
- retrieve-tests-metadata - job: retrieve-tests-metadata
- generate-frontend-fixtures-mapping optional: true
- setup-test-env - job: generate-frontend-fixtures-mapping
- rspec migration pg14 optional: true
- rspec-all frontend_fixture - job: setup-test-env
- rspec unit pg14 optional: true
- rspec unit clickhouse - job: rspec:artifact-collector unit
- rspec integration pg14 optional: true
- rspec system pg14 - job: rspec:artifact-collector part-a
- rspec background_migration pg14 optional: true
- rspec-ee migration pg14 - job: rspec:artifact-collector part-b
- rspec-ee unit pg14 optional: true
- rspec-ee unit clickhouse - job: rspec:artifact-collector ee unit
- rspec-ee integration pg14 optional: true
- rspec-ee system pg14 - job: rspec:artifact-collector ee remainder
- rspec-ee background_migration pg14 optional: true
script: script:
- run_timed_command "retry gem install fog-aws mime-types activesupport rspec_profiling postgres-copy --no-document" - run_timed_command "retry gem install fog-aws mime-types activesupport rspec_profiling postgres-copy --no-document"
- source ./scripts/rspec_helpers.sh - source ./scripts/rspec_helpers.sh
......
...@@ -72,19 +72,25 @@ function retrieve_frontend_fixtures_mapping() { ...@@ -72,19 +72,25 @@ function retrieve_frontend_fixtures_mapping() {
} }
function update_tests_mapping() { function update_tests_mapping() {
if ! crystalball_rspec_data_exists; then pack_and_gzip_mapping "${RSPEC_TESTS_MAPPING_PATH}" "${RSPEC_PACKED_TESTS_MAPPING_PATH}" crystalball/described/rspec*.yml
echo "No crystalball rspec data found."
return 0
fi
scripts/generate-test-mapping "${RSPEC_TESTS_MAPPING_PATH:-unknown_file}" crystalball/rspec*.yml pack_and_gzip_mapping "${RSPEC_TESTS_MAPPING_ALT_PATH}" "${RSPEC_PACKED_TESTS_MAPPING_ALT_PATH}" crystalball/coverage/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}"
} }
function crystalball_rspec_data_exists() { function pack_and_gzip_mapping() {
compgen -G "crystalball/rspec*.yml" >/dev/null 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() { function retrieve_failed_tests() {
......
...@@ -9,13 +9,16 @@ def start! ...@@ -9,13 +9,16 @@ def start!
return unless ENV['CRYSTALBALL'] == 'true' return unless ENV['CRYSTALBALL'] == 'true'
require 'crystalball' require 'crystalball'
require_relative '../tooling/lib/tooling/crystalball/described_class_execution_detector'
map_storage_path_base = ENV['CI_JOB_NAME'] || 'crystalball_data' enable_described_strategy # We use this for writing and reading
map_storage_path = "crystalball/#{map_storage_path_base.gsub(%r{[/ ]}, '_')}.yml" 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| 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 # https://toptal.github.io/crystalball/map_generators/#describedclassstrategy
described_class_execution_detector = Tooling::Crystalball::DescribedClassExecutionDetector.new( described_class_execution_detector = Tooling::Crystalball::DescribedClassExecutionDetector.new(
...@@ -25,18 +28,30 @@ def start! ...@@ -25,18 +28,30 @@ def start!
config.register Crystalball::MapGenerator::DescribedClassStrategy.new( config.register Crystalball::MapGenerator::DescribedClassStrategy.new(
execution_detector: described_class_execution_detector execution_detector: described_class_execution_detector
) )
end
end
# Modified version of https://toptal.github.io/crystalball/map_generators/#coveragestrategy 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_execution_detector'
# require_relative '../tooling/lib/tooling/crystalball/coverage_lines_strategy' require_relative '../tooling/lib/tooling/crystalball/coverage_lines_strategy'
# execution_detector = Tooling::Crystalball::CoverageLinesExecutionDetector.new(
# exclude_prefixes: EXCLUDED_PREFIXES Crystalball::MapGenerator.start! do |config|
# ) config.map_storage_path = "crystalball/coverage/#{map_storage_name}.yml"
# config.register Tooling::Crystalball::CoverageLinesStrategy.new(execution_detector)
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 # https://toptal.github.io/crystalball/map_generators/#actionviewstrategy
# require 'crystalball/rails/map_generator/action_view_strategy'
# config.register Crystalball::Rails::MapGenerator::ActionViewStrategy.new # config.register Crystalball::Rails::MapGenerator::ActionViewStrategy.new
end end
end end
def map_storage_name
(ENV['CI_JOB_NAME'] || 'crystalball_data').gsub(%r{[/ ]}, '_')
end
end end
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册