Skip to content

Commit

Permalink
Merge pull request #25 from SublimeText/drone_ci
Browse files Browse the repository at this point in the history
[Drone CI] initial support for Drone CI
  • Loading branch information
keith-hall authored May 27, 2024
2 parents ea694c3 + cd3f26f commit 003c4af
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 1 deletion.
60 changes: 60 additions & 0 deletions Drone CI.sublime-syntax
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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!
62 changes: 62 additions & 0 deletions tests/syntax_test_drone_ci.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 003c4af

Please sign in to comment.