Commit aaae2223 authored by Frédéric Caplette's avatar Frédéric Caplette Committed by Mark Florian

Remove workers workaround in Pipeline Editor

This fixes a problem for GitLab instances set to use a CDN, via the
`GITLAB_CDN_HOST` environment variable. They were unable to fetch the CI
schema as the path ended up being a concatentation of two absolute URLs.

If the schema path is absolute, it's used as-is. Otherwise, it's made
absolute using the GitLab instance as the base.
parent bdfce550
......@@ -14,7 +14,7 @@ export class CiSchemaExtension {
// to fetch schema files, hence the `gon.gitlab_url`
// reference. This prevents error:
// "Failed to execute 'fetch' on 'WorkerGlobalScope'"
const absoluteSchemaUrl = gon.gitlab_url + ciSchemaPath;
const absoluteSchemaUrl = new URL(ciSchemaPath, gon.gitlab_url).href;
const modelFileName = instance.getModel().uri.path.split('/').pop();
registerSchema({
......
......@@ -2,7 +2,6 @@ import Vue from 'vue';
import VueApollo from 'vue-apollo';
import createDefaultClient from '~/lib/graphql';
import { resetServiceWorkersPublicPath } from '../lib/utils/webpack';
import { EDITOR_APP_STATUS_LOADING } from './constants';
import { CODE_SNIPPET_SOURCE_SETTINGS } from './components/code_snippet_alert/constants';
import getCurrentBranch from './graphql/queries/client/current_branch.query.graphql';
......@@ -14,11 +13,6 @@ import typeDefs from './graphql/typedefs.graphql';
import PipelineEditorApp from './pipeline_editor_app.vue';
export const initPipelineEditor = (selector = '#js-pipeline-editor') => {
// Prevent issues loading syntax validation workers
// Fixes https://gitlab.com/gitlab-org/gitlab/-/issues/297252
// TODO Remove when https://gitlab.com/gitlab-org/gitlab/-/issues/321656 is resolved
resetServiceWorkersPublicPath();
const el = document.querySelector(selector);
if (!el) {
......
......@@ -4,10 +4,14 @@ import { CiSchemaExtension } from '~/editor/extensions/source_editor_ci_schema_e
import ciSchemaPath from '~/editor/schema/ci.json';
import SourceEditor from '~/editor/source_editor';
// Webpack is configured to use file-loader for the CI schema; mimic that here
jest.mock('~/editor/schema/ci.json', () => '/assets/ci.json');
const mockRef = 'AABBCCDD';
describe('~/editor/editor_ci_config_ext', () => {
const defaultBlobPath = '.gitlab-ci.yml';
const expectedSchemaUri = `${TEST_HOST}${ciSchemaPath}`;
let editor;
let instance;
......@@ -84,14 +88,13 @@ describe('~/editor/editor_ci_config_ext', () => {
});
expect(getConfiguredYmlSchema()).toEqual({
uri: `${TEST_HOST}${ciSchemaPath}`,
uri: expectedSchemaUri,
fileMatch: [defaultBlobPath],
});
});
it('with an alternative file name match', () => {
createMockEditor({ blobPath: 'dir1/dir2/another-ci-filename.yml' });
instance.registerCiSchema({
projectNamespace: mockProjectNamespace,
projectPath: mockProjectPath,
......@@ -99,7 +102,7 @@ describe('~/editor/editor_ci_config_ext', () => {
});
expect(getConfiguredYmlSchema()).toEqual({
uri: `${TEST_HOST}${ciSchemaPath}`,
uri: expectedSchemaUri,
fileMatch: ['another-ci-filename.yml'],
});
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment