[DO-110] created groovy linter action
This commit is contained in:
77
README.md
77
README.md
@@ -1,3 +1,78 @@
|
||||
# npm-groovy-lint-docker-action
|
||||
|
||||
NPM Groovy Linter Gitea Action
|
||||
Gitea Action (Github Action) для проверки Groovy кода(Groovy Liter).
|
||||
В качестве линтера используется 'NPM GROOVY LINT' - Groovy & Jenkinsfile Linter. NPM GROOVY LINT основан на базе CodeNarc - анализатора Groovy кода.
|
||||
|
||||
[Ссылка на проект](https://github.com/nvuillam/npm-groovy-lint)
|
||||
|
||||
Пример использования:
|
||||
|
||||
1- Данный код в виде yaml файла размещаем в репозиторий для которого необходим линтинг groovy кода. Путь для размещения
|
||||
файла: repo_with_groovy_files/.gitea/workflows/groovy-linter.yml
|
||||
|
||||
```yaml
|
||||
---
|
||||
name: Groovy linter
|
||||
run-name: ${{ gitea.actor }} is start check sources
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
linter:
|
||||
name: Groovy linter
|
||||
runs-on: docker
|
||||
container:
|
||||
image: harbor.avroid.tech/devops/npm-groovy-lint:14.4.1-0
|
||||
steps:
|
||||
- run: echo "Start job on ${{ runner.name }} with OS ${{ runner.os }}"
|
||||
- run: echo "Work with branch ${{ gitea.ref }} in repository ${{ gitea.repository }}"
|
||||
- name: Check out repository code
|
||||
uses: https://gitea:${{ secrets.CI_TOKEN }}@git.avroid.tech/Mirrors/github-actions-checkout.git@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
- name: Get all groovy files that have changed
|
||||
id: changed-files-specific
|
||||
uses: https://gitea:${{ secrets.CI_TOKEN }}@git.avroid.tech/Mirrors/github-actions-tj-actions-changed-files.git@v44
|
||||
with:
|
||||
files: |
|
||||
**/*.groovy
|
||||
**/Jenkinsfile
|
||||
- name: Run step if there is no changed files
|
||||
id: no_files_to_check
|
||||
if: steps.changed-files-specific.outputs.any_changed != 'true'
|
||||
run: echo "*** No changed groovy files, nothing to check. ***"
|
||||
|
||||
- name: Run linter for changed files
|
||||
id: groovy_linter
|
||||
if: steps.changed-files-specific.outputs.any_changed == 'true'
|
||||
uses: https://gitea:${{ secrets.CI_TOKEN }}@git.avroid.tech/Actions/npm-groovy-lint-docker-action.git@v17
|
||||
with:
|
||||
input_flags: "--failon error"
|
||||
input_files: ${{ steps.changed-files-specific.outputs.all_changed_files }}
|
||||
```
|
||||
2 - Размещаем в корне проверяемого репозитория конфиг для линтера. Путь и имя для размещения
|
||||
repo_with_groovy_files/.groovylintrc.json
|
||||
|
||||
```json
|
||||
{
|
||||
"extends": "recommended",
|
||||
"rules": {
|
||||
"convention.CompileStatic": "off",
|
||||
"convention.NoDef": "off",
|
||||
"groovyism.ExplicitCallToEqualsMethod": "off",
|
||||
"groovyism.GStringExpressionWithinString": "off",
|
||||
"naming.VariableName": {
|
||||
"ignoreVariableNames": "_"
|
||||
},
|
||||
"naming.FactoryMethodName": "off",
|
||||
"unnecessary.UnnecessaryGetter": "off",
|
||||
"size.NestedBlockDepth": {
|
||||
"maxNestedBlockDepth": 10
|
||||
},
|
||||
"unused.UnusedVariable": {
|
||||
"ignoreVariableNames": "_"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
Описание правил конфига линтера https://codenarc.org/codenarc-rule-index-by-name.html
|
||||
Reference in New Issue
Block a user