summaryrefslogtreecommitdiff
path: root/spec/frontend/editor
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/editor')
-rw-r--r--spec/frontend/editor/components/helpers.js12
-rw-r--r--spec/frontend/editor/components/source_editor_toolbar_button_spec.js146
-rw-r--r--spec/frontend/editor/components/source_editor_toolbar_spec.js116
-rw-r--r--spec/frontend/editor/schema/ci/ci_schema_spec.js90
-rw-r--r--spec/frontend/editor/schema/ci/json_tests/negative_tests/default_no_additional_properties.json12
-rw-r--r--spec/frontend/editor/schema/ci/json_tests/negative_tests/inherit_default_no_additional_properties.json8
-rw-r--r--spec/frontend/editor/schema/ci/json_tests/negative_tests/job_variables_must_not_contain_objects.json12
-rw-r--r--spec/frontend/editor/schema/ci/json_tests/negative_tests/release_assets_links_empty.json13
-rw-r--r--spec/frontend/editor/schema/ci/json_tests/negative_tests/release_assets_links_invalid_link_type.json24
-rw-r--r--spec/frontend/editor/schema/ci/json_tests/negative_tests/release_assets_links_missing.json11
-rw-r--r--spec/frontend/editor/schema/ci/json_tests/negative_tests/retry_unknown_when.json9
-rw-r--r--spec/frontend/editor/schema/ci/json_tests/positive_tests/allow_failure.json19
-rw-r--r--spec/frontend/editor/schema/ci/json_tests/positive_tests/environment.json75
-rw-r--r--spec/frontend/editor/schema/ci/json_tests/positive_tests/gitlab-ci-dependencies.json68
-rw-r--r--spec/frontend/editor/schema/ci/json_tests/positive_tests/gitlab-ci.json350
-rw-r--r--spec/frontend/editor/schema/ci/json_tests/positive_tests/inherit.json54
-rw-r--r--spec/frontend/editor/schema/ci/json_tests/positive_tests/multiple-caches.json24
-rw-r--r--spec/frontend/editor/schema/ci/json_tests/positive_tests/retry.json60
-rw-r--r--spec/frontend/editor/schema/ci/json_tests/positive_tests/terraform_report.json50
-rw-r--r--spec/frontend/editor/schema/ci/json_tests/positive_tests/variables.json22
-rw-r--r--spec/frontend/editor/schema/ci/json_tests/positive_tests/variables_mix_string_and_user_input.json10
-rw-r--r--spec/frontend/editor/schema/ci/yaml_tests/negative_tests/cache.yml15
-rw-r--r--spec/frontend/editor/schema/ci/yaml_tests/negative_tests/include.yml17
-rw-r--r--spec/frontend/editor/schema/ci/yaml_tests/positive_tests/cache.yml25
-rw-r--r--spec/frontend/editor/schema/ci/yaml_tests/positive_tests/filter.yml18
-rw-r--r--spec/frontend/editor/schema/ci/yaml_tests/positive_tests/include.yml32
-rw-r--r--spec/frontend/editor/schema/ci/yaml_tests/positive_tests/rules.yml13
27 files changed, 1305 insertions, 0 deletions
diff --git a/spec/frontend/editor/components/helpers.js b/spec/frontend/editor/components/helpers.js
new file mode 100644
index 00000000000..3e6cd2a236d
--- /dev/null
+++ b/spec/frontend/editor/components/helpers.js
@@ -0,0 +1,12 @@
+import { EDITOR_TOOLBAR_RIGHT_GROUP } from '~/editor/constants';
+
+export const buildButton = (id = 'foo-bar-btn', options = {}) => {
+ return {
+ __typename: 'Item',
+ id,
+ label: options.label || 'Foo Bar Button',
+ icon: options.icon || 'foo-bar',
+ selected: options.selected || false,
+ group: options.group || EDITOR_TOOLBAR_RIGHT_GROUP,
+ };
+};
diff --git a/spec/frontend/editor/components/source_editor_toolbar_button_spec.js b/spec/frontend/editor/components/source_editor_toolbar_button_spec.js
new file mode 100644
index 00000000000..5135091af4a
--- /dev/null
+++ b/spec/frontend/editor/components/source_editor_toolbar_button_spec.js
@@ -0,0 +1,146 @@
+import Vue, { nextTick } from 'vue';
+import VueApollo from 'vue-apollo';
+import { GlButton } from '@gitlab/ui';
+import { shallowMount } from '@vue/test-utils';
+import createMockApollo from 'helpers/mock_apollo_helper';
+import SourceEditorToolbarButton from '~/editor/components/source_editor_toolbar_button.vue';
+import getToolbarItemQuery from '~/editor/graphql/get_item.query.graphql';
+import updateToolbarItemMutation from '~/editor/graphql/update_item.mutation.graphql';
+import { buildButton } from './helpers';
+
+Vue.use(VueApollo);
+
+describe('Source Editor Toolbar button', () => {
+ let wrapper;
+ let mockApollo;
+ const defaultBtn = buildButton();
+
+ const findButton = () => wrapper.findComponent(GlButton);
+
+ const createComponentWithApollo = ({ propsData } = {}) => {
+ mockApollo = createMockApollo();
+ mockApollo.clients.defaultClient.cache.writeQuery({
+ query: getToolbarItemQuery,
+ variables: { id: defaultBtn.id },
+ data: {
+ item: {
+ ...defaultBtn,
+ },
+ },
+ });
+
+ wrapper = shallowMount(SourceEditorToolbarButton, {
+ propsData,
+ apolloProvider: mockApollo,
+ });
+ };
+
+ afterEach(() => {
+ wrapper.destroy();
+ mockApollo = null;
+ });
+
+ describe('default', () => {
+ const defaultProps = {
+ category: 'primary',
+ variant: 'default',
+ };
+ const customProps = {
+ category: 'secondary',
+ variant: 'info',
+ };
+ it('renders a default button without props', async () => {
+ createComponentWithApollo();
+ const btn = findButton();
+ expect(btn.exists()).toBe(true);
+ expect(btn.props()).toMatchObject(defaultProps);
+ });
+
+ it('renders a button based on the props passed', async () => {
+ createComponentWithApollo({
+ propsData: {
+ button: customProps,
+ },
+ });
+ const btn = findButton();
+ expect(btn.props()).toMatchObject(customProps);
+ });
+ });
+
+ describe('button updates', () => {
+ it('it properly updates button on Apollo cache update', async () => {
+ const { id } = defaultBtn;
+
+ createComponentWithApollo({
+ propsData: {
+ button: {
+ id,
+ },
+ },
+ });
+
+ expect(findButton().props('selected')).toBe(false);
+
+ mockApollo.clients.defaultClient.cache.writeQuery({
+ query: getToolbarItemQuery,
+ variables: { id },
+ data: {
+ item: {
+ ...defaultBtn,
+ selected: true,
+ },
+ },
+ });
+
+ jest.runOnlyPendingTimers();
+ await nextTick();
+
+ expect(findButton().props('selected')).toBe(true);
+ });
+ });
+
+ describe('click handler', () => {
+ it('fires the click handler on the button when available', () => {
+ const spy = jest.fn();
+ createComponentWithApollo({
+ propsData: {
+ button: {
+ onClick: spy,
+ },
+ },
+ });
+ expect(spy).not.toHaveBeenCalled();
+ findButton().vm.$emit('click');
+ expect(spy).toHaveBeenCalled();
+ });
+ it('emits the "click" event', () => {
+ createComponentWithApollo();
+ jest.spyOn(wrapper.vm, '$emit');
+ expect(wrapper.vm.$emit).not.toHaveBeenCalled();
+ findButton().vm.$emit('click');
+ expect(wrapper.vm.$emit).toHaveBeenCalledWith('click');
+ });
+ it('triggers the mutation exposing the changed "selected" prop', () => {
+ const { id } = defaultBtn;
+ createComponentWithApollo({
+ propsData: {
+ button: {
+ id,
+ },
+ },
+ });
+ jest.spyOn(wrapper.vm.$apollo, 'mutate');
+ expect(wrapper.vm.$apollo.mutate).not.toHaveBeenCalled();
+ findButton().vm.$emit('click');
+ expect(wrapper.vm.$apollo.mutate).toHaveBeenCalledWith({
+ mutation: updateToolbarItemMutation,
+ variables: {
+ id,
+ propsToUpdate: {
+ selected: true,
+ },
+ },
+ });
+ });
+ });
+});
diff --git a/spec/frontend/editor/components/source_editor_toolbar_spec.js b/spec/frontend/editor/components/source_editor_toolbar_spec.js
new file mode 100644
index 00000000000..6e99eadbd97
--- /dev/null
+++ b/spec/frontend/editor/components/source_editor_toolbar_spec.js
@@ -0,0 +1,116 @@
+import Vue, { nextTick } from 'vue';
+import VueApollo from 'vue-apollo';
+import { GlButtonGroup } from '@gitlab/ui';
+import { shallowMount } from '@vue/test-utils';
+import createMockApollo from 'helpers/mock_apollo_helper';
+import SourceEditorToolbar from '~/editor/components/source_editor_toolbar.vue';
+import SourceEditorToolbarButton from '~/editor/components/source_editor_toolbar_button.vue';
+import { EDITOR_TOOLBAR_LEFT_GROUP, EDITOR_TOOLBAR_RIGHT_GROUP } from '~/editor/constants';
+import getToolbarItemsQuery from '~/editor/graphql/get_items.query.graphql';
+import { buildButton } from './helpers';
+
+Vue.use(VueApollo);
+
+describe('Source Editor Toolbar', () => {
+ let wrapper;
+ let mockApollo;
+
+ const findButtons = () => wrapper.findAllComponents(SourceEditorToolbarButton);
+
+ const createApolloMockWithCache = (items = []) => {
+ mockApollo = createMockApollo();
+ mockApollo.clients.defaultClient.cache.writeQuery({
+ query: getToolbarItemsQuery,
+ data: {
+ items: {
+ nodes: items,
+ },
+ },
+ });
+ };
+
+ const createComponentWithApollo = (items = []) => {
+ createApolloMockWithCache(items);
+ wrapper = shallowMount(SourceEditorToolbar, {
+ apolloProvider: mockApollo,
+ stubs: {
+ GlButtonGroup,
+ },
+ });
+ };
+
+ afterEach(() => {
+ wrapper.destroy();
+ mockApollo = null;
+ });
+
+ describe('groups', () => {
+ it.each`
+ group | expectedGroup
+ ${EDITOR_TOOLBAR_LEFT_GROUP} | ${EDITOR_TOOLBAR_LEFT_GROUP}
+ ${EDITOR_TOOLBAR_RIGHT_GROUP} | ${EDITOR_TOOLBAR_RIGHT_GROUP}
+ ${undefined} | ${EDITOR_TOOLBAR_RIGHT_GROUP}
+ ${'non-existing'} | ${EDITOR_TOOLBAR_RIGHT_GROUP}
+ `('puts item with group="$group" into $expectedGroup group', ({ group, expectedGroup }) => {
+ const item = buildButton('first', {
+ group,
+ });
+ createComponentWithApollo([item]);
+ expect(findButtons()).toHaveLength(1);
+ [EDITOR_TOOLBAR_RIGHT_GROUP, EDITOR_TOOLBAR_LEFT_GROUP].forEach((g) => {
+ if (g === expectedGroup) {
+ expect(wrapper.vm.getGroupItems(g)).toEqual([expect.objectContaining({ id: 'first' })]);
+ } else {
+ expect(wrapper.vm.getGroupItems(g)).toHaveLength(0);
+ }
+ });
+ });
+ });
+
+ describe('buttons update', () => {
+ it('it properly updates buttons on Apollo cache update', async () => {
+ const item = buildButton('first', {
+ group: EDITOR_TOOLBAR_RIGHT_GROUP,
+ });
+ createComponentWithApollo();
+
+ expect(findButtons()).toHaveLength(0);
+
+ mockApollo.clients.defaultClient.cache.writeQuery({
+ query: getToolbarItemsQuery,
+ data: {
+ items: {
+ nodes: [item],
+ },
+ },
+ });
+
+ jest.runOnlyPendingTimers();
+ await nextTick();
+
+ expect(findButtons()).toHaveLength(1);
+ });
+ });
+
+ describe('click handler', () => {
+ it('emits the "click" event when a button is clicked', () => {
+ const item1 = buildButton('first', {
+ group: EDITOR_TOOLBAR_LEFT_GROUP,
+ });
+ const item2 = buildButton('second', {
+ group: EDITOR_TOOLBAR_RIGHT_GROUP,
+ });
+ createComponentWithApollo([item1, item2]);
+ jest.spyOn(wrapper.vm, '$emit');
+ expect(wrapper.vm.$emit).not.toHaveBeenCalled();
+
+ findButtons().at(0).vm.$emit('click');
+ expect(wrapper.vm.$emit).toHaveBeenCalledWith('click', item1);
+
+ findButtons().at(1).vm.$emit('click');
+ expect(wrapper.vm.$emit).toHaveBeenCalledWith('click', item2);
+
+ expect(wrapper.vm.$emit.mock.calls).toHaveLength(2);
+ });
+ });
+});
diff --git a/spec/frontend/editor/schema/ci/ci_schema_spec.js b/spec/frontend/editor/schema/ci/ci_schema_spec.js
new file mode 100644
index 00000000000..628c34a27c1
--- /dev/null
+++ b/spec/frontend/editor/schema/ci/ci_schema_spec.js
@@ -0,0 +1,90 @@
+import Ajv from 'ajv';
+import AjvFormats from 'ajv-formats';
+import CiSchema from '~/editor/schema/ci.json';
+
+// JSON POSITIVE TESTS
+import AllowFailureJson from './json_tests/positive_tests/allow_failure.json';
+import EnvironmentJson from './json_tests/positive_tests/environment.json';
+import GitlabCiDependenciesJson from './json_tests/positive_tests/gitlab-ci-dependencies.json';
+import GitlabCiJson from './json_tests/positive_tests/gitlab-ci.json';
+import InheritJson from './json_tests/positive_tests/inherit.json';
+import MultipleCachesJson from './json_tests/positive_tests/multiple-caches.json';
+import RetryJson from './json_tests/positive_tests/retry.json';
+import TerraformReportJson from './json_tests/positive_tests/terraform_report.json';
+import VariablesMixStringAndUserInputJson from './json_tests/positive_tests/variables_mix_string_and_user_input.json';
+import VariablesJson from './json_tests/positive_tests/variables.json';
+
+// JSON NEGATIVE TESTS
+import DefaultNoAdditionalPropertiesJson from './json_tests/negative_tests/default_no_additional_properties.json';
+import InheritDefaultNoAdditionalPropertiesJson from './json_tests/negative_tests/inherit_default_no_additional_properties.json';
+import JobVariablesMustNotContainObjectsJson from './json_tests/negative_tests/job_variables_must_not_contain_objects.json';
+import ReleaseAssetsLinksEmptyJson from './json_tests/negative_tests/release_assets_links_empty.json';
+import ReleaseAssetsLinksInvalidLinkTypeJson from './json_tests/negative_tests/release_assets_links_invalid_link_type.json';
+import ReleaseAssetsLinksMissingJson from './json_tests/negative_tests/release_assets_links_missing.json';
+import RetryUnknownWhenJson from './json_tests/negative_tests/retry_unknown_when.json';
+
+// YAML POSITIVE TEST
+import CacheYaml from './yaml_tests/positive_tests/cache.yml';
+import FilterYaml from './yaml_tests/positive_tests/filter.yml';
+import IncludeYaml from './yaml_tests/positive_tests/include.yml';
+import RulesYaml from './yaml_tests/positive_tests/rules.yml';
+
+// YAML NEGATIVE TEST
+import CacheNegativeYaml from './yaml_tests/negative_tests/cache.yml';
+import IncludeNegativeYaml from './yaml_tests/negative_tests/include.yml';
+
+const ajv = new Ajv({
+ strictTypes: false,
+ strictTuples: false,
+ allowMatchingProperties: true,
+});
+
+AjvFormats(ajv);
+const schema = ajv.compile(CiSchema);
+
+describe('positive tests', () => {
+ it.each(
+ Object.entries({
+ // JSON
+ AllowFailureJson,
+ EnvironmentJson,
+ GitlabCiDependenciesJson,
+ GitlabCiJson,
+ InheritJson,
+ MultipleCachesJson,
+ RetryJson,
+ TerraformReportJson,
+ VariablesMixStringAndUserInputJson,
+ VariablesJson,
+
+ // YAML
+ CacheYaml,
+ FilterYaml,
+ IncludeYaml,
+ RulesYaml,
+ }),
+ )('schema validates %s', (_, input) => {
+ expect(input).toValidateJsonSchema(schema);
+ });
+});
+
+describe('negative tests', () => {
+ it.each(
+ Object.entries({
+ // JSON
+ DefaultNoAdditionalPropertiesJson,
+ JobVariablesMustNotContainObjectsJson,
+ InheritDefaultNoAdditionalPropertiesJson,
+ ReleaseAssetsLinksEmptyJson,
+ ReleaseAssetsLinksInvalidLinkTypeJson,
+ ReleaseAssetsLinksMissingJson,
+ RetryUnknownWhenJson,
+
+ // YAML
+ CacheNegativeYaml,
+ IncludeNegativeYaml,
+ }),
+ )('schema validates %s', (_, input) => {
+ expect(input).not.toValidateJsonSchema(schema);
+ });
+});
diff --git a/spec/frontend/editor/schema/ci/json_tests/negative_tests/default_no_additional_properties.json b/spec/frontend/editor/schema/ci/json_tests/negative_tests/default_no_additional_properties.json
new file mode 100644
index 00000000000..955c19ef1ab
--- /dev/null
+++ b/spec/frontend/editor/schema/ci/json_tests/negative_tests/default_no_additional_properties.json
@@ -0,0 +1,12 @@
+{
+ "default": {
+ "secrets": {
+ "DATABASE_PASSWORD": {
+ "vault": "production/db/password"
+ }
+ },
+ "environment": {
+ "name": "test"
+ }
+ }
+}
diff --git a/spec/frontend/editor/schema/ci/json_tests/negative_tests/inherit_default_no_additional_properties.json b/spec/frontend/editor/schema/ci/json_tests/negative_tests/inherit_default_no_additional_properties.json
new file mode 100644
index 00000000000..7411e4c2434
--- /dev/null
+++ b/spec/frontend/editor/schema/ci/json_tests/negative_tests/inherit_default_no_additional_properties.json
@@ -0,0 +1,8 @@
+{
+ "karma": {
+ "inherit": {
+ "default": ["secrets"]
+ },
+ "script": "karma"
+ }
+}
diff --git a/spec/frontend/editor/schema/ci/json_tests/negative_tests/job_variables_must_not_contain_objects.json b/spec/frontend/editor/schema/ci/json_tests/negative_tests/job_variables_must_not_contain_objects.json
new file mode 100644
index 00000000000..bfdbf26ee70
--- /dev/null
+++ b/spec/frontend/editor/schema/ci/json_tests/negative_tests/job_variables_must_not_contain_objects.json
@@ -0,0 +1,12 @@
+{
+ "gitlab-ci-variables-object": {
+ "stage": "test",
+ "script": ["true"],
+ "variables": {
+ "DEPLOY_ENVIRONMENT": {
+ "value": "staging",
+ "description": "The deployment target. Change this variable to 'canary' or 'production' if needed."
+ }
+ }
+ }
+}
diff --git a/spec/frontend/editor/schema/ci/json_tests/negative_tests/release_assets_links_empty.json b/spec/frontend/editor/schema/ci/json_tests/negative_tests/release_assets_links_empty.json
new file mode 100644
index 00000000000..84a1aa14698
--- /dev/null
+++ b/spec/frontend/editor/schema/ci/json_tests/negative_tests/release_assets_links_empty.json
@@ -0,0 +1,13 @@
+{
+ "gitlab-ci-release-assets-links-empty": {
+ "script": "dostuff",
+ "stage": "deploy",
+ "release": {
+ "description": "Created using the release-cli $EXTRA_DESCRIPTION",
+ "tag_name": "$CI_COMMIT_TAG",
+ "assets": {
+ "links": []
+ }
+ }
+ }
+}
diff --git a/spec/frontend/editor/schema/ci/json_tests/negative_tests/release_assets_links_invalid_link_type.json b/spec/frontend/editor/schema/ci/json_tests/negative_tests/release_assets_links_invalid_link_type.json
new file mode 100644
index 00000000000..048911aefa3
--- /dev/null
+++ b/spec/frontend/editor/schema/ci/json_tests/negative_tests/release_assets_links_invalid_link_type.json
@@ -0,0 +1,24 @@
+{
+ "gitlab-ci-release-assets-links-invalid-link-type": {
+ "script": "dostuff",
+ "stage": "deploy",
+ "release": {
+ "description": "Created using the release-cli $EXTRA_DESCRIPTION",
+ "tag_name": "$CI_COMMIT_TAG",
+ "assets": {
+ "links": [
+ {
+ "name": "asset1",
+ "url": "https://example.com/assets/1"
+ },
+ {
+ "name": "asset2",
+ "url": "https://example.com/assets/2",
+ "filepath": "/pretty/url/1",
+ "link_type": "invalid"
+ }
+ ]
+ }
+ }
+ }
+}
diff --git a/spec/frontend/editor/schema/ci/json_tests/negative_tests/release_assets_links_missing.json b/spec/frontend/editor/schema/ci/json_tests/negative_tests/release_assets_links_missing.json
new file mode 100644
index 00000000000..6f0b5a3bff8
--- /dev/null
+++ b/spec/frontend/editor/schema/ci/json_tests/negative_tests/release_assets_links_missing.json
@@ -0,0 +1,11 @@
+{
+ "gitlab-ci-release-assets-links-missing": {
+ "script": "dostuff",
+ "stage": "deploy",
+ "release": {
+ "description": "Created using the release-cli $EXTRA_DESCRIPTION",
+ "tag_name": "$CI_COMMIT_TAG",
+ "assets": {}
+ }
+ }
+}
diff --git a/spec/frontend/editor/schema/ci/json_tests/negative_tests/retry_unknown_when.json b/spec/frontend/editor/schema/ci/json_tests/negative_tests/retry_unknown_when.json
new file mode 100644
index 00000000000..433504f52c6
--- /dev/null
+++ b/spec/frontend/editor/schema/ci/json_tests/negative_tests/retry_unknown_when.json
@@ -0,0 +1,9 @@
+{
+ "gitlab-ci-retry-object-unknown-when": {
+ "stage": "test",
+ "script": "rspec",
+ "retry": {
+ "when": "gitlab-ci-retry-object-unknown-when"
+ }
+ }
+}
diff --git a/spec/frontend/editor/schema/ci/json_tests/positive_tests/allow_failure.json b/spec/frontend/editor/schema/ci/json_tests/positive_tests/allow_failure.json
new file mode 100644
index 00000000000..44d42116c1a
--- /dev/null
+++ b/spec/frontend/editor/schema/ci/json_tests/positive_tests/allow_failure.json
@@ -0,0 +1,19 @@
+{
+ "job1": {
+ "stage": "test",
+ "script": ["execute_script_that_will_fail"],
+ "allow_failure": true
+ },
+ "job2": {
+ "script": ["exit 1"],
+ "allow_failure": {
+ "exit_codes": 137
+ }
+ },
+ "job3": {
+ "script": ["exit 137"],
+ "allow_failure": {
+ "exit_codes": [137, 255]
+ }
+ }
+}
diff --git a/spec/frontend/editor/schema/ci/json_tests/positive_tests/environment.json b/spec/frontend/editor/schema/ci/json_tests/positive_tests/environment.json
new file mode 100644
index 00000000000..0c6f7935063
--- /dev/null
+++ b/spec/frontend/editor/schema/ci/json_tests/positive_tests/environment.json
@@ -0,0 +1,75 @@
+{
+ "deploy to production 1": {
+ "stage": "deploy",
+ "script": "git push production HEAD: master",
+ "environment": "production"
+ },
+ "deploy to production 2": {
+ "stage": "deploy",
+ "script": "git push production HEAD:master",
+ "environment": {
+ "name": "production"
+ }
+ },
+ "deploy to production 3": {
+ "stage": "deploy",
+ "script": "git push production HEAD:master",
+ "environment": {
+ "name": "production",
+ "url": "https://prod.example.com"
+ }
+ },
+ "review_app 1": {
+ "stage": "deploy",
+ "script": "make deploy-app",
+ "environment": {
+ "name": "review/$CI_COMMIT_REF_NAME",
+ "url": "https://$CI_ENVIRONMENT_SLUG.example.com",
+ "on_stop": "stop_review_app"
+ }
+ },
+ "stop_review_app": {
+ "stage": "deploy",
+ "variables": {
+ "GIT_STRATEGY": "none"
+ },
+ "script": "make delete-app",
+ "when": "manual",
+ "environment": {
+ "name": "review/$CI_COMMIT_REF_NAME",
+ "action": "stop"
+ }
+ },
+ "review_app 2": {
+ "script": "deploy-review-app",
+ "environment": {
+ "name": "review/$CI_COMMIT_REF_NAME",
+ "auto_stop_in": "1 day"
+ }
+ },
+ "deploy 1": {
+ "stage": "deploy",
+ "script": "make deploy-app",
+ "environment": {
+ "name": "production",
+ "kubernetes": {
+ "namespace": "production"
+ }
+ }
+ },
+ "deploy 2": {
+ "script": "echo",
+ "environment": {
+ "name": "customer-portal",
+ "deployment_tier": "production"
+ }
+ },
+ "deploy as review app": {
+ "stage": "deploy",
+ "script": "make deploy",
+ "environment": {
+ "name": "review/$CI_COMMIT_REF_NAME",
+ "url": "https://$CI_ENVIRONMENT_SLUG.example.com/"
+ }
+ }
+}
diff --git a/spec/frontend/editor/schema/ci/json_tests/positive_tests/gitlab-ci-dependencies.json b/spec/frontend/editor/schema/ci/json_tests/positive_tests/gitlab-ci-dependencies.json
new file mode 100644
index 00000000000..5ffa7fa799e
--- /dev/null
+++ b/spec/frontend/editor/schema/ci/json_tests/positive_tests/gitlab-ci-dependencies.json
@@ -0,0 +1,68 @@
+{
+ ".build_config": {
+ "before_script": ["echo test"]
+ },
+ ".build_script": "echo build script",
+ "default": {
+ "image": "ruby:2.5",
+ "services": ["docker:dind"],
+ "cache": {
+ "paths": ["vendor/"]
+ },
+ "before_script": ["bundle install --path vendor/"],
+ "after_script": ["rm -rf tmp/"]
+ },
+ "stages": ["install", "build", "test", "deploy"],
+ "image": "foo:latest",
+ "install task1": {
+ "image": "node:latest",
+ "stage": "install",
+ "script": "npm install",
+ "artifacts": {
+ "paths": ["node_modules/"]
+ }
+ },
+ "build dev": {
+ "image": "node:latest",
+ "stage": "build",
+ "needs": [
+ {
+ "job": "install task1"
+ }
+ ],
+ "script": "npm run build:dev"
+ },
+ "build prod": {
+ "image": "node:latest",
+ "stage": "build",
+ "needs": ["install task1"],
+ "script": "npm run build:prod"
+ },
+ "test": {
+ "image": "node:latest",
+ "stage": "build",
+ "needs": [
+ "install task1",
+ {
+ "job": "build dev",
+ "artifacts": true
+ }
+ ],
+ "script": "npm run test"
+ },
+ "deploy it": {
+ "image": "node:latest",
+ "stage": "deploy",
+ "needs": [
+ {
+ "job": "build dev",
+ "artifacts": false
+ },
+ {
+ "job": "build prod",
+ "artifacts": true
+ }
+ ],
+ "script": "npm run test"
+ }
+}
diff --git a/spec/frontend/editor/schema/ci/json_tests/positive_tests/gitlab-ci.json b/spec/frontend/editor/schema/ci/json_tests/positive_tests/gitlab-ci.json
new file mode 100644
index 00000000000..89420bbc35f
--- /dev/null
+++ b/spec/frontend/editor/schema/ci/json_tests/positive_tests/gitlab-ci.json
@@ -0,0 +1,350 @@
+{
+ ".build_config": {
+ "before_script": ["echo test"]
+ },
+ ".build_script": "echo build script",
+ ".example_variables": {
+ "foo": "hello",
+ "bar": 42
+ },
+ ".example_services": [
+ "docker:dind",
+ {
+ "name": "sql:latest",
+ "command": ["/usr/bin/super-sql", "run"]
+ }
+ ],
+ "default": {
+ "image": "ruby:2.5",
+ "services": ["docker:dind"],
+ "cache": {
+ "paths": ["vendor/"]
+ },
+ "before_script": ["bundle install --path vendor/"],
+ "after_script": ["rm -rf tmp/"],
+ "tags": ["ruby", "postgres"],
+ "artifacts": {
+ "name": "%CI_COMMIT_REF_NAME%",
+ "expose_as": "artifact 1",
+ "paths": ["path/to/file.txt", "target/*.war"],
+ "when": "on_failure"
+ },
+ "retry": 2,
+ "timeout": "3 hours 30 minutes",
+ "interruptible": true
+ },
+ "stages": ["build", "test", "deploy", "random"],
+ "image": "foo:latest",
+ "services": ["sql:latest"],
+ "before_script": ["echo test", "echo test2"],
+ "after_script": [],
+ "cache": {
+ "key": "asd",
+ "paths": ["dist/", ".foo"],
+ "untracked": false,
+ "policy": "pull"
+ },
+ "variables": {
+ "STAGE": "yep",
+ "PROD": "nope"
+ },
+ "include": [
+ "https://gitlab.com/awesome-project/raw/master/.before-script-template.yml",
+ "/templates/.after-script-template.yml",
+ { "template": "Auto-DevOps.gitlab-ci.yml" },
+ {
+ "project": "my-group/my-project",
+ "ref": "master",
+ "file": "/templates/.gitlab-ci-template.yml"
+ },
+ {
+ "project": "my-group/my-project",
+ "ref": "master",
+ "file": ["/templates/.gitlab-ci-template.yml", "/templates/another-template-to-include.yml"]
+ }
+ ],
+ "build": {
+ "image": {
+ "name": "node:latest"
+ },
+ "services": [],
+ "stage": "build",
+ "script": "npm run build",
+ "before_script": ["npm install"],
+ "rules": [
+ {
+ "if": "moo",
+ "changes": ["Moofile"],
+ "exists": ["main.cow"],
+ "when": "delayed",
+ "start_in": "3 hours"
+ }
+ ],
+ "retry": {
+ "max": 1,
+ "when": "stuck_or_timeout_failure"
+ },
+ "cache": {
+ "key": "$CI_COMMIT_REF_NAME",
+ "paths": ["node_modules/"],
+ "policy": "pull-push"
+ },
+ "artifacts": {
+ "paths": ["dist/"],
+ "expose_as": "link_name_in_merge_request",
+ "name": "bundles",
+ "when": "on_success",
+ "expire_in": "1 week",
+ "reports": {
+ "junit": "result.xml",
+ "cobertura": "cobertura-coverage.xml",
+ "codequality": "codequality.json",
+ "sast": "sast.json",
+ "dependency_scanning": "scan.json",
+ "container_scanning": "scan2.json",
+ "dast": "dast.json",
+ "license_management": "license.json",
+ "performance": "performance.json",
+ "metrics": "metrics.txt"
+ }
+ },
+ "variables": {
+ "FOO_BAR": "..."
+ },
+ "only": {
+ "kubernetes": "active",
+ "variables": ["$FOO_BAR == '...'"],
+ "changes": ["/path/to/file", "/another/file"]
+ },
+ "except": ["master", "tags"],
+ "tags": ["docker"],
+ "allow_failure": true,
+ "when": "manual"
+ },
+ "error-report": {
+ "when": "on_failure",
+ "script": "report error",
+ "stage": "test"
+ },
+ "test": {
+ "image": {
+ "name": "node:latest",
+ "entrypoint": [""]
+ },
+ "stage": "test",
+ "script": "npm test",
+ "parallel": 5,
+ "retry": {
+ "max": 2,
+ "when": [
+ "runner_system_failure",
+ "stuck_or_timeout_failure",
+ "script_failure",
+ "unknown_failure",
+ "always"
+ ]
+ },
+ "artifacts": {
+ "reports": {
+ "junit": ["result.xml"],
+ "cobertura": ["cobertura-coverage.xml"],
+ "codequality": ["codequality.json"],
+ "sast": ["sast.json"],
+ "dependency_scanning": ["scan.json"],
+ "container_scanning": ["scan2.json"],
+ "dast": ["dast.json"],
+ "license_management": ["license.json"],
+ "performance": ["performance.json"],
+ "metrics": ["metrics.txt"]
+ }
+ },
+ "coverage": "/Cycles: \\d+\\.\\d+$/",
+ "dependencies": []
+ },
+ "docker": {
+ "script": "docker build -t foo:latest",
+ "when": "delayed",
+ "start_in": "10 min",
+ "timeout": "1h",
+ "retry": 1,
+ "only": {
+ "changes": ["Dockerfile", "docker/scripts/*"]
+ }
+ },
+ "deploy": {
+ "services": [
+ {
+ "name": "sql:latest",
+ "entrypoint": [""],
+ "command": ["/usr/bin/super-sql", "run"],
+ "alias": "super-sql"
+ },
+ "sql:latest",
+ {
+ "name": "sql:latest",
+ "alias": "default-sql"
+ }
+ ],
+ "script": "dostuff",
+ "stage": "deploy",
+ "environment": {
+ "name": "prod",
+ "url": "http://example.com",
+ "on_stop": "stop-deploy"
+ },
+ "only": ["master"],
+ "release": {
+ "name": "Release $CI_COMMIT_TAG",
+ "description": "Created using the release-cli $EXTRA_DESCRIPTION",
+ "tag_name": "$CI_COMMIT_TAG",
+ "ref": "$CI_COMMIT_TAG",
+ "milestones": ["m1", "m2", "m3"],
+ "released_at": "2020-07-15T08:00:00Z",
+ "assets": {
+ "links": [
+ {
+ "name": "asset1",
+ "url": "https://example.com/assets/1"
+ },
+ {
+ "name": "asset2",
+ "url": "https://example.com/assets/2",
+ "filepath": "/pretty/url/1",
+ "link_type": "other"
+ },
+ {
+ "name": "asset3",
+ "url": "https://example.com/assets/3",
+ "link_type": "runbook"
+ },
+ {
+ "name": "asset4",
+ "url": "https://example.com/assets/4",
+ "link_type": "package"
+ },
+ {
+ "name": "asset5",
+ "url": "https://example.com/assets/5",
+ "link_type": "image"
+ }
+ ]
+ }
+ }
+ },
+ ".performance-tmpl": {
+ "after_script": ["echo after"],
+ "before_script": ["echo before"],
+ "variables": {
+ "SCRIPT_NOT_REQUIRED": "true"
+ }
+ },
+ "performance-a": {
+ "extends": ".performance-tmpl",
+ "script": "echo test"
+ },
+ "performance-b": {
+ "extends": ".performance-tmpl"
+ },
+ "workflow": {
+ "rules": [
+ {
+ "if": "$CI_COMMIT_REF_NAME =~ /-wip$/",
+ "when": "never"
+ },
+ {
+ "if": "$CI_COMMIT_TAG",
+ "when": "never"
+ },
+ {
+ "when": "always"
+ }
+ ]
+ },
+ "job": {
+ "script": "echo Hello, Rules!",
+ "rules": [
+ {
+ "if": "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME == \"master\"",
+ "when": "manual",
+ "allow_failure": true
+ }
+ ]
+ },
+ "microservice_a": {
+ "trigger": {
+ "include": "path/to/microservice_a.yml"
+ }
+ },
+ "microservice_b": {
+ "trigger": {
+ "include": [{ "local": "path/to/microservice_b.yml" }, { "template": "SAST.gitlab-cy.yml" }],
+ "strategy": "depend"
+ }
+ },
+ "child-pipeline": {
+ "stage": "test",
+ "trigger": {
+ "include": [
+ {
+ "artifact": "generated-config.yml",
+ "job": "generate-config"
+ }
+ ]
+ }
+ },
+ "child-pipeline-simple": {
+ "stage": "test",
+ "trigger": {
+ "include": "other/file.yml"
+ }
+ },
+ "complex": {
+ "stage": "deploy",
+ "trigger": {
+ "project": "my/deployment",
+ "branch": "stable"
+ }
+ },
+ "parallel-integer": {
+ "stage": "test",
+ "script": ["echo ${CI_NODE_INDEX} ${CI_NODE_TOTAL}"],
+ "parallel": 5
+ },
+ "parallel-matrix-simple": {
+ "stage": "test",
+ "script": ["echo ${MY_VARIABLE}"],
+ "parallel": {
+ "matrix": [
+ {
+ "MY_VARIABLE": 0
+ },
+ {
+ "MY_VARIABLE": "sample"
+ },
+ {
+ "MY_VARIABLE": ["element0", 1, "element2"]
+ }
+ ]
+ }
+ },
+ "parallel-matrix-gitlab-docs": {
+ "stage": "deploy",
+ "script": ["bin/deploy"],
+ "parallel": {
+ "matrix": [
+ {
+ "PROVIDER": "aws",
+ "STACK": ["app1", "app2"]
+ },
+ {
+ "PROVIDER": "ovh",
+ "STACK": ["monitoring", "backup", "app"]
+ },
+ {
+ "PROVIDER": ["gcp", "vultr"],
+ "STACK": ["data", "processing"]
+ }
+ ]
+ }
+ }
+}
diff --git a/spec/frontend/editor/schema/ci/json_tests/positive_tests/inherit.json b/spec/frontend/editor/schema/ci/json_tests/positive_tests/inherit.json
new file mode 100644
index 00000000000..3f72afa6ceb
--- /dev/null
+++ b/spec/frontend/editor/schema/ci/json_tests/positive_tests/inherit.json
@@ -0,0 +1,54 @@
+{
+ "default": {
+ "image": "ruby:2.4",
+ "before_script": ["echo Hello World"]
+ },
+ "variables": {
+ "DOMAIN": "example.com",
+ "WEBHOOK_URL": "https://my-webhook.example.com"
+ },
+ "rubocop": {
+ "inherit": {
+ "default": false,
+ "variables": false
+ },
+ "script": "bundle exec rubocop"
+ },
+ "rspec": {
+ "inherit": {
+ "default": ["image"],
+ "variables": ["WEBHOOK_URL"]
+ },
+ "script": "bundle exec rspec"
+ },
+ "capybara": {
+ "inherit": {
+ "variables": false
+ },
+ "script": "bundle exec capybara"
+ },
+ "karma": {
+ "inherit": {
+ "default": true,
+ "variables": ["DOMAIN"]
+ },
+ "script": "karma"
+ },
+ "inherit literally all": {
+ "inherit": {
+ "default": [
+ "after_script",
+ "artifacts",
+ "before_script",
+ "cache",
+ "image",
+ "interruptible",
+ "retry",
+ "services",
+ "tags",
+ "timeout"
+ ]
+ },
+ "script": "true"
+ }
+}
diff --git a/spec/frontend/editor/schema/ci/json_tests/positive_tests/multiple-caches.json b/spec/frontend/editor/schema/ci/json_tests/positive_tests/multiple-caches.json
new file mode 100644
index 00000000000..360938e5ce7
--- /dev/null
+++ b/spec/frontend/editor/schema/ci/json_tests/positive_tests/multiple-caches.json
@@ -0,0 +1,24 @@
+{
+ "test-job": {
+ "stage": "build",
+ "cache": [
+ {
+ "key": {
+ "files": ["Gemfile.lock"]
+ },
+ "paths": ["vendor/ruby"]
+ },
+ {
+ "key": {
+ "files": ["yarn.lock"]
+ },
+ "paths": [".yarn-cache/"]
+ }
+ ],
+ "script": [
+ "bundle install --path=vendor",
+ "yarn install --cache-folder .yarn-cache",
+ "echo Run tests..."
+ ]
+ }
+}
diff --git a/spec/frontend/editor/schema/ci/json_tests/positive_tests/retry.json b/spec/frontend/editor/schema/ci/json_tests/positive_tests/retry.json
new file mode 100644
index 00000000000..1337e5e7bc8
--- /dev/null
+++ b/spec/frontend/editor/schema/ci/json_tests/positive_tests/retry.json
@@ -0,0 +1,60 @@
+{
+ "gitlab-ci-retry-int": {
+ "stage": "test",
+ "script": "rspec",
+ "retry": 2
+ },
+ "gitlab-ci-retry-object-no-max": {
+ "stage": "test",
+ "script": "rspec",
+ "retry": {
+ "when": "runner_system_failure"
+ }
+ },
+ "gitlab-ci-retry-object-single-when": {
+ "stage": "test",
+ "script": "rspec",
+ "retry": {
+ "max": 2,
+ "when": "runner_system_failure"
+ }
+ },
+ "gitlab-ci-retry-object-multiple-when": {
+ "stage": "test",
+ "script": "rspec",
+ "retry": {
+ "max": 2,
+ "when": ["runner_system_failure", "stuck_or_timeout_failure"]
+ }
+ },
+ "gitlab-ci-retry-object-multiple-when-dupes": {
+ "stage": "test",
+ "script": "rspec",
+ "retry": {
+ "max": 2,
+ "when": ["runner_system_failure", "runner_system_failure"]
+ }
+ },
+ "gitlab-ci-retry-object-all-when": {
+ "stage": "test",
+ "script": "rspec",
+ "retry": {
+ "max": 2,
+ "when": [
+ "always",
+ "unknown_failure",
+ "script_failure",
+ "api_failure",
+ "stuck_or_timeout_failure",
+ "runner_system_failure",
+ "runner_unsupported",
+ "stale_schedule",
+ "job_execution_timeout",
+ "archived_failure",
+ "unmet_prerequisites",
+ "scheduler_failure",
+ "data_integrity_failure"
+ ]
+ }
+ }
+}
diff --git a/spec/frontend/editor/schema/ci/json_tests/positive_tests/terraform_report.json b/spec/frontend/editor/schema/ci/json_tests/positive_tests/terraform_report.json
new file mode 100644
index 00000000000..0e444a4ba62
--- /dev/null
+++ b/spec/frontend/editor/schema/ci/json_tests/positive_tests/terraform_report.json
@@ -0,0 +1,50 @@
+{
+ "image": {
+ "name": "registry.gitlab.com/gitlab-org/gitlab-build-images:terraform",
+ "entrypoint": [
+ "/usr/bin/env",
+ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
+ ]
+ },
+ "variables": {
+ "PLAN": "plan.tfplan",
+ "JSON_PLAN_FILE": "tfplan.json"
+ },
+ "cache": {
+ "paths": [".terraform"]
+ },
+ "before_script": [
+ "alias convert_report=\"jq -r '([.resource_changes[]?.change.actions?]|flatten)|{\"create\":(map(select(.==\"create\"))|length),\"update\":(map(select(.==\"update\"))|length),\"delete\":(map(select(.==\"delete\"))|length)}'\"",
+ "terraform --version",
+ "terraform init"
+ ],
+ "stages": ["validate", "build", "test", "deploy"],
+ "validate": {
+ "stage": "validate",
+ "script": ["terraform validate"]
+ },
+ "plan": {
+ "stage": "build",
+ "script": [
+ "terraform plan -out=$PLAN",
+ "terraform show --json $PLAN | convert_report > $JSON_PLAN_FILE"
+ ],
+ "artifacts": {
+ "name": "plan",
+ "paths": ["$PLAN"],
+ "reports": {
+ "terraform": "$JSON_PLAN_FILE"
+ }
+ }
+ },
+ "apply": {
+ "stage": "deploy",
+ "environment": {
+ "name": "production"
+ },
+ "script": ["terraform apply -input=false $PLAN"],
+ "dependencies": ["plan"],
+ "when": "manual",
+ "only": ["master"]
+ }
+}
diff --git a/spec/frontend/editor/schema/ci/json_tests/positive_tests/variables.json b/spec/frontend/editor/schema/ci/json_tests/positive_tests/variables.json
new file mode 100644
index 00000000000..ce59b3fbbec
--- /dev/null
+++ b/spec/frontend/editor/schema/ci/json_tests/positive_tests/variables.json
@@ -0,0 +1,22 @@
+{
+ "variables": {
+ "DEPLOY_ENVIRONMENT": {
+ "value": "staging",
+ "description": "The deployment target. Change this variable to 'canary' or 'production' if needed."
+ }
+ },
+ "gitlab-ci-variables-string": {
+ "stage": "test",
+ "script": ["true"],
+ "variables": {
+ "TEST_VAR": "String variable"
+ }
+ },
+ "gitlab-ci-variables-integer": {
+ "stage": "test",
+ "script": ["true"],
+ "variables": {
+ "canonical": 685230
+ }
+ }
+}
diff --git a/spec/frontend/editor/schema/ci/json_tests/positive_tests/variables_mix_string_and_user_input.json b/spec/frontend/editor/schema/ci/json_tests/positive_tests/variables_mix_string_and_user_input.json
new file mode 100644
index 00000000000..87a9ec05b57
--- /dev/null
+++ b/spec/frontend/editor/schema/ci/json_tests/positive_tests/variables_mix_string_and_user_input.json
@@ -0,0 +1,10 @@
+{
+ "variables": {
+ "SOME_STR": "--batch-mode --errors --fail-at-end --show-version",
+ "SOME_INT": 10,
+ "SOME_USER_INPUT_FLAG": {
+ "value": "flag value",
+ "description": "Some Flag!"
+ }
+ }
+}
diff --git a/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/cache.yml b/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/cache.yml
new file mode 100644
index 00000000000..ee533f54d3b
--- /dev/null
+++ b/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/cache.yml
@@ -0,0 +1,15 @@
+# Covers https://gitlab.com/gitlab-org/gitlab/-/merge_requests/70779
+stages:
+ - prepare
+
+# invalid cache:when value
+job1:
+ stage: prepare
+ cache:
+ when: 0
+
+# invalid cache:when value
+job2:
+ stage: prepare
+ cache:
+ when: 'never'
diff --git a/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/include.yml b/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/include.yml
new file mode 100644
index 00000000000..287150a765f
--- /dev/null
+++ b/spec/frontend/editor/schema/ci/yaml_tests/negative_tests/include.yml
@@ -0,0 +1,17 @@
+# Covers https://gitlab.com/gitlab-org/gitlab/-/merge_requests/70779
+stages:
+ - prepare
+
+# missing file property
+childPipeline:
+ stage: prepare
+ trigger:
+ include:
+ - project: 'my-group/my-pipeline-library'
+
+# missing project property
+childPipeline2:
+ stage: prepare
+ trigger:
+ include:
+ - file: '.gitlab-ci.yml'
diff --git a/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/cache.yml b/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/cache.yml
new file mode 100644
index 00000000000..436c7d72699
--- /dev/null
+++ b/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/cache.yml
@@ -0,0 +1,25 @@
+# Covers https://gitlab.com/gitlab-org/gitlab/-/merge_requests/70779
+stages:
+ - prepare
+
+# test for cache:when values
+job1:
+ stage: prepare
+ script:
+ - echo 'running job'
+ cache:
+ when: 'on_success'
+
+job2:
+ stage: prepare
+ script:
+ - echo 'running job'
+ cache:
+ when: 'on_failure'
+
+job3:
+ stage: prepare
+ script:
+ - echo 'running job'
+ cache:
+ when: 'always'
diff --git a/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/filter.yml b/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/filter.yml
new file mode 100644
index 00000000000..2b29c24fa3c
--- /dev/null
+++ b/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/filter.yml
@@ -0,0 +1,18 @@
+# Covers https://gitlab.com/gitlab-org/gitlab/-/merge_requests/79335
+deploy-template:
+ script:
+ - echo "hello world"
+ only:
+ - foo
+ except:
+ - bar
+
+# null value allowed
+deploy-without-only:
+ extends: deploy-template
+ only:
+
+# null value allowed
+deploy-without-except:
+ extends: deploy-template
+ except:
diff --git a/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/include.yml b/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/include.yml
new file mode 100644
index 00000000000..3497be28058
--- /dev/null
+++ b/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/include.yml
@@ -0,0 +1,32 @@
+# Covers https://gitlab.com/gitlab-org/gitlab/-/merge_requests/70779
+
+# test for include:rules
+include:
+ - local: builds.yml
+ rules:
+ - if: '$INCLUDE_BUILDS == "true"'
+ when: always
+
+stages:
+ - prepare
+
+# test for trigger:include
+childPipeline:
+ stage: prepare
+ script:
+ - echo 'creating pipeline...'
+ trigger:
+ include:
+ - project: 'my-group/my-pipeline-library'
+ file: '.gitlab-ci.yml'
+
+# accepts optional ref property
+childPipeline2:
+ stage: prepare
+ script:
+ - echo 'creating pipeline...'
+ trigger:
+ include:
+ - project: 'my-group/my-pipeline-library'
+ file: '.gitlab-ci.yml'
+ ref: 'main'
diff --git a/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/rules.yml b/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/rules.yml
new file mode 100644
index 00000000000..27a199cff13
--- /dev/null
+++ b/spec/frontend/editor/schema/ci/yaml_tests/positive_tests/rules.yml
@@ -0,0 +1,13 @@
+# Covers https://gitlab.com/gitlab-org/gitlab/-/merge_requests/74164
+
+# test for workflow:rules:changes and workflow:rules:exists
+workflow:
+ rules:
+ - if: '$CI_PIPELINE_SOURCE == "schedule"'
+ exists:
+ - Dockerfile
+ changes:
+ - Dockerfile
+ variables:
+ IS_A_FEATURE: 'true'
+ when: always