mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-05-06 21:33:14 +00:00
Merge pull request #376 from rjeffman/ci_add_yml_linters
Add support for ansible-lint and yamllint as Github actions.
This commit is contained in:
23
.ansible-lint
Normal file
23
.ansible-lint
Normal file
@@ -0,0 +1,23 @@
|
||||
exclude_paths:
|
||||
- roles
|
||||
- .tox
|
||||
- .venv
|
||||
|
||||
parseable: true
|
||||
|
||||
quiet: false
|
||||
|
||||
skip_list:
|
||||
- '201' # Trailing whitespace
|
||||
- '204' # Lines should be no longer than 160 chars
|
||||
- '206' # Variables should have spaces before and after: {{ var_name }}'
|
||||
- '208' # File permissions not mentioned
|
||||
- '301' # Commands should not change things if nothing needs doing'
|
||||
- '305' # Use shell only when shell functionality is required'
|
||||
- '306' # Shells that use pipes should set the pipefail option'
|
||||
- '502' # All tasks should be named
|
||||
- '505' # Referenced missing file
|
||||
|
||||
use_default_rules: true
|
||||
|
||||
verbosity: 1
|
||||
33
.github/workflows/lint.yml
vendored
Normal file
33
.github/workflows/lint.yml
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
---
|
||||
name: Run Linters
|
||||
on:
|
||||
- push
|
||||
- pull_request
|
||||
jobs:
|
||||
linters:
|
||||
name: Run Linters
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: "3.6"
|
||||
|
||||
- name: Run ansible-lint
|
||||
uses: ansible/ansible-lint-action@master
|
||||
with:
|
||||
targets: |
|
||||
tests/*.yml
|
||||
tests/*/*.yml
|
||||
tests/*/*/*.yml
|
||||
playbooks/*.yml
|
||||
playbooks/*/*.yml
|
||||
env:
|
||||
ANSIBLE_MODULE_UTILS: plugins/module_utils
|
||||
ANSIBLE_LIBRARY: plugins/modules
|
||||
|
||||
- name: Run yaml-lint
|
||||
uses: ibiqlik/action-yamllint@v1
|
||||
|
||||
- name: Run Python linters
|
||||
uses: rjeffman/python-lint-action@master
|
||||
28
.yamllint
Normal file
28
.yamllint
Normal file
@@ -0,0 +1,28 @@
|
||||
---
|
||||
ignore: |
|
||||
/.tox/
|
||||
/.venv/
|
||||
/.github/
|
||||
|
||||
extends: default
|
||||
|
||||
rules:
|
||||
braces:
|
||||
max-spaces-inside: 1
|
||||
level: error
|
||||
brackets:
|
||||
max-spaces-inside: 1
|
||||
level: error
|
||||
truthy:
|
||||
allowed-values: ["yes", "no", "true", "false", "True", "False"]
|
||||
level: error
|
||||
# Disabled rules
|
||||
document-start: disable
|
||||
indentation: disable
|
||||
line-length: disable
|
||||
colons: disable
|
||||
empty-lines: disable
|
||||
comments: disable
|
||||
comments-indentation: disable
|
||||
trailing-spaces: disable
|
||||
new-line-at-end-of-file: disable
|
||||
@@ -11,7 +11,7 @@
|
||||
- name: Ensure nss package is updated
|
||||
package:
|
||||
name: nss
|
||||
state: latest
|
||||
state: latest # noqa 403
|
||||
|
||||
- include_role:
|
||||
name: ipaserver
|
||||
|
||||
@@ -22,7 +22,8 @@ data_files =
|
||||
/usr/share/ansible/roles/ipareplica = roles/ipareplica/*
|
||||
|
||||
[flake8]
|
||||
extend-ignore = E203
|
||||
extend-ignore = E203, D1, D212, D203, D400, D401
|
||||
exclude = .git,__pycache__,.tox,.venv
|
||||
per-file-ignores =
|
||||
plugins/*:E402
|
||||
roles/*:E402
|
||||
|
||||
@@ -18,27 +18,6 @@ pool:
|
||||
vmImage: 'ubuntu-18.04'
|
||||
|
||||
stages:
|
||||
- stage: Linters
|
||||
jobs:
|
||||
- job: RunLinters
|
||||
displayName: Run Linters
|
||||
steps:
|
||||
- task: UsePythonVersion@0
|
||||
inputs:
|
||||
versionSpec: '3.6'
|
||||
|
||||
- script: python -m pip install --upgrade pip setuptools wheel
|
||||
displayName: Install tools
|
||||
|
||||
- script: pip install pydocstyle flake8
|
||||
displayName: Install dependencies
|
||||
|
||||
- script: flake8 .
|
||||
displayName: Run flake8 checks
|
||||
|
||||
- script: pydocstyle .
|
||||
displayName: Verify docstings
|
||||
|
||||
- stage: Centos7
|
||||
dependsOn: []
|
||||
jobs:
|
||||
|
||||
25
utils/lint_check.sh
Executable file
25
utils/lint_check.sh
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
topdir=`dirname $(dirname $0)`
|
||||
|
||||
flake8 .
|
||||
pydocstyle .
|
||||
|
||||
ANSIBLE_LIBRARY=${ANSIBLE_LIBRARY:-"${topdir}/plugins/modules"}
|
||||
ANSIBLE_MODULE_UTILS=${ANSIBLE_MODULE_UTILS:-"${topdir}/plugins/module_utils"}
|
||||
|
||||
export ANSIBLE_LIBRARY ANSIBLE_MODULE_UTILS
|
||||
|
||||
yaml_dirs=(
|
||||
"${topdir}/tests/*.yml"
|
||||
"${topdir}/tests/*/*.yml"
|
||||
"${topdir}/tests/*/*/*.yml"
|
||||
"${topdir}/playbooks/*.yml"
|
||||
"${topdir}/playbooks/*/*.yml"
|
||||
"${topdir}/molecule/*/*.yml"
|
||||
"${topdir}/molecule/*/*/*.yml"
|
||||
)
|
||||
|
||||
ansible-lint --force-color ${yaml_dirs[@]}
|
||||
|
||||
yamllint -f colored ${yaml_dirs[@]}
|
||||
Reference in New Issue
Block a user