summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ale_linters/yaml/actionlint.vim10
-rw-r--r--autoload/ale/handlers/actionlint.vim24
-rw-r--r--doc/ale-supported-languages-and-tools.txt1
-rw-r--r--doc/ale-yaml.txt22
-rw-r--r--doc/ale.txt1
-rw-r--r--supported-tools.md1
-rw-r--r--test/handler/test_actionlint_handler.vader28
7 files changed, 87 insertions, 0 deletions
diff --git a/ale_linters/yaml/actionlint.vim b/ale_linters/yaml/actionlint.vim
new file mode 100644
index 00000000..e51cf5f0
--- /dev/null
+++ b/ale_linters/yaml/actionlint.vim
@@ -0,0 +1,10 @@
+" Author: bretello <bretello@distruzione.org>
+
+call ale#Set('yaml_actionlint_executable', 'actionlint')
+
+call ale#linter#Define('yaml', {
+\ 'name': 'actionlint',
+\ 'executable': {b -> ale#Var(b, 'yaml_actionlint_executable')},
+\ 'command': function('ale#handlers#actionlint#GetCommand'),
+\ 'callback': 'ale#handlers#actionlint#Handle',
+\})
diff --git a/autoload/ale/handlers/actionlint.vim b/autoload/ale/handlers/actionlint.vim
new file mode 100644
index 00000000..9a6f1909
--- /dev/null
+++ b/autoload/ale/handlers/actionlint.vim
@@ -0,0 +1,24 @@
+function! ale#handlers#actionlint#GetCommand(buffer) abort
+ return '%e --no-color --oneline %t'
+endfunction
+
+function! ale#handlers#actionlint#Handle(buffer, lines) abort
+ " Matches patterns line the following:
+ ".github/workflows/main.yml:19:0: could not parse as YAML: yaml: line 19: mapping values are not allowed in this context [yaml-syntax]
+ let l:pattern = '\v^.*:(\d+):(\d+): (.+) \[(.+)\]$'
+ let l:output = []
+
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
+ let l:item = {
+ \ 'lnum': l:match[1] + 0,
+ \ 'col': l:match[2] + 0,
+ \ 'text': l:match[3],
+ \ 'code': l:match[4],
+ \ 'type': 'E',
+ \}
+
+ call add(l:output, l:item)
+ endfor
+
+ return l:output
+endfunction
diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt
index 0eadde9c..07d71826 100644
--- a/doc/ale-supported-languages-and-tools.txt
+++ b/doc/ale-supported-languages-and-tools.txt
@@ -648,6 +648,7 @@ Notes:
* XML
* `xmllint`
* YAML
+ * `actionlint`
* `circleci`!!
* `prettier`
* `spectral`
diff --git a/doc/ale-yaml.txt b/doc/ale-yaml.txt
index a5da85a5..7c513fe4 100644
--- a/doc/ale-yaml.txt
+++ b/doc/ale-yaml.txt
@@ -3,6 +3,28 @@ ALE YAML Integration *ale-yaml-options*
===============================================================================
+actionlint *ale-yaml-actionlint*
+
+Website: https://github.com/rhysd/actionlint
+
+
+Installation
+-------------------------------------------------------------------------------
+
+See installation guide: https://github.com/rhysd/actionlint#quick-start
+
+Options
+-------------------------------------------------------------------------------
+
+g:ale_yaml_actionlint_executable *g:ale_yaml_actionlint_executable*
+ *b:ale_yaml_actionlint_executable*
+ Type: |String|
+ Default: `'actionlint'`
+
+ This variable can be set to change the path to actionlint.
+
+
+===============================================================================
circleci *ale-yaml-circleci*
Website: https://circleci.com/docs/2.0/local-cli
diff --git a/doc/ale.txt b/doc/ale.txt
index 103fc3ea..0c1de7be 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -3272,6 +3272,7 @@ documented in additional help files.
xml.....................................|ale-xml-options|
xmllint...............................|ale-xml-xmllint|
yaml....................................|ale-yaml-options|
+ actionlint............................|ale-yaml-actionlint|
circleci..............................|ale-yaml-circleci|
prettier..............................|ale-yaml-prettier|
spectral..............................|ale-yaml-spectral|
diff --git a/supported-tools.md b/supported-tools.md
index 88647398..a3b9fcb6 100644
--- a/supported-tools.md
+++ b/supported-tools.md
@@ -657,6 +657,7 @@ formatting.
* XML
* [xmllint](http://xmlsoft.org/xmllint.html)
* YAML
+ * [actionlint](https://github.com/rhysd/actionlint)
* [circleci](https://circleci.com/docs/2.0/local-cli) :floppy_disk:
* [prettier](https://github.com/prettier/prettier)
* [spectral](https://github.com/stoplightio/spectral)
diff --git a/test/handler/test_actionlint_handler.vader b/test/handler/test_actionlint_handler.vader
new file mode 100644
index 00000000..557cff02
--- /dev/null
+++ b/test/handler/test_actionlint_handler.vader
@@ -0,0 +1,28 @@
+Before:
+ runtime! ale/handlers/actionlint.vim
+
+After:
+ call ale#linter#Reset()
+
+Execute(Problems should be parsed correctly for actionlint):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 2,
+ \ 'col': 1,
+ \ 'type': 'E',
+ \ 'text': '"jobs" section is missing in workflow',
+ \ 'code': 'syntax-check',
+ \ },
+ \ {
+ \ 'lnum': 56,
+ \ 'col': 23,
+ \ 'type': 'E',
+ \ 'text': 'property "unknown_input" is not defined in object type {input7: bool; input0: any; input1: any; input2: string; input3: any; input4: any; input5: number; input6: number}',
+ \ 'code': 'expression',
+ \ },
+ \ ],
+ \ ale#handlers#actionlint#Handle(bufnr(''), [
+ \ '.codecov.yaml:2:1: "jobs" section is missing in workflow [syntax-check]',
+ \ 'workflow_call_event.yaml:56:23: property "unknown_input" is not defined in object type {input7: bool; input0: any; input1: any; input2: string; input3: any; input4: any; input5: number; input6: number} [expression]',
+ \ ])