From 31d1f24ebbf452e276dded8f4802ed03fb0ea1ec Mon Sep 17 00:00:00 2001 From: darknao Date: Sat, 24 Jun 2023 21:05:10 +0200 Subject: [PATCH] ci: fix vale pipeline --- .gitignore | 2 + .gitlab-ci.yml | 14 +- .vale/styles/RedHat/Abbreviations.yml | 9 - .vale/styles/RedHat/CaseSensitiveTerms.yml | 299 -------------- .vale/styles/RedHat/Conjunctions.yml | 14 - .vale/styles/RedHat/ConsciousLanguage.yml | 14 - .vale/styles/RedHat/Contractions.yml | 44 --- .vale/styles/RedHat/Definitions.yml | 183 --------- .vale/styles/RedHat/Ellipses.yml | 12 - .vale/styles/RedHat/HeadingPunctuation.yml | 15 - .vale/styles/RedHat/Headings.yml | 247 ------------ .vale/styles/RedHat/OxfordComma.yml | 8 - .vale/styles/RedHat/PascalCamelCase.yml | 179 --------- .vale/styles/RedHat/PassiveVoice.yml | 186 --------- .vale/styles/RedHat/README-IBM.adoc | 9 - .vale/styles/RedHat/README-proselint.md | 13 - .vale/styles/RedHat/README-write-good.md | 28 -- .vale/styles/RedHat/ReadabilityGrade.yml | 12 - .vale/styles/RedHat/ReleaseNotes.yml | 11 - .vale/styles/RedHat/RepeatedWords.yml | 10 - .vale/styles/RedHat/SelfReferentialText.yml | 14 - .vale/styles/RedHat/SentenceLength.yml | 9 - .vale/styles/RedHat/SimpleWords.yml | 119 ------ .vale/styles/RedHat/Slash.yml | 20 - .vale/styles/RedHat/Spacing.yml | 10 - .vale/styles/RedHat/Spelling.yml | 410 -------------------- .vale/styles/RedHat/TermsErrors.yml | 329 ---------------- .vale/styles/RedHat/TermsSuggestions.yml | 41 -- .vale/styles/RedHat/TermsWarnings.yml | 22 -- .vale/styles/RedHat/Usage.yml | 152 -------- .vale/styles/RedHat/UserReplacedValues.yml | 8 - .vale/styles/RedHat/meta.json | 4 - vale-json.tmpl | 57 +++ 33 files changed, 68 insertions(+), 2436 deletions(-) delete mode 100644 .vale/styles/RedHat/Abbreviations.yml delete mode 100644 .vale/styles/RedHat/CaseSensitiveTerms.yml delete mode 100644 .vale/styles/RedHat/Conjunctions.yml delete mode 100644 .vale/styles/RedHat/ConsciousLanguage.yml delete mode 100644 .vale/styles/RedHat/Contractions.yml delete mode 100644 .vale/styles/RedHat/Definitions.yml delete mode 100644 .vale/styles/RedHat/Ellipses.yml delete mode 100644 .vale/styles/RedHat/HeadingPunctuation.yml delete mode 100644 .vale/styles/RedHat/Headings.yml delete mode 100644 .vale/styles/RedHat/OxfordComma.yml delete mode 100644 .vale/styles/RedHat/PascalCamelCase.yml delete mode 100644 .vale/styles/RedHat/PassiveVoice.yml delete mode 100644 .vale/styles/RedHat/README-IBM.adoc delete mode 100644 .vale/styles/RedHat/README-proselint.md delete mode 100644 .vale/styles/RedHat/README-write-good.md delete mode 100644 .vale/styles/RedHat/ReadabilityGrade.yml delete mode 100644 .vale/styles/RedHat/ReleaseNotes.yml delete mode 100644 .vale/styles/RedHat/RepeatedWords.yml delete mode 100644 .vale/styles/RedHat/SelfReferentialText.yml delete mode 100644 .vale/styles/RedHat/SentenceLength.yml delete mode 100644 .vale/styles/RedHat/SimpleWords.yml delete mode 100644 .vale/styles/RedHat/Slash.yml delete mode 100644 .vale/styles/RedHat/Spacing.yml delete mode 100644 .vale/styles/RedHat/Spelling.yml delete mode 100644 .vale/styles/RedHat/TermsErrors.yml delete mode 100644 .vale/styles/RedHat/TermsSuggestions.yml delete mode 100644 .vale/styles/RedHat/TermsWarnings.yml delete mode 100644 .vale/styles/RedHat/Usage.yml delete mode 100644 .vale/styles/RedHat/UserReplacedValues.yml delete mode 100644 .vale/styles/RedHat/meta.json create mode 100644 vale-json.tmpl diff --git a/.gitignore b/.gitignore index 9f3ebf5..c010f8c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +.vale +gl-code-quality-report.json build cache public diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5369958..4c2f1a1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -36,12 +36,16 @@ code_quality: VARH_REPO: "redhat-documentation/vale-at-red-hat" VARH_BRANCH: "main" before_script: - - apk add --no-cache curl asciidoctor python3 - - | - curl -o vale2cc.py \ - https://raw.githubusercontent.com/${VARH_REPO}/${VARH_BRANCH}/tools/vale2cc.py + # - apk update && apk add git + - vale sync script: - - vale --no-exit --output=JSON . | python3 vale2cc.py > gl-code-quality-report.json + # list of updated/modified *.adoc files + # - FILES=$(git diff --name-only HEAD~1 HEAD --diff-filter=d "*.adoc") + # clean out conditions for wider vale coverage + # - sed -i -e 's/ifdef::.*\|ifndef::.*\|ifeval::.*\|endif::.*/ /' ${FILES} + # use a template to rearrange the vale JSON output + # run vale with `--no-exit` to pass the build with errors + - vale --no-exit --minAlertLevel=error --glob='*.adoc' --output="$(pwd)/vale-json.tmpl" . | sed "s/CI_COMMIT_SHA/$CI_COMMIT_SHA/g" > gl-code-quality-report.json artifacts: reports: codequality: gl-code-quality-report.json diff --git a/.vale/styles/RedHat/Abbreviations.yml b/.vale/styles/RedHat/Abbreviations.yml deleted file mode 100644 index 102fee4..0000000 --- a/.vale/styles/RedHat/Abbreviations.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- -extends: existence -level: error -link: https://redhat-documentation.github.io/vale-at-red-hat/docs/main/reference-guide/abbreviations/ -message: "Do not use periods in all-uppercase abbreviations such as '%s'." -nonword: true -# source: "IBM - Periods with abbreviations, p. 5" -tokens: - - '\b(?:[A-Z]\.){3,5}' diff --git a/.vale/styles/RedHat/CaseSensitiveTerms.yml b/.vale/styles/RedHat/CaseSensitiveTerms.yml deleted file mode 100644 index 4482a1e..0000000 --- a/.vale/styles/RedHat/CaseSensitiveTerms.yml +++ /dev/null @@ -1,299 +0,0 @@ ---- -extends: substitution -ignorecase: false -level: error -link: https://redhat-documentation.github.io/vale-at-red-hat/docs/reference-guide/casesensitiveterms/ -message: Use '%s' rather than '%s'. -# source: "https://redhat-documentation.github.io/supplementary-style-guide/#glossary-terms-conventions" -action: - name: replace -swap: - "(? -Copyright © 2014–2015, Jordan Suchow, Michael Pacer, and Lara A. Ross -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - -3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/.vale/styles/RedHat/README-write-good.md b/.vale/styles/RedHat/README-write-good.md deleted file mode 100644 index ba919b6..0000000 --- a/.vale/styles/RedHat/README-write-good.md +++ /dev/null @@ -1,28 +0,0 @@ - -Based on [write-good](https://github.com/btford/write-good). - -> Naive linter for English prose for developers who can't write good and wanna learn to do other stuff good too. - -``` -The MIT License (MIT) - -Copyright (c) 2014 Brian Ford - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -``` diff --git a/.vale/styles/RedHat/ReadabilityGrade.yml b/.vale/styles/RedHat/ReadabilityGrade.yml deleted file mode 100644 index 607cbdd..0000000 --- a/.vale/styles/RedHat/ReadabilityGrade.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- -extends: readability -grade: 21 -level: suggestion -link: https://redhat-documentation.github.io/vale-at-red-hat/docs/main/reference-guide/readabilitygrade/ -message: "Grade level (%s) too high." -metrics: - - Automated Readability - - Coleman-Liau - - Flesch-Kincaid - - Gunning Fog - - SMOG diff --git a/.vale/styles/RedHat/ReleaseNotes.yml b/.vale/styles/RedHat/ReleaseNotes.yml deleted file mode 100644 index 10ee9c9..0000000 --- a/.vale/styles/RedHat/ReleaseNotes.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- -extends: substitution -ignorecase: false -level: suggestion -link: https://redhat-documentation.github.io/vale-at-red-hat/docs/main/reference-guide/releasenotes/ -message: "For release notes, consider using '%s' rather than '%s'." -# source: "https://redhat-documentation.github.io/supplementary-style-guide/#release-notes" -# swap maps tokens in form of bad: good -swap: - Now: With this update - Previously: Before this update diff --git a/.vale/styles/RedHat/RepeatedWords.yml b/.vale/styles/RedHat/RepeatedWords.yml deleted file mode 100644 index 61b6577..0000000 --- a/.vale/styles/RedHat/RepeatedWords.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -extends: repetition -message: "'%s' is repeated!" -level: warning -link: https://redhat-documentation.github.io/vale-at-red-hat/docs/main/reference-guide/repeatedwords/ -ignorecase: false -alpha: true -tokens: - - '[^\s\.]+' - - '[^\s]+' diff --git a/.vale/styles/RedHat/SelfReferentialText.yml b/.vale/styles/RedHat/SelfReferentialText.yml deleted file mode 100644 index 36adbf4..0000000 --- a/.vale/styles/RedHat/SelfReferentialText.yml +++ /dev/null @@ -1,14 +0,0 @@ ---- -extends: existence -ignorecase: true -level: suggestion -link: https://redhat-documentation.github.io/vale-at-red-hat/docs/main/reference-guide/selfreferentialtext/ -message: "Avoid using self-referential text such as '%s'." -# source: "IBM - Audience and medium, p. 22" -tokens: - - this topic - - this module - - this assembly - - this chapter - - this section - - this subsection diff --git a/.vale/styles/RedHat/SentenceLength.yml b/.vale/styles/RedHat/SentenceLength.yml deleted file mode 100644 index c21f0bc..0000000 --- a/.vale/styles/RedHat/SentenceLength.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- -extends: occurrence -level: suggestion -link: https://redhat-documentation.github.io/vale-at-red-hat/docs/main/reference-guide/sentencelength/ -message: "Try to keep sentences to an average of 32 words or fewer." -scope: sentence -# source: "IBM - Conversational style" -max: 32 -token: \b(\w+)\b diff --git a/.vale/styles/RedHat/SimpleWords.yml b/.vale/styles/RedHat/SimpleWords.yml deleted file mode 100644 index f5b650b..0000000 --- a/.vale/styles/RedHat/SimpleWords.yml +++ /dev/null @@ -1,119 +0,0 @@ ---- -extends: substitution -ignorecase: true -level: suggestion -link: https://redhat-documentation.github.io/vale-at-red-hat/docs/main/reference-guide/simplewords/ -message: "Use simple language. Consider using '%s' rather than '%s'." -# source: "IBM - Conversational style; http://www.plainlanguage.gov/howto/wordsuggestions/simplewords.cfm" -swap: - "approximate(?:ly)?": about - "objective(?! C?)": aim|goal - absent: none|not here - abundance: plenty - accelerate: speed up - accentuate: stress - accompany: go with - accomplish: carry out|do - accorded: given - accordingly: so - accrue: add - accurate: right|exact - acquiesce: agree - acquire: get|buy - "(?__': Separate words by underscores in user-replaced values diff --git a/.vale/styles/RedHat/meta.json b/.vale/styles/RedHat/meta.json deleted file mode 100644 index 6099c80..0000000 --- a/.vale/styles/RedHat/meta.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "feed": "https://github.com/redhat-documentation/vale-at-red-hat/releases.atom", - "vale_version": ">=2.20.0" -} diff --git a/vale-json.tmpl b/vale-json.tmpl new file mode 100644 index 0000000..25dbaea --- /dev/null +++ b/vale-json.tmpl @@ -0,0 +1,57 @@ +{{- /* Modify Vale's output https://docs.errata.ai/vale/cli#--output */ -}} + +{{- /* Keep track of our various counts */ -}} + +{{- $e := 0 -}} +{{- $w := 0 -}} +{{- $s := 0 -}} +{{- $f := 0 -}} + +{{- /* Range over the linted files */ -}} + +[ +{{- range $jdx, $file := .Files -}} + +{{- $f = add1 $f -}} +{{- $path := .Path -}} + +{{- /* Range over the file's alerts */ -}} + +{{- if $jdx -}},{{- end -}} +{{- range $idx, $a := .Alerts -}} + +{{- $error := "" -}} +{{- if eq .Severity "error" -}} + {{- $error = "critical" -}} + {{- $e = add1 $e -}} +{{- else if eq .Severity "warning" -}} + {{- $error = "major" -}} + {{- $w = add1 $w -}} +{{- else -}} + {{- $error = "minor" -}} + {{- $s = add1 $s -}} +{{- end}} + +{{- /* Variables setup */ -}} + +{{- $loc := printf "%d" .Line -}} +{{- $check := printf "%s" .Check -}} +{{- $message := printf "%s" .Message -}} +{{- if $idx -}},{{- end -}} + +{{- /* Output */ -}} + + { + "description": "{{$check}}: {{ $message }}", + "fingerprint": "CI_COMMIT_SHA", + "severity": "{{ $error }}", + "location": { + "path": "{{ $path }}", + "lines": { + "begin": {{ $loc }} + } + } + } +{{end -}} +{{end -}} +]