mirror of
https://github.com/ibiqlik/action-yamllint.git
synced 2024-11-23 23:01:03 -05:00
Use yamllint github format to set file annotations on errors & warnings (#12)
* Use github format output * Add few tests * Config yamllint
This commit is contained in:
parent
7f68ad7a33
commit
76fdac3839
9 changed files with 94 additions and 13 deletions
26
.github/workflows/lint.yml
vendored
Normal file
26
.github/workflows/lint.yml
vendored
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
name: Test Action
|
||||||
|
on: pull_request
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: lint with config
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
file_or_dir: test
|
||||||
|
config_data: |
|
||||||
|
extends: default
|
||||||
|
ignore: nok.yaml
|
||||||
|
rules:
|
||||||
|
new-line-at-end-of-file:
|
||||||
|
level: warning
|
||||||
|
trailing-spaces:
|
||||||
|
level: warning
|
||||||
|
|
||||||
|
- name: lint all (but pass)
|
||||||
|
continue-on-error: true
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
file_or_dir: test
|
||||||
|
strict: true
|
11
.yamllint
Normal file
11
.yamllint
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
---
|
||||||
|
extends: default
|
||||||
|
|
||||||
|
rules:
|
||||||
|
line-length: disable
|
||||||
|
new-lines:
|
||||||
|
type: unix
|
||||||
|
new-line-at-end-of-file:
|
||||||
|
level: warning
|
||||||
|
trailing-spaces:
|
||||||
|
level: warning
|
|
@ -1,6 +1,6 @@
|
||||||
FROM python:3-alpine
|
FROM python:3-alpine
|
||||||
|
|
||||||
RUN pip install yamllint && \
|
RUN pip install 'yamllint>=1.25.0' && \
|
||||||
apk add --no-cache bash && \
|
apk add --no-cache bash && \
|
||||||
rm -rf ~/.cache/pip
|
rm -rf ~/.cache/pip
|
||||||
|
|
||||||
|
|
42
README.md
42
README.md
|
@ -4,17 +4,23 @@ This action executes `yamllint` (https://github.com/adrienverge/yamllint) agains
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
Simple as:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- uses: ibiqlik/action-yamllint@v2
|
||||||
|
```
|
||||||
|
|
||||||
### Optional parameters
|
### Optional parameters
|
||||||
|
|
||||||
- `config_file` - Path to custom configuration
|
- `config_file` - Path to custom configuration
|
||||||
- `config_data` - Custom configuration (as YAML source)
|
- `config_data` - Custom configuration (as YAML source)
|
||||||
- `file_or_dir` - Enter file/folder (space separated), wildcards accepted. Examples:
|
- `file_or_dir` - Enter file/folder (space separated), wildcards accepted. Examples:
|
||||||
- `.` - run against all yaml files in a directory recursively (default)
|
- `.` - run against all yaml files in a directory recursively (default)
|
||||||
- `file1.yaml`
|
- `file1.yaml`
|
||||||
- `file1.yaml file2.yaml`
|
- `file1.yaml file2.yaml`
|
||||||
- `kustomize/**/*.yaml mychart/*values.yaml`
|
- `kustomize/**/*.yaml mychart/*values.yaml`
|
||||||
- `format` - Format for parsing output [parsable,standard,colored,auto] (default: colored)
|
- `format` - Format for parsing output [parsable,standard,colored,github,auto] (default: github)
|
||||||
- `strict` - Return non-zero exit code on warnings as well as errors [true,false]
|
- `strict` - Return non-zero exit code on warnings as well as errors [true,false] (default: false)
|
||||||
|
|
||||||
### Example usage in workflow
|
### Example usage in workflow
|
||||||
|
|
||||||
|
@ -27,7 +33,7 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
- name: yaml-lint
|
- name: yaml-lint
|
||||||
uses: ibiqlik/action-yamllint@v1
|
uses: ibiqlik/action-yamllint@v2
|
||||||
with:
|
with:
|
||||||
file_or_dir: myfolder/*values*.yaml
|
file_or_dir: myfolder/*values*.yaml
|
||||||
config_file: .yamllint.yml
|
config_file: .yamllint.yml
|
||||||
|
@ -44,5 +50,25 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
- name: yaml-lint
|
- name: yaml-lint
|
||||||
uses: ibiqlik/action-yamllint@v1
|
uses: ibiqlik/action-yamllint@v2
|
||||||
|
```
|
||||||
|
|
||||||
|
**Note:** Action will use `.yamllint` as configuration file automatically if it is available in root.
|
||||||
|
|
||||||
|
Config data examples:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# Single line
|
||||||
|
config_data: "{extends: default, rules: {new-line-at-end-of-file: disable}}"
|
||||||
|
```
|
||||||
|
|
||||||
|
``` yaml
|
||||||
|
# Multi line
|
||||||
|
config_data: |
|
||||||
|
extends: default
|
||||||
|
rules:
|
||||||
|
new-line-at-end-of-file:
|
||||||
|
level: warning
|
||||||
|
trailing-spaces:
|
||||||
|
level: warning
|
||||||
```
|
```
|
||||||
|
|
|
@ -5,7 +5,7 @@ author: 'ibiqlik'
|
||||||
inputs:
|
inputs:
|
||||||
file_or_dir:
|
file_or_dir:
|
||||||
description: 'File(s) or Directory, separate by space if multiple files or folder are specified'
|
description: 'File(s) or Directory, separate by space if multiple files or folder are specified'
|
||||||
required: true
|
required: false
|
||||||
config_file:
|
config_file:
|
||||||
description: 'Path to custom configuration'
|
description: 'Path to custom configuration'
|
||||||
required: false
|
required: false
|
||||||
|
@ -13,9 +13,9 @@ inputs:
|
||||||
description: 'Custom configuration (as YAML source)'
|
description: 'Custom configuration (as YAML source)'
|
||||||
required: false
|
required: false
|
||||||
format:
|
format:
|
||||||
description: 'Format for parsing output [parsable,standard,colored,auto]'
|
description: 'Format for parsing output [parsable,standard,colored,github,auto]'
|
||||||
required: false
|
required: false
|
||||||
default: "colored"
|
default: "github"
|
||||||
strict:
|
strict:
|
||||||
description: 'Return non-zero exit code on warnings as well as errors'
|
description: 'Return non-zero exit code on warnings as well as errors'
|
||||||
required: false
|
required: false
|
||||||
|
|
5
test/nok.yaml
Normal file
5
test/nok.yaml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
this:
|
||||||
|
is: Not
|
||||||
|
a valid
|
||||||
|
- yaml
|
||||||
|
file
|
6
test/ok.yaml
Normal file
6
test/ok.yaml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
this:
|
||||||
|
is: a
|
||||||
|
valid:
|
||||||
|
- yaml
|
||||||
|
- file
|
7
test/warning.yaml
Normal file
7
test/warning.yaml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
this:
|
||||||
|
is: a
|
||||||
|
valid:
|
||||||
|
- yaml
|
||||||
|
- file
|
||||||
|
with: warnings
|
Loading…
Reference in a new issue