add yaml actionlint support (github actions) (#4173)

Co-authored-by: bretello <bretello@distruzione.org>
This commit is contained in:
bretello 2022-05-03 03:03:05 +02:00 committed by GitHub
parent 56399106fc
commit c694a24188
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 87 additions and 0 deletions

View File

@ -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',
\})

View File

@ -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

View File

@ -648,6 +648,7 @@ Notes:
* XML
* `xmllint`
* YAML
* `actionlint`
* `circleci`!!
* `prettier`
* `spectral`

View File

@ -2,6 +2,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*

View File

@ -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|

View File

@ -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)

View File

@ -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]',
\ ])