From 748fb77ab7523f7fe4419cff2a1894cbfe2abe0f Mon Sep 17 00:00:00 2001 From: Keith Hall Date: Thu, 16 May 2024 21:50:29 +0300 Subject: [PATCH 1/4] [GitLab] support script references --- Gitlab CICD.sublime-syntax | 35 ++++++++++++++++++++++++++ tests/syntax_test_gitlab_cicd.yml | 41 +++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) diff --git a/Gitlab CICD.sublime-syntax b/Gitlab CICD.sublime-syntax index 2a59a4d..93d6cae 100644 --- a/Gitlab CICD.sublime-syntax +++ b/Gitlab CICD.sublime-syntax @@ -39,6 +39,12 @@ contexts: 2: punctuation.separator.key-value.yaml script-block-sequence: + - match: (-)[ \t]+(!reference\b)\s*(\[) + captures: + 1: punctuation.definition.block.sequence.item.yaml + 2: meta.property.yaml storage.type.tag-handle.yaml + 3: meta.sequence.flow.yaml punctuation.definition.sequence.begin.yaml + push: script-reference-flow-sequence-body - match: (-)[ \t]+(?=\S) captures: 1: punctuation.definition.block.sequence.item.yaml @@ -63,3 +69,32 @@ contexts: - meta_include_prototype: false - meta_scope: source.shell.bash.embedded - include: scope:source.shell.bash.folded + + script-reference-flow-sequence-body: + - meta_content_scope: meta.sequence.flow.yaml + - match: \] + scope: meta.sequence.flow.yaml punctuation.definition.sequence.end.yaml + pop: 1 + - match: ',' + scope: punctuation.separator.sequence.yaml + push: after-reference + - match: '[-\w.]+' + scope: constant.other.label.gitlab + - include: flow-pair-no-clear + - include: flow-node-11 + + after-reference: + - match: \w+ + scope: constant.other.gitlab + - match: ',' + scope: punctuation.separator.sequence.yaml + set: after-reference-type + - match: (?=\]) + pop: 1 + + after-reference-type: + - match: \w+ + scope: variable.other.constant.gitlab + pop: 1 + - match: (?=\S) + pop: 1 diff --git a/tests/syntax_test_gitlab_cicd.yml b/tests/syntax_test_gitlab_cicd.yml index 3aa4088..0970e30 100644 --- a/tests/syntax_test_gitlab_cicd.yml +++ b/tests/syntax_test_gitlab_cicd.yml @@ -153,3 +153,44 @@ release-finish: # ^^^^^^^^^^^^^^^^ meta.string # ^^^^^^^^^^^ meta.interpolation.parameter variable.other.readwrite -DskipTestProject=true + +include: + - local: setup.yml + +.teardown: + after_script: + - echo deleting environment + +test: + script: + - !reference [.setup, script] +# ^ punctuation.definition.block.sequence.item +# ^^^^^^^^^^ meta.property storage.type.tag-handle +# ^^^^^^^^^^^^^^^^ meta.sequence.flow +# ^ punctuation.definition.sequence.begin +# ^^^^^^ constant.other.label +# ^ punctuation.separator.sequence +# ^^^^^^ constant.other +# ^ punctuation.definition.sequence.end +# ^ - meta.sequence + - echo running my own command +# ^ meta.block.script punctuation.definition.block.sequence.item +# ^^^^ source.shell.bash meta.function-call.identifier support.function.echo + after_script: + - !reference [.teardown, after_script] + +.vars: + variables: + URL: "http://my-url.internal" + IMPORTANT_VAR: "the details" + +test-vars-1: + variables: !reference [.vars, variables] + script: + - printenv + +test-vars-2: + variables: + MY_VAR: !reference [.vars, variables, IMPORTANT_VAR] + script: + - printenv From b7aef0aad5319e2e218c7c388bc633e7c00918ff Mon Sep 17 00:00:00 2001 From: Keith Hall Date: Thu, 16 May 2024 21:53:15 +0300 Subject: [PATCH 2/4] [GitLab] rework to support variable references as well --- Gitlab CICD.sublime-syntax | 24 +++++++++++++----------- tests/syntax_test_gitlab_cicd.yml | 8 ++++++++ 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/Gitlab CICD.sublime-syntax b/Gitlab CICD.sublime-syntax index 93d6cae..365725c 100644 --- a/Gitlab CICD.sublime-syntax +++ b/Gitlab CICD.sublime-syntax @@ -39,12 +39,6 @@ contexts: 2: punctuation.separator.key-value.yaml script-block-sequence: - - match: (-)[ \t]+(!reference\b)\s*(\[) - captures: - 1: punctuation.definition.block.sequence.item.yaml - 2: meta.property.yaml storage.type.tag-handle.yaml - 3: meta.sequence.flow.yaml punctuation.definition.sequence.begin.yaml - push: script-reference-flow-sequence-body - match: (-)[ \t]+(?=\S) captures: 1: punctuation.definition.block.sequence.item.yaml @@ -70,29 +64,37 @@ contexts: - meta_scope: source.shell.bash.embedded - include: scope:source.shell.bash.folded - script-reference-flow-sequence-body: + property: + - meta_prepend: true + - match: (!reference\b)\s*(\[) + captures: + 1: meta.property.yaml storage.type.tag-handle.yaml + 2: meta.sequence.flow.yaml punctuation.definition.sequence.begin.yaml + push: gitlab-reference-flow-sequence-body + + gitlab-reference-flow-sequence-body: - meta_content_scope: meta.sequence.flow.yaml - match: \] scope: meta.sequence.flow.yaml punctuation.definition.sequence.end.yaml pop: 1 - match: ',' scope: punctuation.separator.sequence.yaml - push: after-reference + push: gitlab-after-reference - match: '[-\w.]+' scope: constant.other.label.gitlab - include: flow-pair-no-clear - include: flow-node-11 - after-reference: + gitlab-after-reference: - match: \w+ scope: constant.other.gitlab - match: ',' scope: punctuation.separator.sequence.yaml - set: after-reference-type + set: gitlab-after-reference-type - match: (?=\]) pop: 1 - after-reference-type: + gitlab-after-reference-type: - match: \w+ scope: variable.other.constant.gitlab pop: 1 diff --git a/tests/syntax_test_gitlab_cicd.yml b/tests/syntax_test_gitlab_cicd.yml index 0970e30..b68d962 100644 --- a/tests/syntax_test_gitlab_cicd.yml +++ b/tests/syntax_test_gitlab_cicd.yml @@ -192,5 +192,13 @@ test-vars-1: test-vars-2: variables: MY_VAR: !reference [.vars, variables, IMPORTANT_VAR] + # ^^^^^^^^^^ meta.property storage.type.tag-handle + # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.sequence.flow + # ^ punctuation.definition.sequence.begin + # ^^^^^ constant.other.label + # ^ punctuation.separator.sequence + # ^^^^^^^^^ constant.other + # ^ punctuation.separator.sequence + # ^^^^^^^^^^^^^ variable.other.constant script: - printenv From b034f7055f80024368dd56b011c6c1f6384caf74 Mon Sep 17 00:00:00 2001 From: Keith Hall Date: Mon, 27 May 2024 21:51:41 +0300 Subject: [PATCH 3/4] [GitLab] changes after PR comments --- Gitlab CICD.sublime-syntax | 4 ++-- tests/syntax_test_gitlab_cicd.yml | 22 ++++++++++++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Gitlab CICD.sublime-syntax b/Gitlab CICD.sublime-syntax index 365725c..468a464 100644 --- a/Gitlab CICD.sublime-syntax +++ b/Gitlab CICD.sublime-syntax @@ -66,7 +66,7 @@ contexts: property: - meta_prepend: true - - match: (!reference\b)\s*(\[) + - match: (!reference)\s*(\[) captures: 1: meta.property.yaml storage.type.tag-handle.yaml 2: meta.sequence.flow.yaml punctuation.definition.sequence.begin.yaml @@ -87,7 +87,7 @@ contexts: gitlab-after-reference: - match: \w+ - scope: constant.other.gitlab + scope: keyword.other.gitlab - match: ',' scope: punctuation.separator.sequence.yaml set: gitlab-after-reference-type diff --git a/tests/syntax_test_gitlab_cicd.yml b/tests/syntax_test_gitlab_cicd.yml index b68d962..977be0e 100644 --- a/tests/syntax_test_gitlab_cicd.yml +++ b/tests/syntax_test_gitlab_cicd.yml @@ -170,7 +170,7 @@ test: # ^ punctuation.definition.sequence.begin # ^^^^^^ constant.other.label # ^ punctuation.separator.sequence -# ^^^^^^ constant.other +# ^^^^^^ keyword.other # ^ punctuation.definition.sequence.end # ^ - meta.sequence - echo running my own command @@ -197,8 +197,26 @@ test-vars-2: # ^ punctuation.definition.sequence.begin # ^^^^^ constant.other.label # ^ punctuation.separator.sequence - # ^^^^^^^^^ constant.other + # ^^^^^^^^^ keyword.other # ^ punctuation.separator.sequence # ^^^^^^^^^^^^^ variable.other.constant script: - printenv + +job1: + artifacts: + paths: + - binaries/ + - .config + +job2: + artifacts: + paths: !reference [job1, artifacts, paths] +# ^^^^^^^^^^ meta.property storage.type.tag-handle +# ^^^^^^^^^^^^^^^^^^^^^^^^ meta.sequence.flow +# ^^^^ constant.other.label +# ^ punctuation.separator.sequence +# ^^^^^^^^^ keyword.other +# ^ punctuation.separator.sequence +# ^^^^^ variable.other.constant +# ^ punctuation.definition.sequence.end From bc67d948eaa60fff5d8ff7ff97e484cafc19aed0 Mon Sep 17 00:00:00 2001 From: Keith Hall Date: Tue, 28 May 2024 21:06:15 +0300 Subject: [PATCH 4/4] [GitLab] improvements from PR review --- Gitlab CICD.sublime-syntax | 7 ++++++- tests/syntax_test_gitlab_cicd.yml | 8 +++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Gitlab CICD.sublime-syntax b/Gitlab CICD.sublime-syntax index 468a464..c074c67 100644 --- a/Gitlab CICD.sublime-syntax +++ b/Gitlab CICD.sublime-syntax @@ -91,12 +91,17 @@ contexts: - match: ',' scope: punctuation.separator.sequence.yaml set: gitlab-after-reference-type + - include: flow-pair-no-clear + - include: flow-node-11 - match: (?=\]) pop: 1 gitlab-after-reference-type: - match: \w+ scope: variable.other.constant.gitlab - pop: 1 + - match: ',' + scope: punctuation.separator.sequence.yaml + - include: flow-pair-no-clear + - include: flow-node-11 - match: (?=\S) pop: 1 diff --git a/tests/syntax_test_gitlab_cicd.yml b/tests/syntax_test_gitlab_cicd.yml index 977be0e..ed0b0e8 100644 --- a/tests/syntax_test_gitlab_cicd.yml +++ b/tests/syntax_test_gitlab_cicd.yml @@ -211,12 +211,14 @@ job1: job2: artifacts: - paths: !reference [job1, artifacts, paths] + paths: !reference [job1, artifacts, paths, further_nesting] # ^^^^^^^^^^ meta.property storage.type.tag-handle -# ^^^^^^^^^^^^^^^^^^^^^^^^ meta.sequence.flow +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.sequence.flow # ^^^^ constant.other.label # ^ punctuation.separator.sequence # ^^^^^^^^^ keyword.other # ^ punctuation.separator.sequence # ^^^^^ variable.other.constant -# ^ punctuation.definition.sequence.end +# ^ punctuation.separator.sequence +# ^^^^^^^^^^^^^^^ variable.other.constant +# ^ punctuation.definition.sequence.end