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
|
@ -0,0 +1,2 @@
|
||||||
|
---
|
||||||
|
parseable: true
|
|
@ -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)
|
|
@ -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
|
defend, and hold each Contributor harmless for any liability
|
||||||
incurred by, or claims asserted against, such Contributor by reason
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
of your accepting any such warranty or additional liability.
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
|
---
|
||||||
update_repo: ''
|
update_repo: ''
|
||||||
container_build_tool: 'docker'
|
container_build_tool: 'docker'
|
||||||
|
|
|
@ -3,7 +3,7 @@ set -e
|
||||||
# Cherry-pick a refspec
|
# Cherry-pick a refspec
|
||||||
# $1 : project name e.g. keystone
|
# $1 : project name e.g. keystone
|
||||||
# $2 : Gerrit refspec(s) to cherry pick
|
# $2 : Gerrit refspec(s) to cherry pick
|
||||||
function cherrypick(){
|
function cherrypick {
|
||||||
local PROJ_NAME=$1
|
local PROJ_NAME=$1
|
||||||
local REFSPECS="$2"
|
local REFSPECS="$2"
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
galaxy_info:
|
galaxy_info:
|
||||||
author: Steve Baker
|
author: Steve Baker
|
||||||
description: Modify container images built for TripleO
|
description: Modify container images built for TripleO
|
||||||
|
@ -6,9 +7,9 @@ galaxy_info:
|
||||||
min_ansible_version: 2.4
|
min_ansible_version: 2.4
|
||||||
|
|
||||||
platforms:
|
platforms:
|
||||||
- name: EL
|
- name: EL
|
||||||
versions:
|
versions:
|
||||||
- 7
|
- 7
|
||||||
|
|
||||||
galaxy_tags:
|
galaxy_tags:
|
||||||
- docker
|
- docker
|
||||||
|
|
|
@ -34,3 +34,8 @@ universal = 1
|
||||||
skip_authors = True
|
skip_authors = True
|
||||||
skip_changelog = 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
|
import setuptools
|
||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
|
long_description_content_type='text/markdown',
|
||||||
setup_requires=['pbr'],
|
setup_requires=['pbr'],
|
||||||
pbr=True)
|
pbr=True)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
- import_tasks: precheck.yml
|
- import_tasks: precheck.yml
|
||||||
tags:
|
tags:
|
||||||
- always
|
- always
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
- when: container_build_tool == 'docker'
|
- when: container_build_tool == 'docker'
|
||||||
block:
|
block:
|
||||||
- name: Inspect image with Docker
|
- name: Inspect image with Docker
|
||||||
|
@ -19,8 +20,7 @@
|
||||||
become: true
|
become: true
|
||||||
- name: Set config with Buildah
|
- name: Set config with Buildah
|
||||||
set_fact:
|
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
|
- name: Set original_user with Buildah
|
||||||
set_fact:
|
set_fact:
|
||||||
original_user: "{{ buildah_config['Docker']['config']['User'] }}"
|
original_user: "{{ buildah_config['Docker']['config']['User'] }}"
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
- import_tasks: precheck.yml
|
- import_tasks: precheck.yml
|
||||||
tags:
|
tags:
|
||||||
- always
|
- always
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
- import_tasks: precheck.yml
|
- import_tasks: precheck.yml
|
||||||
tags:
|
tags:
|
||||||
- always
|
- always
|
||||||
|
@ -36,7 +37,7 @@
|
||||||
{{ build_commands[container_build_tool] }} \
|
{{ build_commands[container_build_tool] }} \
|
||||||
--tag {{ target_image | default(source_image) }}{{ modified_append_tag }} \
|
--tag {{ target_image | default(source_image) }}{{ modified_append_tag }} \
|
||||||
--file {{ dockerfile.path }} --network host ./
|
--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 }}"
|
become: "{{ true if build_commands[container_build_tool] == 'buildah' else false }}"
|
||||||
args:
|
args:
|
||||||
chdir: "{{ modify_dir_path }}"
|
chdir: "{{ modify_dir_path }}"
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
- name: Ensure that source_image is defined
|
- name: Ensure that source_image is defined
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
|
@ -5,7 +6,8 @@
|
||||||
- source_image | length > 0
|
- source_image | length > 0
|
||||||
|
|
||||||
- name: Ensure that container_build_tool is correctly set
|
- 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']
|
when: container_build_tool not in ['docker', 'buildah']
|
||||||
|
|
||||||
- name: Set default modified_append_tag
|
- name: Set default modified_append_tag
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
- import_tasks: precheck.yml
|
- import_tasks: precheck.yml
|
||||||
tags:
|
tags:
|
||||||
- always
|
- always
|
||||||
|
@ -18,7 +19,7 @@
|
||||||
find:
|
find:
|
||||||
paths: "{{ rpms_path }}"
|
paths: "{{ rpms_path }}"
|
||||||
patterns: "^.*?\\.rpm$"
|
patterns: "^.*?\\.rpm$"
|
||||||
use_regex: yes
|
use_regex: true
|
||||||
when: rpms_path is defined
|
when: rpms_path is defined
|
||||||
register: context_rpms
|
register: context_rpms
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
- import_tasks: precheck.yml
|
- import_tasks: precheck.yml
|
||||||
tags:
|
tags:
|
||||||
- always
|
- always
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
- import_tasks: precheck.yml
|
- import_tasks: precheck.yml
|
||||||
tags:
|
tags:
|
||||||
- always
|
- always
|
||||||
|
@ -57,7 +58,8 @@
|
||||||
path: "{{ yum_update.path }}"
|
path: "{{ yum_update.path }}"
|
||||||
state: absent
|
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: >
|
command: >
|
||||||
buildah commit
|
buildah commit
|
||||||
{{ from_image }}
|
{{ from_image }}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
- import_tasks: precheck.yml
|
- import_tasks: precheck.yml
|
||||||
tags:
|
tags:
|
||||||
- always
|
- 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
|
commands = bindep test
|
||||||
|
|
||||||
[testenv:pep8]
|
[testenv:pep8]
|
||||||
basepython = python3
|
envdir = {toxworkdir}/linters
|
||||||
commands =
|
commands =
|
||||||
# Run hacking/flake8 check for all python files
|
python -m pre_commit run flake8 -a
|
||||||
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"
|
|
||||||
|
|
||||||
[testenv:ansible-lint]
|
[testenv:ansible-lint]
|
||||||
basepython=python3
|
setenv =
|
||||||
|
ANSIBLE_LIBRARY=./library
|
||||||
|
envdir = {toxworkdir}/linters
|
||||||
commands =
|
commands =
|
||||||
bash ci-scripts/ansible-lint.sh
|
python -m pre_commit run ansible-lint -a
|
||||||
|
|
||||||
[testenv:linters]
|
[testenv:linters]
|
||||||
basepython = python3
|
basepython = python3
|
||||||
deps =
|
|
||||||
-r{toxinidir}/test-requirements.txt
|
|
||||||
-r{toxinidir}/ansible-requirements.txt
|
|
||||||
commands =
|
commands =
|
||||||
{[testenv:pep8]commands}
|
# check only modified files:
|
||||||
{[testenv:ansible-lint]commands}
|
python -m pre_commit run -a
|
||||||
|
|
||||||
[testenv:releasenotes]
|
[testenv:releasenotes]
|
||||||
basepython = python3
|
basepython = python3
|
||||||
whitelist_externals = bash
|
whitelist_externals = bash
|
||||||
commands = bash -c ci-scripts/releasenotes_tox.sh
|
commands = bash -c ci-scripts/releasenotes_tox.sh
|
||||||
|
|
||||||
|
[testenv:bashate]
|
||||||
|
envdir = {toxworkdir}/linters
|
||||||
|
commands =
|
||||||
|
python -m pre_commit run bashate -a
|
||||||
|
|
||||||
[testenv:venv]
|
[testenv:venv]
|
||||||
basepython = python3
|
basepython = python3
|
||||||
commands = {posargs}
|
commands = {posargs}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
# we support 'docker' or 'buildah'
|
# we support 'docker' or 'buildah'
|
||||||
build_commands:
|
build_commands:
|
||||||
docker: docker build
|
docker: docker build
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
- project:
|
- project:
|
||||||
templates:
|
templates:
|
||||||
- tripleo-multinode-container-minimal
|
- tripleo-multinode-container-minimal
|
||||||
|
|
Loading…
Reference in New Issue