Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Drone CI] initial support for Drone CI #25

Merged
merged 1 commit into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading