From cd3f26f9350b02124999127bf7f4408dcca405cd Mon Sep 17 00:00:00 2001 From: Keith Hall Date: Sun, 26 May 2024 20:42:54 +0300 Subject: [PATCH] [Drone CI] initial support for Drone CI https://docs.drone.io/quickstart/docker/ --- Drone CI.sublime-syntax | 60 ++++++++++++++++++++++++++++++++ README.md | 2 +- tests/syntax_test_drone_ci.yml | 62 ++++++++++++++++++++++++++++++++++ 3 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 Drone CI.sublime-syntax create mode 100644 tests/syntax_test_drone_ci.yml diff --git a/Drone CI.sublime-syntax b/Drone CI.sublime-syntax new file mode 100644 index 0000000..71a4283 --- /dev/null +++ b/Drone CI.sublime-syntax @@ -0,0 +1,60 @@ +%YAML 1.2 +--- +# https://docs.drone.io/quickstart/docker/ +scope: source.yaml.pipeline.drone +version: 2 + +extends: Packages/YamlPipelines/YamlPipeline.sublime-syntax + +file_extensions: + - .drone.yml + +variables: + global_keywords: |- + (?x)\b(?: + services + | steps + | trigger + )\b + + +contexts: + node: + - meta_prepend: true + - match: ^(\s+)(commands)\s*(:)(?=\s|$) + captures: + 2: string.unquoted.plain.out.yaml keyword.control.flow.script.pipeline + 3: punctuation.separator.key-value.yaml + push: script-block-sequence + - match: ^({{global_keywords}})\s*(:)$ + captures: + 1: meta.mapping.key.yaml meta.string.yaml string.unquoted.plain.out.yaml + 2: meta.mapping.yaml punctuation.separator.key-value.mapping.yaml + - match: ^(?=[\.\w])([-.\w ]+)\s*(:)$ + captures: + 1: entity.name.label.gitlab + 2: punctuation.separator.key-value.yaml + + script-block-sequence: + - match: (-)[ \t]+(?=\S) + captures: + 1: punctuation.definition.block.sequence.item.yaml + push: script-block-node + - match: ^(?!\1\s*-) + pop: 1 + + script-block-node: + - meta_prepend: true + - include: flow-alias + - match: '{{_flow_scalar_end_plain_out}}' + pop: 1 + + embedded-bash: + - meta_include_prototype: false + - meta_scope: source.shell.bash.embedded + - include: scope:source.shell.bash + + embedded-bash-folded: + - meta_include_prototype: false + - meta_scope: source.shell.bash.embedded + - include: scope:source.shell.bash.folded diff --git a/README.md b/README.md index 64096c1..dc18fbc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Yaml Pipelines for Sublime Text -Syntax highlighting definitions for YAML pipeline files, like GitHub Actions and AzureDevops. +Syntax highlighting definitions for YAML pipeline files, like GitHub Actions and AzureDevops, Drone CI, GitLab CICD etc. Includes a small plugin to automatically apply the GitHub Actions filetype when loading or saving a YAML file in a `.github/workflows` folder. Why not just use the default YAML syntax definition? Because it doesn't highlight conditions, variables or embedded Bash or PowerShell scripts! diff --git a/tests/syntax_test_drone_ci.yml b/tests/syntax_test_drone_ci.yml new file mode 100644 index 0000000..715293a --- /dev/null +++ b/tests/syntax_test_drone_ci.yml @@ -0,0 +1,62 @@ +# SYNTAX TEST "Packages/YamlPipelines/Drone CI.sublime-syntax" +kind: pipeline +type: docker +name: en + +steps: + # ^ meta.mapping.key meta.string string.unquoted.plain.out +- name: greeting + image: alpine + commands: +# ^^^^^^^^ string.unquoted.plain.out keyword.control.flow.script +# ^ punctuation.separator.key-value + - echo hello world +# ^ meta.block.script punctuation.definition.block.sequence.item +# ^^^^^^^^^^^^^^^^ source.shell.bash +# ^^^^ support.function.echo + +# <- - source.shell +trigger: + event: + - push + +--- +kind: pipeline +type: docker +name: fr + +steps: +- name: greeting + image: alpine + commands: + - echo bonjour monde + +trigger: + event: + - pull_request + +--- +# <- entity.other.document.begin +kind: pipeline +type: docker +name: default + +steps: +- name: test + image: golang:1.13 + # TODO: scope this like the Containerfile syntax does + commands: + - go build +# ^ meta.block.script punctuation.definition.block.sequence.item +# ^^^^^^^^ source.shell.bash + - go test -v +# ^ meta.block.script punctuation.definition.block.sequence.item - source.shell +# ^^ source.shell.bash meta.function-call.identifier variable.function + +- name: notify +# <- punctuation.definition.block.sequence.item - meta.block.script + image: plugins/slack + settings: + channel: dev + webhook: + from_secret: endpoint