From 3eff9a2d581311905f71a98a67b6391a561d5517 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Tue, 14 May 2024 21:07:17 +0200 Subject: Adding upstream version 1.35.1. Signed-off-by: Daniel Baumann --- docs/conf.py | 8 ++-- docs/disable_with_comments.rst | 18 ++++---- docs/integration.rst | 102 +++++++++++++++++++++++++++++------------ docs/requirements.txt | 1 + 4 files changed, 86 insertions(+), 43 deletions(-) create mode 100644 docs/requirements.txt (limited to 'docs') diff --git a/docs/conf.py b/docs/conf.py index 2c40177..8a03b2f 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,17 +1,17 @@ # yamllint documentation build configuration file, created by # sphinx-quickstart on Thu Jan 21 21:18:52 2016. -import sys import os +import sys from unittest.mock import MagicMock sys.path.insert(0, os.path.abspath('..')) - -from yamllint import __copyright__, APP_NAME, APP_VERSION # noqa +from yamllint import __copyright__, APP_NAME, APP_VERSION # noqa: I001, E402 # -- General configuration ------------------------------------------------ extensions = [ + 'sphinx_rtd_theme', 'sphinx.ext.autodoc', ] @@ -29,7 +29,7 @@ pygments_style = 'sphinx' # -- Options for HTML output ---------------------------------------------- -html_theme = 'default' +html_theme = 'sphinx_rtd_theme' htmlhelp_basename = 'yamllintdoc' diff --git a/docs/disable_with_comments.rst b/docs/disable_with_comments.rst index a973da6..6fcd221 100644 --- a/docs/disable_with_comments.rst +++ b/docs/disable_with_comments.rst @@ -12,11 +12,11 @@ line above. For instance: # The following mapping contains the same key twice, # but I know what I'm doing: - key: value 1 - key: value 2 # yamllint disable-line rule:key-duplicates + - key: value 1 + key: value 2 # yamllint disable-line rule:key-duplicates - This line is waaaaaaaaaay too long but yamllint will not report anything about it. # yamllint disable-line rule:line-length - This line will be checked by yamllint. + - This line will be checked by yamllint. or: @@ -24,13 +24,13 @@ or: # The following mapping contains the same key twice, # but I know what I'm doing: - key: value 1 - # yamllint disable-line rule:key-duplicates - key: value 2 + - key: value 1 + # yamllint disable-line rule:key-duplicates + key: value 2 # yamllint disable-line rule:line-length - This line is waaaaaaaaaay too long but yamllint will not report anything about it. - This line will be checked by yamllint. + - This line will be checked by yamllint. It is possible, although not recommend, to disabled **all** rules for a specific line: @@ -90,8 +90,8 @@ For instance: # yamllint disable-file # The following mapping contains the same key twice, but I know what I'm doing: - key: value 1 - key: value 2 + - key: value 1 + key: value 2 - This line is waaaaaaaaaay too long but yamllint will not report anything about it. diff --git a/docs/integration.rst b/docs/integration.rst index 9a6a935..e805667 100644 --- a/docs/integration.rst +++ b/docs/integration.rst @@ -9,15 +9,15 @@ Here is an example, to add in your .pre-commit-config.yaml .. code:: yaml - --- - # Update the rev variable with the release version that you want, from the yamllint repo - # You can pass your custom .yamllint with args attribute. - repos: - - repo: https://github.com/adrienverge/yamllint.git - rev: v1.29.0 - hooks: - - id: yamllint - args: [--strict, -c=/path/to/.yamllint] + --- + # Update the rev variable with the release version that you want, from the yamllint repo + # You can pass your custom .yamllint with args attribute. + repos: + - repo: https://github.com/adrienverge/yamllint.git + rev: v1.29.0 + hooks: + - id: yamllint + args: [--strict, -c=/path/to/.yamllint] Integration with GitHub Actions @@ -32,20 +32,62 @@ A minimal example workflow using GitHub Actions: .. code:: yaml - --- - on: push # yamllint disable-line rule:truthy + --- + on: push # yamllint disable-line rule:truthy - jobs: - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 + jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 - - name: Install yamllint - run: pip install yamllint + - name: Install yamllint + run: pip install yamllint - - name: Lint YAML files - run: yamllint . + - name: Lint YAML files + run: yamllint . + +Integration with GitLab +----------------------- + +You can use the following GitLab CI/CD stage to run yamllint and get the +results as a `Code quality (Code Climate) +` report. + +.. code:: yaml + + --- + lint: + stage: lint + script: + - pip install yamllint + - mkdir reports + - > + yamllint -f parsable . | tee >(awk ' + BEGIN {FS = ":"; ORS="\n"; first=1} + { + gsub(/^[ \t]+|[ \t]+$|"/, "", $4); + match($4, /^\[(warning|error)\](.*)\((.*)\)$/, a); + sev = (a[1] == "error" ? "major" : "minor"); + if (first) { + first=0; + printf("["); + } else { + printf(","); + } + printf("{\"location\":{\"path\":\"%s\",\"lines\":{\"begin\":%s",\ + "\"end\":%s}},\"severity\":\"%s\",\"check_name\":\"%s\","\ + "\"categories\":[\"Style\"],\"type\":\"issue\","\ + "\"description\":\"%s\"}", $1, $2, $3, sev, a[3], a[2]); + } + END { if (!first) printf("]\n"); }' > reports/codequality.json) + artifacts: + when: always + paths: + - reports + expire_in: 1 week + reports: + codequality: reports/codequality.json Integration with Arcanist ------------------------- @@ -55,13 +97,13 @@ You can configure yamllint to run on ``arc lint``. Here is an example .. code:: json - { - "linters": { - "yamllint": { - "type": "script-and-regex", - "script-and-regex.script": "yamllint", - "script-and-regex.regex": "/^(?P\\d+):(?P\\d+) +(?Pwarning|error) +(?P.*) +\\((?P.*)\\)$/m", - "include": "(\\.(yml|yaml)$)" - } - } - } + { + "linters": { + "yamllint": { + "type": "script-and-regex", + "script-and-regex.script": "yamllint", + "script-and-regex.regex": "/^(?P\\d+):(?P\\d+) +(?Pwarning|error) +(?P.*) +\\((?P.*)\\)$/m", + "include": "(\\.(yml|yaml)$)" + } + } + } diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 0000000..f5a3564 --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1 @@ +sphinx-rtd-theme >=2.0.0 -- cgit v1.2.3