Skip to content

Commit

Permalink
docs: add GitLab CI / Code Climate example
Browse files Browse the repository at this point in the history
Signed-off-by: gardar <[email protected]>
  • Loading branch information
gardar committed Jan 5, 2024
1 parent 1d65ab6 commit c65c006
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions docs/integration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,44 @@ You can configure yamllint to run on ``arc lint``. Here is an example
}
}
}
Intergration with GitLab
------------------------

You can use the following gitlab-ci stage to do run yamllint and get the results as a
`Code quality (Code Climate) <https://docs.gitlab.com/ee/ci/testing/code_quality.html>` 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

0 comments on commit c65c006

Please sign in to comment.