mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-07 13:14:29 +08:00
Run actionlint by default on GitHub files
Detect paths containing .github as a directory for running actionlint by default on YAML filetypes.
This commit is contained in:
@@ -5,6 +5,11 @@ call ale#Set('yaml_actionlint_executable', 'actionlint')
|
|||||||
call ale#Set('yaml_actionlint_options', '')
|
call ale#Set('yaml_actionlint_options', '')
|
||||||
|
|
||||||
function! ale_linters#yaml#actionlint#GetCommand(buffer) abort
|
function! ale_linters#yaml#actionlint#GetCommand(buffer) abort
|
||||||
|
" Only execute actionlint on YAML files in /.github/ paths.
|
||||||
|
if expand('#' . a:buffer . ':p') !~# '\v[/\\]\.github[/\\]'
|
||||||
|
return ''
|
||||||
|
endif
|
||||||
|
|
||||||
let l:options = ale#Var(a:buffer, 'yaml_actionlint_options')
|
let l:options = ale#Var(a:buffer, 'yaml_actionlint_options')
|
||||||
|
|
||||||
if l:options !~# '-no-color'
|
if l:options !~# '-no-color'
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ let s:default_ale_linters = {
|
|||||||
\ 'vue': ['eslint', 'vls'],
|
\ 'vue': ['eslint', 'vls'],
|
||||||
\ 'zsh': ['shell'],
|
\ 'zsh': ['shell'],
|
||||||
\ 'v': ['v'],
|
\ 'v': ['v'],
|
||||||
\ 'yaml': ['spectral', 'yaml-language-server', 'yamllint'],
|
\ 'yaml': ['actionlint', 'spectral', 'yaml-language-server', 'yamllint'],
|
||||||
\}
|
\}
|
||||||
|
|
||||||
" Testing/debugging helper to unload all linters.
|
" Testing/debugging helper to unload all linters.
|
||||||
|
|||||||
@@ -1670,7 +1670,7 @@ g:ale_linters *g:ale_linters*
|
|||||||
\ 'vue': ['eslint', 'vls'],
|
\ 'vue': ['eslint', 'vls'],
|
||||||
\ 'zsh': ['shell'],
|
\ 'zsh': ['shell'],
|
||||||
\ 'v': ['v'],
|
\ 'v': ['v'],
|
||||||
\ 'yaml': ['spectral', 'yaml-language-server', 'yamllint'],
|
\ 'yaml': ['actionlint', 'spectral', 'yaml-language-server', 'yamllint'],
|
||||||
\}
|
\}
|
||||||
<
|
<
|
||||||
This option can be used to enable only a particular set of linters for a
|
This option can be used to enable only a particular set of linters for a
|
||||||
|
|||||||
@@ -720,7 +720,7 @@ formatting.
|
|||||||
* XML
|
* XML
|
||||||
* [xmllint](http://xmlsoft.org/xmllint.html)
|
* [xmllint](http://xmlsoft.org/xmllint.html)
|
||||||
* YAML
|
* YAML
|
||||||
* [actionlint](https://github.com/rhysd/actionlint) :warning:
|
* [actionlint](https://github.com/rhysd/actionlint)
|
||||||
* [circleci](https://circleci.com/docs/2.0/local-cli) :floppy_disk: :warning:
|
* [circleci](https://circleci.com/docs/2.0/local-cli) :floppy_disk: :warning:
|
||||||
* [gitlablint](https://github.com/elijah-roberts/gitlab-lint)
|
* [gitlablint](https://github.com/elijah-roberts/gitlab-lint)
|
||||||
* [prettier](https://github.com/prettier/prettier)
|
* [prettier](https://github.com/prettier/prettier)
|
||||||
|
|||||||
43
test/handler/test_actionlint_handler.vader
Normal file
43
test/handler/test_actionlint_handler.vader
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
Before:
|
||||||
|
runtime ale_linters/yaml/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_linters#yaml#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]',
|
||||||
|
\ ])
|
||||||
|
|
||||||
|
Execute(Shellcheck issues should be reported at the line they appear):
|
||||||
|
AssertEqual
|
||||||
|
\ [
|
||||||
|
\ {
|
||||||
|
\ 'lnum': 19,
|
||||||
|
\ 'col': 9,
|
||||||
|
\ 'type': 'E',
|
||||||
|
\ 'text': 'Double quote to prevent globbing and word splitting',
|
||||||
|
\ 'code': 'shellcheck SC2086',
|
||||||
|
\ },
|
||||||
|
\ ],
|
||||||
|
\ ale_linters#yaml#actionlint#Handle(bufnr(''), [
|
||||||
|
\ 'validate.yml:19:9: shellcheck reported issue in this script: SC2086:info:1:15: Double quote to prevent globbing and word splitting [shellcheck]'
|
||||||
|
\ ])
|
||||||
@@ -1,57 +1,20 @@
|
|||||||
Before:
|
Before:
|
||||||
call ale#assert#SetUpLinterTest('yaml', 'actionlint')
|
call ale#assert#SetUpLinterTest('yaml', 'actionlint')
|
||||||
|
call ale#test#SetFilename('/.github/file.yml')
|
||||||
|
|
||||||
After:
|
After:
|
||||||
call ale#assert#TearDownLinterTest()
|
call ale#assert#TearDownLinterTest()
|
||||||
|
|
||||||
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_linters#yaml#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]',
|
|
||||||
\ ])
|
|
||||||
|
|
||||||
Execute(Shellcheck issues should be reported at the line they appear):
|
|
||||||
AssertEqual
|
|
||||||
\ [
|
|
||||||
\ {
|
|
||||||
\ 'lnum': 19,
|
|
||||||
\ 'col': 9,
|
|
||||||
\ 'type': 'E',
|
|
||||||
\ 'text': 'Double quote to prevent globbing and word splitting',
|
|
||||||
\ 'code': 'shellcheck SC2086',
|
|
||||||
\ },
|
|
||||||
\ ],
|
|
||||||
\ ale_linters#yaml#actionlint#Handle(bufnr(''), [
|
|
||||||
\ 'validate.yml:19:9: shellcheck reported issue in this script: SC2086:info:1:15: Double quote to prevent globbing and word splitting [shellcheck]'
|
|
||||||
\ ])
|
|
||||||
|
|
||||||
Execute(Command should always have -no-color, -oneline and - options):
|
Execute(Command should always have -no-color, -oneline and - options):
|
||||||
let g:ale_yaml_actionlint_options = ''
|
let g:ale_yaml_actionlint_options = ''
|
||||||
|
|
||||||
AssertEqual
|
AssertLinter 'actionlint', ale#Escape('actionlint') . ' -no-color -oneline - '
|
||||||
\ '%e -no-color -oneline - ',
|
|
||||||
\ ale_linters#yaml#actionlint#GetCommand(bufnr(''))
|
|
||||||
|
|
||||||
Execute(Options should be added to command):
|
Execute(Options should be added to command):
|
||||||
let g:ale_yaml_actionlint_options = '-shellcheck= -pyflakes='
|
let g:ale_yaml_actionlint_options = '-shellcheck= -pyflakes='
|
||||||
|
|
||||||
AssertEqual
|
AssertLinter 'actionlint',
|
||||||
\ '%e -shellcheck= -pyflakes= -no-color -oneline - ',
|
\ ale#Escape('actionlint') . ' -shellcheck= -pyflakes= -no-color -oneline - '
|
||||||
\ ale_linters#yaml#actionlint#GetCommand(bufnr(''))
|
|
||||||
|
Execute(actionlint not run on files outside of /.github/ paths):
|
||||||
|
call ale#test#SetFilename('/something-else/file.yml')
|
||||||
|
|||||||
@@ -135,3 +135,6 @@ Execute(The defaults for the vader filetype should be correct):
|
|||||||
Execute(Default aliases for React should be defined):
|
Execute(Default aliases for React should be defined):
|
||||||
AssertEqual ['javascript', 'jsx'], ale#linter#ResolveFiletype('javascriptreact')
|
AssertEqual ['javascript', 'jsx'], ale#linter#ResolveFiletype('javascriptreact')
|
||||||
AssertEqual ['typescript', 'tsx'], ale#linter#ResolveFiletype('typescriptreact')
|
AssertEqual ['typescript', 'tsx'], ale#linter#ResolveFiletype('typescriptreact')
|
||||||
|
|
||||||
|
Execute(The defaults for the yaml filetype should be correct):
|
||||||
|
AssertEqual ['actionlint', 'spectral', 'yaml-language-server', 'yamllint'], GetLinterNames('yaml')
|
||||||
|
|||||||
Reference in New Issue
Block a user