mirror of
https://github.com/adrienverge/yamllint.git
synced 2025-02-25 18:55:20 -06:00
fix: code example indents
Signed-off-by: gardar <gardar@users.noreply.github.com>
This commit is contained in:
@@ -9,15 +9,15 @@ Here is an example, to add in your .pre-commit-config.yaml
|
|||||||
|
|
||||||
.. code:: yaml
|
.. code:: yaml
|
||||||
|
|
||||||
---
|
---
|
||||||
# Update the rev variable with the release version that you want, from the yamllint repo
|
# Update the rev variable with the release version that you want, from the yamllint repo
|
||||||
# You can pass your custom .yamllint with args attribute.
|
# You can pass your custom .yamllint with args attribute.
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/adrienverge/yamllint.git
|
- repo: https://github.com/adrienverge/yamllint.git
|
||||||
rev: v1.29.0
|
rev: v1.29.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: yamllint
|
- id: yamllint
|
||||||
args: [--strict, -c=/path/to/.yamllint]
|
args: [--strict, -c=/path/to/.yamllint]
|
||||||
|
|
||||||
|
|
||||||
Integration with GitHub Actions
|
Integration with GitHub Actions
|
||||||
@@ -32,20 +32,20 @@ A minimal example workflow using GitHub Actions:
|
|||||||
|
|
||||||
.. code:: yaml
|
.. code:: yaml
|
||||||
|
|
||||||
---
|
---
|
||||||
on: push # yamllint disable-line rule:truthy
|
on: push # yamllint disable-line rule:truthy
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
lint:
|
lint:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Install yamllint
|
- name: Install yamllint
|
||||||
run: pip install yamllint
|
run: pip install yamllint
|
||||||
|
|
||||||
- name: Lint YAML files
|
- name: Lint YAML files
|
||||||
run: yamllint .
|
run: yamllint .
|
||||||
|
|
||||||
Integration with GitLab
|
Integration with GitLab
|
||||||
------------------------
|
------------------------
|
||||||
@@ -57,38 +57,38 @@ report.
|
|||||||
|
|
||||||
.. code:: yaml
|
.. code:: yaml
|
||||||
|
|
||||||
---
|
---
|
||||||
lint:
|
lint:
|
||||||
stage: lint
|
stage: lint
|
||||||
script:
|
script:
|
||||||
- pip install yamllint
|
- pip install yamllint
|
||||||
- mkdir reports
|
- mkdir reports
|
||||||
- >
|
- >
|
||||||
yamllint -f parsable . | tee >(awk '
|
yamllint -f parsable . | tee >(awk '
|
||||||
BEGIN {FS = ":"; ORS="\n"; first=1}
|
BEGIN {FS = ":"; ORS="\n"; first=1}
|
||||||
{
|
{
|
||||||
gsub(/^[ \t]+|[ \t]+$|"/, "", $4);
|
gsub(/^[ \t]+|[ \t]+$|"/, "", $4);
|
||||||
match($4, /^\[(warning|error)\](.*)\((.*)\)$/, a);
|
match($4, /^\[(warning|error)\](.*)\((.*)\)$/, a);
|
||||||
sev = (a[1] == "error" ? "major" : "minor");
|
sev = (a[1] == "error" ? "major" : "minor");
|
||||||
if (first) {
|
if (first) {
|
||||||
first=0;
|
first=0;
|
||||||
printf("[");
|
printf("[");
|
||||||
} else {
|
} else {
|
||||||
printf(",");
|
printf(",");
|
||||||
}
|
}
|
||||||
printf("{\"location\":{\"path\":\"%s\",\"lines\":{\"begin\":%s",\
|
printf("{\"location\":{\"path\":\"%s\",\"lines\":{\"begin\":%s",\
|
||||||
"\"end\":%s}},\"severity\":\"%s\",\"check_name\":\"%s\","\
|
"\"end\":%s}},\"severity\":\"%s\",\"check_name\":\"%s\","\
|
||||||
"\"categories\":[\"Style\"],\"type\":\"issue\","\
|
"\"categories\":[\"Style\"],\"type\":\"issue\","\
|
||||||
"\"description\":\"%s\"}", $1, $2, $3, sev, a[3], a[2]);
|
"\"description\":\"%s\"}", $1, $2, $3, sev, a[3], a[2]);
|
||||||
}
|
}
|
||||||
END { if (!first) printf("]\n"); }' > reports/codequality.json)
|
END { if (!first) printf("]\n"); }' > reports/codequality.json)
|
||||||
artifacts:
|
artifacts:
|
||||||
when: always
|
when: always
|
||||||
paths:
|
paths:
|
||||||
- reports
|
- reports
|
||||||
expire_in: 1 week
|
expire_in: 1 week
|
||||||
reports:
|
reports:
|
||||||
codequality: reports/codequality.json
|
codequality: reports/codequality.json
|
||||||
|
|
||||||
Integration with Arcanist
|
Integration with Arcanist
|
||||||
-------------------------
|
-------------------------
|
||||||
@@ -98,13 +98,13 @@ You can configure yamllint to run on ``arc lint``. Here is an example
|
|||||||
|
|
||||||
.. code:: json
|
.. code:: json
|
||||||
|
|
||||||
{
|
{
|
||||||
"linters": {
|
"linters": {
|
||||||
"yamllint": {
|
"yamllint": {
|
||||||
"type": "script-and-regex",
|
"type": "script-and-regex",
|
||||||
"script-and-regex.script": "yamllint",
|
"script-and-regex.script": "yamllint",
|
||||||
"script-and-regex.regex": "/^(?P<line>\\d+):(?P<offset>\\d+) +(?P<severity>warning|error) +(?P<message>.*) +\\((?P<name>.*)\\)$/m",
|
"script-and-regex.regex": "/^(?P<line>\\d+):(?P<offset>\\d+) +(?P<severity>warning|error) +(?P<message>.*) +\\((?P<name>.*)\\)$/m",
|
||||||
"include": "(\\.(yml|yaml)$)"
|
"include": "(\\.(yml|yaml)$)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user