mirror of
https://github.com/ibiqlik/action-yamllint.git
synced 2024-11-21 13:51:05 -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
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: lint with config
|
||||
|
||||
- name: Get yamllint version
|
||||
run: yamllint --version
|
||||
|
||||
- id: lint-with-config
|
||||
name: lint with config
|
||||
uses: ./
|
||||
with:
|
||||
file_or_dir: test
|
||||
|
@ -18,7 +23,8 @@ jobs:
|
|||
trailing-spaces:
|
||||
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
|
||||
uses: ./
|
||||
with:
|
||||
|
@ -26,13 +32,26 @@ jobs:
|
|||
strict: true
|
||||
no_warnings: true
|
||||
|
||||
- name: lint all (continue on error)
|
||||
- id: lint-all-continue
|
||||
name: lint all (continue on error)
|
||||
continue-on-error: true
|
||||
uses: ./
|
||||
with:
|
||||
file_or_dir: test
|
||||
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
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
|
@ -10,7 +10,7 @@ Simple as:
|
|||
- uses: ibiqlik/action-yamllint@v3
|
||||
```
|
||||
|
||||
### Optional parameters
|
||||
### Optional input parameters
|
||||
|
||||
- `config_file` - Path to custom configuration
|
||||
- `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)`
|
||||
- `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
|
||||
|
||||
```yaml
|
||||
---
|
||||
name: Yaml Lint
|
||||
on: [push]
|
||||
on: [push] # yamllint disable-line rule:truthy
|
||||
jobs:
|
||||
lintAllTheThings:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: yaml-lint
|
||||
uses: ibiqlik/action-yamllint@v3
|
||||
with:
|
||||
file_or_dir: myfolder/*values*.yaml
|
||||
config_file: .yamllint.yml
|
||||
- uses: actions/checkout@v2
|
||||
- name: yaml-lint
|
||||
uses: ibiqlik/action-yamllint@v3
|
||||
with:
|
||||
file_or_dir: myfolder/*values*.yaml
|
||||
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
|
||||
---
|
||||
name: Yaml Lint
|
||||
on: [push]
|
||||
on: [push] # yamllint disable-line rule:truthy
|
||||
jobs:
|
||||
lintAllTheThings:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: yaml-lint
|
||||
uses: ibiqlik/action-yamllint@v3
|
||||
- uses: actions/checkout@v2
|
||||
- name: yaml-lint
|
||||
uses: ibiqlik/action-yamllint@v3
|
||||
```
|
||||
|
||||
Config data examples:
|
||||
|
@ -73,3 +83,26 @@ config_data: |
|
|||
trailing-spaces:
|
||||
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
|
||||
default: "false"
|
||||
|
||||
outputs:
|
||||
logfile:
|
||||
description: "Yamllint log file path"
|
||||
value: ${{ steps.yamllint.outputs.logfile }}
|
||||
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- run: ${{ github.action_path }}/entrypoint.sh
|
||||
- id: yamllint
|
||||
run: |
|
||||
# export LOGFILE=$(mktemp yamllint-XXXXXX)
|
||||
${{ github.action_path }}/entrypoint.sh
|
||||
shell: bash
|
||||
env:
|
||||
INPUT_FILE_OR_DIR: ${{ inputs.file_or_dir }}
|
||||
|
|
|
@ -1,9 +1,15 @@
|
|||
#!/bin/bash -l
|
||||
# shellcheck disable=SC2086
|
||||
set -o pipefail
|
||||
|
||||
echo "======================"
|
||||
echo "= Linting YAML files ="
|
||||
echo "======================"
|
||||
|
||||
if [[ -z "$LOGFILE" ]]; then
|
||||
LOGFILE=$(mktemp yamllint-XXXXXX)
|
||||
fi
|
||||
|
||||
if [[ -n "$INPUT_CONFIG_FILE" ]]; then
|
||||
options+=(-c "$INPUT_CONFIG_FILE")
|
||||
fi
|
||||
|
@ -25,10 +31,10 @@ fi
|
|||
# Enable globstar so ** globs recursively
|
||||
shopt -s globstar
|
||||
|
||||
yamllint "${options[@]}" ${INPUT_FILE_OR_DIR:-.}
|
||||
|
||||
yamllint "${options[@]}" ${INPUT_FILE_OR_DIR:-.} | tee -a "$LOGFILE"
|
||||
exitcode=$?
|
||||
|
||||
shopt -u globstar
|
||||
echo "::set-output name=logfile::$(realpath ${LOGFILE})"
|
||||
|
||||
exit $exitcode
|
||||
|
|
Loading…
Reference in a new issue