mirror of
https://github.com/ibiqlik/action-yamllint.git
synced 2024-11-24 15:21:04 -05:00
Save yamllint output/log to a file (#23)
This commit is contained in:
parent
0d4bd66960
commit
81e214fd48
4 changed files with 88 additions and 22 deletions
27
.github/workflows/lint.yml
vendored
27
.github/workflows/lint.yml
vendored
|
@ -5,7 +5,12 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: lint with config
|
|
||||||
|
- name: Get yamllint version
|
||||||
|
run: yamllint --version
|
||||||
|
|
||||||
|
- id: lint-with-config
|
||||||
|
name: lint with config
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
file_or_dir: test
|
file_or_dir: test
|
||||||
|
@ -18,7 +23,8 @@ jobs:
|
||||||
trailing-spaces:
|
trailing-spaces:
|
||||||
level: warning
|
level: warning
|
||||||
|
|
||||||
- name: lint all - no warnings (continue on error)
|
- id: lint-all-no-warnings
|
||||||
|
name: lint all - no warnings (continue on error)
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
|
@ -26,13 +32,26 @@ jobs:
|
||||||
strict: true
|
strict: true
|
||||||
no_warnings: true
|
no_warnings: true
|
||||||
|
|
||||||
- name: lint all (continue on error)
|
- id: lint-all-continue
|
||||||
|
name: lint all (continue on error)
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
file_or_dir: test
|
file_or_dir: test
|
||||||
strict: true
|
strict: true
|
||||||
|
format: standard
|
||||||
|
|
||||||
- name: default lint all (continue on error)
|
- id: default-lint-all
|
||||||
|
name: default lint all (continue on error)
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
uses: ./
|
uses: ./
|
||||||
|
|
||||||
|
- id: print-output
|
||||||
|
if: always()
|
||||||
|
name: Print output
|
||||||
|
run: |
|
||||||
|
echo ${{ steps.lint-with-config.outputs.logfile }}
|
||||||
|
cat ${{ steps.lint-with-config.outputs.logfile }}
|
||||||
|
|
||||||
|
echo ${{ steps.lint-all-continue.outputs.logfile }}
|
||||||
|
cat ${{ steps.lint-all-continue.outputs.logfile }}
|
||||||
|
|
63
README.md
63
README.md
|
@ -1,6 +1,6 @@
|
||||||
# GitHub YAMLlint
|
# GitHub YAMLlint
|
||||||
|
|
||||||
This action executes `yamllint` (https://github.com/adrienverge/yamllint) against file(s) or folder
|
This action executes `yamllint` (https://github.com/adrienverge/yamllint) against files or folder
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ Simple as:
|
||||||
- uses: ibiqlik/action-yamllint@v3
|
- uses: ibiqlik/action-yamllint@v3
|
||||||
```
|
```
|
||||||
|
|
||||||
### Optional parameters
|
### Optional input 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)
|
||||||
|
@ -23,37 +23,47 @@ Simple as:
|
||||||
- `strict` - Return non-zero exit code on warnings as well as errors `[true,false] (default: false)`
|
- `strict` - Return non-zero exit code on warnings as well as errors `[true,false] (default: false)`
|
||||||
- `no_warnings` - Output only error level problems `[true,false] (default: false)`
|
- `no_warnings` - Output only error level problems `[true,false] (default: false)`
|
||||||
|
|
||||||
**Note:** If `.yamllint` configuration file exists in your root folder, yamllint will automatically use it.
|
**Note:** If `.yamllint` configuration file exists in your root folder, yamllint automatically uses it.
|
||||||
|
|
||||||
|
### Outputs
|
||||||
|
|
||||||
|
`logfile` - Path to yamllint log file
|
||||||
|
|
||||||
|
`${{ steps.<step>.outputs.logfile }}`
|
||||||
|
|
||||||
|
**Note:** Each yamllint run (for example if you define multiple yamllint steps) has its own log
|
||||||
|
|
||||||
### Example usage in workflow
|
### Example usage in workflow
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
|
---
|
||||||
name: Yaml Lint
|
name: Yaml Lint
|
||||||
on: [push]
|
on: [push] # yamllint disable-line rule:truthy
|
||||||
jobs:
|
jobs:
|
||||||
lintAllTheThings:
|
lintAllTheThings:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v2
|
||||||
- name: yaml-lint
|
- name: yaml-lint
|
||||||
uses: ibiqlik/action-yamllint@v3
|
uses: ibiqlik/action-yamllint@v3
|
||||||
with:
|
with:
|
||||||
file_or_dir: myfolder/*values*.yaml
|
file_or_dir: myfolder/*values*.yaml
|
||||||
config_file: .yamllint.yml
|
config_file: .yamllint.yml
|
||||||
```
|
```
|
||||||
|
|
||||||
Or just simply check all yaml files in the repository:
|
Or just simply lint all yaml files in the repository:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
|
---
|
||||||
name: Yaml Lint
|
name: Yaml Lint
|
||||||
on: [push]
|
on: [push] # yamllint disable-line rule:truthy
|
||||||
jobs:
|
jobs:
|
||||||
lintAllTheThings:
|
lintAllTheThings:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: yaml-lint
|
- name: yaml-lint
|
||||||
uses: ibiqlik/action-yamllint@v3
|
uses: ibiqlik/action-yamllint@v3
|
||||||
```
|
```
|
||||||
|
|
||||||
Config data examples:
|
Config data examples:
|
||||||
|
@ -73,3 +83,26 @@ config_data: |
|
||||||
trailing-spaces:
|
trailing-spaces:
|
||||||
level: warning
|
level: warning
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Use output to save/upload the log in artifact. Note, you must have `id` in the step running the yamllint action.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
---
|
||||||
|
name: Yaml Lint
|
||||||
|
on: [push] # yamllint disable-line rule:truthy
|
||||||
|
jobs:
|
||||||
|
lintAllTheThings:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- id: yaml-lint
|
||||||
|
uses: ibiqlik/action-yamllint@v3
|
||||||
|
|
||||||
|
- run: echo ${{ steps.yaml-lint.outputs.logfile }}
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v2
|
||||||
|
if: always()
|
||||||
|
with:
|
||||||
|
name: yamllint-logfile
|
||||||
|
path: ${{ steps.yaml-lint.outputs.logfile }}
|
||||||
|
```
|
||||||
|
|
10
action.yml
10
action.yml
|
@ -25,10 +25,18 @@ inputs:
|
||||||
required: false
|
required: false
|
||||||
default: "false"
|
default: "false"
|
||||||
|
|
||||||
|
outputs:
|
||||||
|
logfile:
|
||||||
|
description: "Yamllint log file path"
|
||||||
|
value: ${{ steps.yamllint.outputs.logfile }}
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: 'composite'
|
using: 'composite'
|
||||||
steps:
|
steps:
|
||||||
- run: ${{ github.action_path }}/entrypoint.sh
|
- id: yamllint
|
||||||
|
run: |
|
||||||
|
# export LOGFILE=$(mktemp yamllint-XXXXXX)
|
||||||
|
${{ github.action_path }}/entrypoint.sh
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
INPUT_FILE_OR_DIR: ${{ inputs.file_or_dir }}
|
INPUT_FILE_OR_DIR: ${{ inputs.file_or_dir }}
|
||||||
|
|
|
@ -1,9 +1,15 @@
|
||||||
#!/bin/bash -l
|
#!/bin/bash -l
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
echo "======================"
|
echo "======================"
|
||||||
echo "= Linting YAML files ="
|
echo "= Linting YAML files ="
|
||||||
echo "======================"
|
echo "======================"
|
||||||
|
|
||||||
|
if [[ -z "$LOGFILE" ]]; then
|
||||||
|
LOGFILE=$(mktemp yamllint-XXXXXX)
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -n "$INPUT_CONFIG_FILE" ]]; then
|
if [[ -n "$INPUT_CONFIG_FILE" ]]; then
|
||||||
options+=(-c "$INPUT_CONFIG_FILE")
|
options+=(-c "$INPUT_CONFIG_FILE")
|
||||||
fi
|
fi
|
||||||
|
@ -25,10 +31,10 @@ fi
|
||||||
# Enable globstar so ** globs recursively
|
# Enable globstar so ** globs recursively
|
||||||
shopt -s globstar
|
shopt -s globstar
|
||||||
|
|
||||||
yamllint "${options[@]}" ${INPUT_FILE_OR_DIR:-.}
|
yamllint "${options[@]}" ${INPUT_FILE_OR_DIR:-.} | tee -a "$LOGFILE"
|
||||||
|
|
||||||
exitcode=$?
|
exitcode=$?
|
||||||
|
|
||||||
shopt -u globstar
|
shopt -u globstar
|
||||||
|
echo "::set-output name=logfile::$(realpath ${LOGFILE})"
|
||||||
|
|
||||||
exit $exitcode
|
exit $exitcode
|
||||||
|
|
Loading…
Reference in a new issue