forked from dense-analysis/ale
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add yaml actionlint support (github actions) (dense-analysis#4173)
Co-authored-by: bretello <bretello@distruzione.org>
- Loading branch information
Showing
7 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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', | ||
\}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -648,6 +648,7 @@ Notes: | |
* XML | ||
* `xmllint` | ||
* YAML | ||
* `actionlint` | ||
* `circleci`!! | ||
* `prettier` | ||
* `spectral` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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]', | ||
\ ]) |