Skip to content
Snippets Groups Projects
Verified Commit aa52ebc6 authored by Andrew Fontaine's avatar Andrew Fontaine Committed by GitLab
Browse files

Merge branch 'update-vue3-quarantine-list' into 'master'

Remove non-existent specs from Vue 3 quarantine

See merge request !173756



Merged-by: Andrew Fontaine's avatarAndrew Fontaine <afontaine@gitlab.com>
Approved-by: Andrew Fontaine's avatarAndrew Fontaine <afontaine@gitlab.com>
Reviewed-by: Andrew Fontaine's avatarAndrew Fontaine <afontaine@gitlab.com>
Reviewed-by: Mark Florian's avatarMark Florian <mflorian@gitlab.com>
Co-authored-by: Mark Florian's avatarMark Florian <mflorian@gitlab.com>
parents 9efc32df a790e0a5
No related branches found
No related tags found
1 merge request!173756Remove non-existent specs from Vue 3 quarantine
Pipeline #1563270320 passed
const { spawnSync } = require('node:child_process');
const { readFile, open } = require('node:fs/promises');
const { readFile, open, stat } = require('node:fs/promises');
const parser = require('fast-xml-parser');
const defaultChalk = require('chalk');
const { getLocalQuarantinedFiles } = require('./jest_vue3_quarantine_utils');
......@@ -7,6 +7,9 @@ const { getLocalQuarantinedFiles } = require('./jest_vue3_quarantine_utils');
// Always use basic color output
const chalk = new defaultChalk.constructor({ level: 1 });
let quarantinedFiles;
let filesThatChanged;
async function parseJUnitReport() {
let junit;
try {
......@@ -21,7 +24,7 @@ async function parseJUnitReport() {
console.warn(e);
// No JUnit report exists, or there was a parsing error. Either way, we
// should not block the MR.
return { passed: [], total: 0 };
return [];
}
const failuresByFile = new Map();
......@@ -41,32 +44,28 @@ async function parseJUnitReport() {
}
}
const quarantinedFiles = new Set(await getLocalQuarantinedFiles());
const passed = [];
for (const [file, failures] of failuresByFile.entries()) {
if (failures === 0 && quarantinedFiles.has(file)) passed.push(file);
}
return {
passed,
total: failuresByFile.size,
};
return passed;
}
function reportPassingSpecsShouldBeUnquarantined(passed) {
function reportSpecsShouldBeUnquarantined(files) {
const docsLink =
// eslint-disable-next-line no-restricted-syntax
'https://docs.gitlab.com/ee/development/testing_guide/testing_vue3.html#quarantine-list';
console.warn(' ');
console.warn(
`The following ${passed.length} spec file(s) now pass(es) under Vue 3, and so must be removed from quarantine:`,
`The following ${files.length} spec files either now pass under Vue 3, or no longer exist, and so must be removed from quarantine:`,
);
console.warn(' ');
console.warn(passed.join('\n'));
console.warn(files.join('\n'));
console.warn(' ');
console.warn(
chalk.red(
`To fix this job, remove the file(s) listed above from the file ${chalk.underline('scripts/frontend/quarantined_vue3_specs.txt')}.`,
`To fix this job, remove the files listed above from the file ${chalk.underline('scripts/frontend/quarantined_vue3_specs.txt')}.`,
),
);
console.warn(`For more information, please see ${docsLink}.`);
......@@ -84,8 +83,34 @@ async function changedFiles() {
return files.flat();
}
function intersection(a, b) {
const result = new Set();
for (const element of a) {
if (b.has(element)) result.add(element);
}
return result;
}
async function getRemovedQuarantinedSpecs() {
const removedQuarantinedSpecs = [];
for (const file of intersection(filesThatChanged, quarantinedFiles)) {
try {
// eslint-disable-next-line no-await-in-loop
await stat(file);
} catch (e) {
if (e.code === 'ENOENT') removedQuarantinedSpecs.push(file);
}
}
return removedQuarantinedSpecs;
}
async function main() {
const filesThatChanged = await changedFiles();
filesThatChanged = await changedFiles();
quarantinedFiles = new Set(await getLocalQuarantinedFiles());
const jestStdout = (await open('jest_stdout', 'w')).createWriteStream();
const jestStderr = (await open('jest_stderr', 'w')).createWriteStream();
......@@ -126,18 +151,18 @@ async function main() {
},
);
const { passed, total } = await parseJUnitReport();
const passed = await parseJUnitReport();
const removedQuarantinedSpecs = await getRemovedQuarantinedSpecs();
const filesToReport = [...passed, ...removedQuarantinedSpecs];
if (total.length === 0) {
if (filesToReport.length === 0) {
// No tests ran, or there was some unexpected error. Either way, exit
// successfully.
return;
}
if (passed.length > 0) {
process.exitCode = 1;
reportPassingSpecsShouldBeUnquarantined(passed);
}
process.exitCode = 1;
reportSpecsShouldBeUnquarantined(filesToReport);
}
main().catch((e) => {
......
......@@ -13,7 +13,6 @@ ee/spec/frontend/analytics/analytics_dashboards/components/analytics_dashboards_
ee/spec/frontend/analytics/analytics_dashboards/components/analytics_data_explorer_spec.js
ee/spec/frontend/analytics/analytics_dashboards/components/list/feature_list_item_spec.js
ee/spec/frontend/analytics/cycle_analytics/components/value_stream_aggregation_status_spec.js
ee/spec/frontend/analytics/cycle_analytics/components/value_stream_form_content_spec.js
ee/spec/frontend/analytics/cycle_analytics/vsa_settings/components/value_stream_form_content_spec.js
ee/spec/frontend/analytics/dashboards/ai_impact/components/metric_table_spec.js
ee/spec/frontend/analytics/devops_reports/devops_adoption/components/devops_adoption_app_spec.js
......@@ -46,7 +45,6 @@ ee/spec/frontend/clusters/components/environments_spec.js
ee/spec/frontend/compliance_dashboard/components/frameworks_report/edit_framework/components/policies_section_spec.js
ee/spec/frontend/compliance_dashboard/components/frameworks_report/report_spec.js
ee/spec/frontend/compliance_dashboard/components/standards_adherence_report/base_table_spec.js
ee/spec/frontend/contextual_sidebar/components/trial_status_widget_spec.js
ee/spec/frontend/dependencies/components/app_spec.js
ee/spec/frontend/dependencies/components/dependency_location_spec.js
ee/spec/frontend/dependencies/components/dependency_path_viewer_spec.js
......@@ -171,7 +169,6 @@ spec/frontend/ci/pipeline_editor/components/job_assistant_drawer/accordion_items
spec/frontend/ci/pipeline_editor/components/lint/ci_lint_warnings_spec.js
spec/frontend/ci/pipeline_editor/components/pipeline_editor_tabs_spec.js
spec/frontend/ci/pipeline_editor/pipeline_editor_app_spec.js
spec/frontend/ci/pipeline_mini_graph/legacy_pipeline_mini_graph/legacy_pipeline_stage_spec.js
spec/frontend/ci/pipeline_mini_graph/pipeline_mini_graph_spec.js
spec/frontend/ci/pipelines_page/components/pipeline_multi_actions_spec.js
spec/frontend/ci/pipelines_page/components/pipelines_artifacts_spec.js
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment