Skip to content
Snippets Groups Projects
Verified Commit 6269109c authored by Mark Florian's avatar Mark Florian :two:
Browse files

Run reduced Vue 3 Jest specs in merge requests

Part of #468194.
parent f121f817
No related branches found
No related tags found
2 merge requests!164749Enable parallel in test-on-omnibus,!162483Run reduced Vue 3 Jest specs in merge requests
......@@ -277,7 +277,7 @@ jest-build-cache:
jest-build-cache-vue3:
extends:
- jest-build-cache
- .frontend:rules:jest-vue3-nightly
- .frontend:rules:jest
- .vue3
jest:
......@@ -334,6 +334,42 @@ jest-with-fixtures vue3:
- !reference [.repo-from-artifacts, needs]
- !reference [.with-fixtures-needs, needs]
jest vue3 mr:
extends:
- .frontend-test-base
- .frontend:rules:jest
- .vue3
needs:
- !reference [.with-jest-build-cache-vue3-needs, needs]
artifacts:
name: vue3-mr-junit
expire_in: 31d
when: always
paths:
- junit_jest.xml
parallel: 6
script:
- run_timed_command "yarn jest:ci:vue3-mr:without-fixtures"
allow_failure: true
jest-with-fixtures vue3 mr:
extends:
- jest vue3 mr
- .repo-from-artifacts
needs:
- !reference [.with-jest-build-cache-vue3-needs, needs]
# it's ok to wait for the repo artifact as we're waiting for the fixtures (which wait for the repo artifact) anyway
- !reference [.repo-from-artifacts, needs]
- !reference [.with-fixtures-needs, needs]
artifacts:
name: vue3-mr-junit
expire_in: 31d
when: always
paths:
- junit_jest.xml
script:
- run_timed_command "yarn jest:ci:vue3-mr:with-fixtures"
jest predictive:
extends:
- jest
......@@ -354,6 +390,24 @@ jest-with-fixtures predictive:
script:
- if [[ -s "$RSPEC_CHANGED_FILES_PATH" ]] || [[ -s "$RSPEC_MATCHING_JS_FILES_PATH" ]]; then run_timed_command "yarn jest:ci:predictive-with-fixtures"; fi
jest vue3 predictive:
extends:
- jest vue3 mr
- .frontend:rules:jest:predictive
needs:
- "detect-tests"
script:
- if [[ -s "$RSPEC_CHANGED_FILES_PATH" ]] || [[ -s "$RSPEC_MATCHING_JS_FILES_PATH" ]]; then run_timed_command "yarn jest:ci:vue3-mr:predictive-without-fixtures"; fi
jest-with-fixtures vue3 predictive:
extends:
- jest-with-fixtures vue3 mr
- .frontend:rules:jest:predictive
needs:
- "detect-tests"
script:
- if [[ -s "$RSPEC_CHANGED_FILES_PATH" ]] || [[ -s "$RSPEC_MATCHING_JS_FILES_PATH" ]]; then run_timed_command "yarn jest:ci:vue3-mr:predictive-with-fixtures"; fi
jest-integration:
extends:
- .frontend-test-base
......
......@@ -21,6 +21,10 @@
"jest:ci:with-fixtures": "JEST_FIXTURE_JOBS_ONLY=1 jest --config jest.config.js --ci --coverage --testSequencer ./scripts/frontend/fixture_ci_sequencer.js --shard \"${CI_NODE_INDEX:-1}/${CI_NODE_TOTAL:-1}\" --logHeapUsage",
"jest:ci:predictive-without-fixtures": "jest --config jest.config.js --ci --coverage --findRelatedTests $(cat $RSPEC_CHANGED_FILES_PATH) $(cat $RSPEC_MATCHING_JS_FILES_PATH) --passWithNoTests --testSequencer ./scripts/frontend/fixture_ci_sequencer.js --shard \"${CI_NODE_INDEX:-1}/${CI_NODE_TOTAL:-1}\" --logHeapUsage",
"jest:ci:predictive-with-fixtures": "JEST_FIXTURE_JOBS_ONLY=1 jest --config jest.config.js --ci --coverage --findRelatedTests $(cat $RSPEC_CHANGED_FILES_PATH) $(cat $RSPEC_MATCHING_JS_FILES_PATH) --passWithNoTests --testSequencer ./scripts/frontend/fixture_ci_sequencer.js --shard \"${CI_NODE_INDEX:-1}/${CI_NODE_TOTAL:-1}\" --logHeapUsage",
"jest:ci:vue3-mr:without-fixtures": "jest --config jest.config.js --ci --testSequencer ./scripts/frontend/skip_specs_broken_in_vue_compat_fixture_ci_sequencer.js --shard \"${CI_NODE_INDEX:-1}/${CI_NODE_TOTAL:-1}\" --logHeapUsage",
"jest:ci:vue3-mr:with-fixtures": "JEST_FIXTURE_JOBS_ONLY=1 jest --config jest.config.js --ci --testSequencer ./scripts/frontend/skip_specs_broken_in_vue_compat_fixture_ci_sequencer.js --shard \"${CI_NODE_INDEX:-1}/${CI_NODE_TOTAL:-1}\" --logHeapUsage",
"jest:ci:vue3-mr:predictive-without-fixtures": "jest --config jest.config.js --ci --findRelatedTests $(cat $RSPEC_CHANGED_FILES_PATH) $(cat $RSPEC_MATCHING_JS_FILES_PATH) --passWithNoTests --testSequencer ./scripts/frontend/skip_specs_broken_in_vue_compat_fixture_ci_sequencer.js --shard \"${CI_NODE_INDEX:-1}/${CI_NODE_TOTAL:-1}\" --logHeapUsage",
"jest:ci:vue3-mr:predictive-with-fixtures": "JEST_FIXTURE_JOBS_ONLY=1 jest --config jest.config.js --ci --findRelatedTests $(cat $RSPEC_CHANGED_FILES_PATH) $(cat $RSPEC_MATCHING_JS_FILES_PATH) --passWithNoTests --testSequencer ./scripts/frontend/skip_specs_broken_in_vue_compat_fixture_ci_sequencer.js --shard \"${CI_NODE_INDEX:-1}/${CI_NODE_TOTAL:-1}\" --logHeapUsage",
"jest:contract": "PACT_DO_NOT_TRACK=true jest --config jest.config.contract.js --runInBand",
"jest:integration": "jest --config jest.config.integration.js",
"jest:scripts": "jest --config jest.config.scripts.js",
......
const { relative } = require('node:path');
const { setTimeout: setTimeoutPromise } = require('node:timers/promises');
const axios = require('axios');
const FixtureCISequencer = require('./fixture_ci_sequencer');
const url = 'https://gitlab-org.gitlab.io/frontend/playground/jest-speed-reporter/vue3.json';
async function getFailedFilesAsAbsolutePaths(n = 0, maxRetries = 3) {
try {
const { data } = await axios.get(url, { timeout: 10_000 });
return new Set(data.failedFiles);
} catch (error) {
console.error('\nFailed to fetch list of specs failing with @vue/compat: %s', error.message);
if (n < maxRetries) {
const waitMs = 5_000 * 2 ** n;
console.error(`Waiting ${waitMs}ms to retry (${maxRetries - n} remaining)`);
await setTimeoutPromise(waitMs);
return getFailedFilesAsAbsolutePaths(n + 1);
}
throw error;
}
}
class SkipSpecsBrokenInVueCompatFixtureCISequencer extends FixtureCISequencer {
#failedSpecFilesPromise = getFailedFilesAsAbsolutePaths();
async shard(tests, options) {
const failedSpecFiles = await this.#failedSpecFilesPromise;
const testsExcludingOnesThatFailInVueCompat = tests.filter(
(test) => !failedSpecFiles.has(relative(test.context.config.rootDir, test.path)),
);
return super.shard(testsExcludingOnesThatFailInVueCompat, options);
}
}
module.exports = SkipSpecsBrokenInVueCompatFixtureCISequencer;
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