Switched Web IDE to local schema for CI config

What does this MR do and why?

There are issues with fetching the CI config schema from a remote. Especially for the self-hosted instances. In ab875500 the schema from the schemastore has been copied over to GitLab to be hosted as an asset locally. The pipeline editor has been updated to use it since %14.4 behind the feature flag. Web IDE, on another hand, was continuing using the remote one, hosted on the schemastore.

This MR unifies the CI linting capabilities by switching Web IDE to use the local schema instead of the remotely hosted one. The MR does protect the change with the same feature flag as the Pipeline Editor (:schema_linting). The flag is globally enabled on gitlab.com for several milestones, and the lining has been working perfect in the Pipeline Editor. In case the flag is disabled, Web IDE will go on and fetch the CI linting schema conventionally from schemastore. To visually describe the conditions, introduced in this MR, here's the flowchart for your convenience:

flowchart TB

  id1{is .gitlab-ci.yml file?}
  id2{is flag ON?}
  id3{is the extension installed?}
  id31{is the extension installed?}

  id4[register external schema]
  id5[register local schema]
  id6[unuse the extension]
  id7[use local extension]
  id8[fetch, store and use extension]

  id1-->|No|id3
  id3-->|No|id4
  id3-->|Yes|id6
  id1-->|Yes|id2
  id2-->|No|id4
  id2-->|Yes|id5
  id6-->id4
  id5-->id31
  id31-->|Yes|id7
  id31-->|NO|id8

The feature flag's roll-out issue is a wip and the flag will be enabled by default (incl. the self-hosted instances) in %15.7.

Screenshots or screen recordings

Some things to note in the screenshots below:

  • the Pipeline Editor's state is identical before this MR and after and is affected only with the feature flag
  • Web IDE Before (flag ON) and After (flag OFF) states are identical to Before (flag OFF) - in all these cases, Web IDE will reach out to schemastore
  • The only change in the set of After states compared to Before is the Web IDE's After (flag ON) - that's where we reach out to the locally hosted schema
Web IDE Pipeline Editor
Before (flag OFF) Screenshot_2022-11-22_at_09.41.18 Screenshot_2022-11-22_at_09.38.46
Before (flag ON) Screenshot_2022-11-22_at_09.41.18
Identical to Before (flag OFF)
Screenshot_2022-11-22_at_09.37.34
After (flag OFF) Screenshot_2022-11-22_at_09.41.18
Identical to Before (flag OFF)
Screenshot_2022-11-22_at_09.38.46
Identical to Before (flag OFF)
After (flag ON) Screenshot_2022-11-22_at_09.33.27 Screenshot_2022-11-22_at_09.37.34
Identical to Before (flag ON)

How to set up and validate locally

  1. Locally, in a project containing .gitlab-ci.yml file, go to Web IDE and open the file
  2. In the DevTools, note the unsuccessful request (422 response) to .gitlab-ci.yml worker and the interlining of the very first character in the editor. Hovering over it will show an error (see the screenshot above)
  3. In the terminal, go to the Rails console rails c
  4. Enable the :schema_linting flag: Feature.enable(:schema_linting)
  5. Reload the browser (it might take some hard reload as it might take some time for the feature flag changes to be available in the browser). Note that the unsuccessful worker request has been replaced with a successful request to ci.SOME_HASH.json file.
  6. The error and underlining on the first character in the editor should also be gone

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #371600 (closed)

Edited by Denys Mishunov

Merge request reports

Loading