Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add GitLab CI / Code Climate example #631

Merged
merged 8 commits into from
Jan 13, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions docs/integration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,46 @@ You can configure yamllint to run on ``arc lint``. Here is an example
}
}
}

Intergration with GitLab
gardar marked this conversation as resolved.
Show resolved Hide resolved
------------------------

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

---
gardar marked this conversation as resolved.
Show resolved Hide resolved
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]);
gardar marked this conversation as resolved.
Show resolved Hide resolved
}
END { if (!first) printf("]\n"); }' > reports/codequality.json)
artifacts:
when: always
paths:
- reports
expire_in: 1 week
reports:
codequality: reports/codequality.json
Loading