Run all linters via pre-commit
Executes all linters via pre-commit, which is much faster, guarantees their version locking and allows upgrading them with a single command. Before this change the only linter running via pre-commit was ansible-lint. Now we also run bashate, flake8 and yamllint via pre-commit. For developer convenience we still keep the old tox environments which allow running a single linter. Added long_description_content_type to fix twine check failure Change-Id: I037eae61921b2a84aa99838804f70e96ee8d8b13
This commit is contained in:
parent
ad56778e6e
commit
b541c5ef99
2
.ansible-lint
Normal file
2
.ansible-lint
Normal file
@ -0,0 +1,2 @@
|
||||
---
|
||||
parseable: true
|
40
.pre-commit-config.yaml
Normal file
40
.pre-commit-config.yaml
Normal file
@ -0,0 +1,40 @@
|
||||
---
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v2.1.0
|
||||
hooks:
|
||||
- id: end-of-file-fixer
|
||||
- id: trailing-whitespace
|
||||
- id: mixed-line-ending
|
||||
- id: check-byte-order-marker
|
||||
- id: check-executables-have-shebangs
|
||||
- id: check-merge-conflict
|
||||
- id: debug-statements
|
||||
- id: flake8
|
||||
- id: check-yaml
|
||||
files: .*\.(yaml|yml)$
|
||||
- repo: https://github.com/adrienverge/yamllint.git
|
||||
rev: v1.15.0
|
||||
hooks:
|
||||
- id: yamllint
|
||||
files: \.(yaml|yml)$
|
||||
types: [file, yaml]
|
||||
entry: yamllint --strict -f parsable
|
||||
- repo: https://github.com/ansible/ansible-lint
|
||||
rev: v4.1.0a0
|
||||
hooks:
|
||||
- id: ansible-lint
|
||||
files: \.(yaml|yml)$
|
||||
entry: ansible-lint --force-color -v
|
||||
- repo: https://github.com/openstack-dev/bashate.git
|
||||
rev: 0.6.0
|
||||
hooks:
|
||||
- id: bashate
|
||||
entry: bashate --error . --verbose --ignore=E006,E040
|
||||
# Run bashate check for all bash scripts
|
||||
# Ignores the following rules:
|
||||
# E006: Line longer than 79 columns (as many scripts use jinja
|
||||
# templating, this is very difficult)
|
||||
# E040: Syntax error determined using `bash -n` (as many scripts
|
||||
# use jinja templating, this will often fail and the syntax
|
||||
# error will be discovered in execution anyway)
|
7
.yamllint
Normal file
7
.yamllint
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
extends: default
|
||||
|
||||
rules:
|
||||
line-length:
|
||||
# matches hardcoded 160 value from ansible-lint
|
||||
max: 160
|
1
LICENSE
1
LICENSE
@ -173,4 +173,3 @@
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
|
@ -1,2 +1,3 @@
|
||||
---
|
||||
update_repo: ''
|
||||
container_build_tool: 'docker'
|
||||
|
@ -3,7 +3,7 @@ set -e
|
||||
# Cherry-pick a refspec
|
||||
# $1 : project name e.g. keystone
|
||||
# $2 : Gerrit refspec(s) to cherry pick
|
||||
function cherrypick(){
|
||||
function cherrypick {
|
||||
local PROJ_NAME=$1
|
||||
local REFSPECS="$2"
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
---
|
||||
galaxy_info:
|
||||
author: Steve Baker
|
||||
description: Modify container images built for TripleO
|
||||
@ -6,9 +7,9 @@ galaxy_info:
|
||||
min_ansible_version: 2.4
|
||||
|
||||
platforms:
|
||||
- name: EL
|
||||
versions:
|
||||
- 7
|
||||
- name: EL
|
||||
versions:
|
||||
- 7
|
||||
|
||||
galaxy_tags:
|
||||
- docker
|
||||
|
@ -34,3 +34,8 @@ universal = 1
|
||||
skip_authors = True
|
||||
skip_changelog = True
|
||||
|
||||
[flake8]
|
||||
# E123, E125 skipped as they are invalid PEP-8.
|
||||
show-source = True
|
||||
ignore = E123,E125
|
||||
builtins = _
|
||||
|
1
setup.py
1
setup.py
@ -15,5 +15,6 @@
|
||||
import setuptools
|
||||
|
||||
setuptools.setup(
|
||||
long_description_content_type='text/markdown',
|
||||
setup_requires=['pbr'],
|
||||
pbr=True)
|
||||
|
@ -1,3 +1,4 @@
|
||||
---
|
||||
- import_tasks: precheck.yml
|
||||
tags:
|
||||
- always
|
||||
|
@ -1,3 +1,4 @@
|
||||
---
|
||||
- when: container_build_tool == 'docker'
|
||||
block:
|
||||
- name: Inspect image with Docker
|
||||
@ -19,8 +20,7 @@
|
||||
become: true
|
||||
- name: Set config with Buildah
|
||||
set_fact:
|
||||
buildah_config: "{{ source_image_facts.stdout_lines | join('') | from_json }}"
|
||||
buildah_config: "{{ source_image_facts.stdout_lines | join('') | from_json }}"
|
||||
- name: Set original_user with Buildah
|
||||
set_fact:
|
||||
original_user: "{{ buildah_config['Docker']['config']['User'] }}"
|
||||
|
||||
original_user: "{{ buildah_config['Docker']['config']['User'] }}"
|
||||
|
@ -1,3 +1,4 @@
|
||||
---
|
||||
- import_tasks: precheck.yml
|
||||
tags:
|
||||
- always
|
||||
|
@ -1,3 +1,4 @@
|
||||
---
|
||||
- import_tasks: precheck.yml
|
||||
tags:
|
||||
- always
|
||||
@ -36,7 +37,7 @@
|
||||
{{ build_commands[container_build_tool] }} \
|
||||
--tag {{ target_image | default(source_image) }}{{ modified_append_tag }} \
|
||||
--file {{ dockerfile.path }} --network host ./
|
||||
#FIXME: buildah should not required root commands to build an image
|
||||
# FIXME: buildah should not required root commands to build an image
|
||||
become: "{{ true if build_commands[container_build_tool] == 'buildah' else false }}"
|
||||
args:
|
||||
chdir: "{{ modify_dir_path }}"
|
||||
|
@ -1,3 +1,4 @@
|
||||
---
|
||||
- name: Ensure that source_image is defined
|
||||
assert:
|
||||
that:
|
||||
@ -5,7 +6,8 @@
|
||||
- source_image | length > 0
|
||||
|
||||
- name: Ensure that container_build_tool is correctly set
|
||||
fail: msg="{{ container_build_tool }} is not a valid value for container_build_tool. Pick docker or buildah."
|
||||
fail: msg="{{ container_build_tool }} is not a valid value for
|
||||
container_build_tool. Pick docker or buildah."
|
||||
when: container_build_tool not in ['docker', 'buildah']
|
||||
|
||||
- name: Set default modified_append_tag
|
||||
|
@ -1,3 +1,4 @@
|
||||
---
|
||||
- import_tasks: precheck.yml
|
||||
tags:
|
||||
- always
|
||||
@ -18,7 +19,7 @@
|
||||
find:
|
||||
paths: "{{ rpms_path }}"
|
||||
patterns: "^.*?\\.rpm$"
|
||||
use_regex: yes
|
||||
use_regex: true
|
||||
when: rpms_path is defined
|
||||
register: context_rpms
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
---
|
||||
- import_tasks: precheck.yml
|
||||
tags:
|
||||
- always
|
||||
|
@ -1,3 +1,4 @@
|
||||
---
|
||||
- import_tasks: precheck.yml
|
||||
tags:
|
||||
- always
|
||||
@ -57,7 +58,8 @@
|
||||
path: "{{ yum_update.path }}"
|
||||
state: absent
|
||||
|
||||
- name: Commit changes to image {{ target_image | default(source_image) }}{{ modified_append_tag }}
|
||||
- name: Commit changes to image
|
||||
({{ target_image | default(source_image) }}{{ modified_append_tag }})
|
||||
command: >
|
||||
buildah commit
|
||||
{{ from_image }}
|
||||
|
@ -1,3 +1,4 @@
|
||||
---
|
||||
- import_tasks: precheck.yml
|
||||
tags:
|
||||
- always
|
||||
|
@ -1 +1 @@
|
||||
hacking>=1.1.0,<1.2.0 # Apache-2.0
|
||||
pre-commit # MIT
|
||||
|
32
tox.ini
32
tox.ini
@ -20,39 +20,33 @@ deps = bindep
|
||||
commands = bindep test
|
||||
|
||||
[testenv:pep8]
|
||||
basepython = python3
|
||||
envdir = {toxworkdir}/linters
|
||||
commands =
|
||||
# Run hacking/flake8 check for all python files
|
||||
bash -c "git ls-files | grep -v releasenotes | xargs grep --binary-files=without-match \
|
||||
--files-with-match '^.!.*python$' \
|
||||
--exclude-dir .tox \
|
||||
--exclude-dir .git \
|
||||
--exclude-dir .eggs \
|
||||
--exclude-dir *.egg-info \
|
||||
--exclude-dir dist \
|
||||
--exclude-dir *lib/python* \
|
||||
--exclude-dir doc \
|
||||
| xargs flake8 --verbose"
|
||||
python -m pre_commit run flake8 -a
|
||||
|
||||
[testenv:ansible-lint]
|
||||
basepython=python3
|
||||
setenv =
|
||||
ANSIBLE_LIBRARY=./library
|
||||
envdir = {toxworkdir}/linters
|
||||
commands =
|
||||
bash ci-scripts/ansible-lint.sh
|
||||
python -m pre_commit run ansible-lint -a
|
||||
|
||||
[testenv:linters]
|
||||
basepython = python3
|
||||
deps =
|
||||
-r{toxinidir}/test-requirements.txt
|
||||
-r{toxinidir}/ansible-requirements.txt
|
||||
commands =
|
||||
{[testenv:pep8]commands}
|
||||
{[testenv:ansible-lint]commands}
|
||||
# check only modified files:
|
||||
python -m pre_commit run -a
|
||||
|
||||
[testenv:releasenotes]
|
||||
basepython = python3
|
||||
whitelist_externals = bash
|
||||
commands = bash -c ci-scripts/releasenotes_tox.sh
|
||||
|
||||
[testenv:bashate]
|
||||
envdir = {toxworkdir}/linters
|
||||
commands =
|
||||
python -m pre_commit run bashate -a
|
||||
|
||||
[testenv:venv]
|
||||
basepython = python3
|
||||
commands = {posargs}
|
||||
|
@ -1,3 +1,4 @@
|
||||
---
|
||||
# we support 'docker' or 'buildah'
|
||||
build_commands:
|
||||
docker: docker build
|
||||
|
@ -1,3 +1,4 @@
|
||||
---
|
||||
- project:
|
||||
templates:
|
||||
- tripleo-multinode-container-minimal
|
||||
|
Loading…
x
Reference in New Issue
Block a user