From 4dd6c7deb380d1c3ade66d5d11596d4d6be05f15 Mon Sep 17 00:00:00 2001 From: Thanh Ha Date: Sat, 8 Aug 2020 15:08:14 -0400 Subject: [PATCH] Migrate yamllint to pre-commit hook We'd like to move off of Coala as it hasn't had a release in a very long time. This patch sets up the pre-commit configuration for the yamllint hook as well as "prettier" for automated file formatting. This patch also sets YAML indents to 2 as it is the corrent dominant indent size for the YAML files in this project. Issue: RELENG-2642 Change-Id: I3827d922023ac18519d94c906b211274ff3e65d9 Signed-off-by: Thanh Ha --- .coafile | 6 ------ .editorconfig | 2 +- .pre-commit-config.yaml | 26 ++++++++++++++++++-------- yamllint.conf => .yamllint.yaml | 0 docs_conf/defaults/default.yaml | 2 +- docs_conf/defaults/lfdocs.yaml | 2 +- docs_conf/defaults/onap.yaml | 11 +++++------ docs_conf/defaults/opendaylight.yaml | 2 +- docs_conf/defaults/opnfv.yaml | 4 ++-- docs_conf/defaults/oran.yaml | 6 +++--- examples/conf.yaml | 2 +- 11 files changed, 33 insertions(+), 30 deletions(-) rename yamllint.conf => .yamllint.yaml (100%) diff --git a/.coafile b/.coafile index 3cab223..464aed4 100644 --- a/.coafile +++ b/.coafile @@ -9,9 +9,3 @@ ignore = .tox/**, [all.Documentation] bears = WriteGoodLintBear files = docs/**.rst - -[all.YAML] -bears = YAMLLintBear -files = docs_conf/**.yaml -document_start = True -yamllint_config = yamllint.conf diff --git a/.editorconfig b/.editorconfig index 3b13db5..c235528 100644 --- a/.editorconfig +++ b/.editorconfig @@ -14,4 +14,4 @@ indent_size = 4 max_line_legth = 88 [*.yaml] -indent_size = 4 +indent_size = 2 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 08519df..76fbb82 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,27 +11,37 @@ repos: - repo: https://github.com/jorisroovers/gitlint rev: v0.13.1 hooks: - - id: gitlint + - id: gitlint + + - repo: https://github.com/prettier/prettier + rev: 2.0.5 + hooks: + - id: prettier - repo: https://github.com/ambv/black rev: stable hooks: - - id: black + - id: black - repo: https://gitlab.com/pycqa/flake8 rev: 3.8.3 hooks: - - id: flake8 - args: ['--max-line-length=88'] + - id: flake8 + args: ["--max-line-length=88"] - repo: https://github.com/pycqa/bandit rev: 1.6.2 hooks: - - id: bandit - # Bandit does not need to run on test code - exclude: tests/* + - id: bandit + # Bandit does not need to run on test code + exclude: tests/* - repo: https://github.com/pycqa/pydocstyle rev: 5.0.2 hooks: - - id: pydocstyle + - id: pydocstyle + + - repo: https://github.com/adrienverge/yamllint + rev: v1.24.2 + hooks: + - id: yamllint diff --git a/yamllint.conf b/.yamllint.yaml similarity index 100% rename from yamllint.conf rename to .yamllint.yaml diff --git a/docs_conf/defaults/default.yaml b/docs_conf/defaults/default.yaml index bcf0140..1a0dbcc 100644 --- a/docs_conf/defaults/default.yaml +++ b/docs_conf/defaults/default.yaml @@ -5,7 +5,7 @@ version: master author: DEFAULT_AUTHOR copyright: 2018, DEFAULT_PROJECT -needs_sphinx: '1.6.5' +needs_sphinx: "1.6.5" extensions: - sphinx.ext.autodoc - sphinx.ext.doctest diff --git a/docs_conf/defaults/lfdocs.yaml b/docs_conf/defaults/lfdocs.yaml index 12d0315..578ecd9 100644 --- a/docs_conf/defaults/lfdocs.yaml +++ b/docs_conf/defaults/lfdocs.yaml @@ -5,7 +5,7 @@ version: master author: Linux Foundation Releng copyright: 2017-2018, The Linux Foundation -needs_sphinx: '1.6.5' +needs_sphinx: "1.6.5" extensions: - sphinx.ext.autodoc - sphinx.ext.doctest diff --git a/docs_conf/defaults/onap.yaml b/docs_conf/defaults/onap.yaml index c1c71dd..b605d1b 100644 --- a/docs_conf/defaults/onap.yaml +++ b/docs_conf/defaults/onap.yaml @@ -3,15 +3,15 @@ project: onap release: master version: master -author: 'Open Network Automation Platform' +author: "Open Network Automation Platform" # yamllint disable-line rule:line-length -copyright: '2020 ONAP. Licensed under Creative Commons Attribution 4.0 International License' +copyright: "2020 ONAP. Licensed under Creative Commons Attribution 4.0 International License" -pygments_style: 'sphinx' +pygments_style: "sphinx" html_theme: sphinx_rtd_theme html_theme_options: - style_nav_header_background: 'white' - sticky_navigation: 'False' + style_nav_header_background: "white" + sticky_navigation: "False" html_logo: _static/logo_onap_2017.png html_favicon: _static/favicon.ico html_static_path: @@ -36,7 +36,6 @@ extensions: - sphinxcontrib.plantuml - sphinxcontrib.swaggerdoc - exclude_patterns: - .DS_Store - _build diff --git a/docs_conf/defaults/opendaylight.yaml b/docs_conf/defaults/opendaylight.yaml index 2998551..2d968c9 100644 --- a/docs_conf/defaults/opendaylight.yaml +++ b/docs_conf/defaults/opendaylight.yaml @@ -5,7 +5,7 @@ version: master author: OpenDaylight Project copyright: 2016-2018, OpenDaylight Project -needs_sphinx: '1.6.5' +needs_sphinx: "1.6.5" extensions: - sphinx.ext.autodoc - sphinx.ext.doctest diff --git a/docs_conf/defaults/opnfv.yaml b/docs_conf/defaults/opnfv.yaml index aa74d69..1014f13 100644 --- a/docs_conf/defaults/opnfv.yaml +++ b/docs_conf/defaults/opnfv.yaml @@ -5,7 +5,7 @@ version: Latest author: Open Platform for NFV copyright: 2020, OPNFV. Licensed under CC BY 4.0 -needs_sphinx: '1.3' +needs_sphinx: "1.3" extensions: - sphinxcontrib.httpdomain - sphinx.ext.autodoc @@ -17,7 +17,7 @@ html_theme: opnfv html_theme_options: bootswatch_theme: journal navbar_sidebarrel: false - navbar_title: ' ' + navbar_title: " " html_logo: _static/logo.png html_favicon: _static/favicon.ico html_static_path: diff --git a/docs_conf/defaults/oran.yaml b/docs_conf/defaults/oran.yaml index 53abb41..7fddb5e 100644 --- a/docs_conf/defaults/oran.yaml +++ b/docs_conf/defaults/oran.yaml @@ -5,7 +5,7 @@ version: master author: O-RAN Project copyright: 2019, O-RAN Project -needs_sphinx: '1.6.5' +needs_sphinx: "1.6.5" extensions: - sphinx.ext.autodoc - sphinx.ext.doctest @@ -26,5 +26,5 @@ html_static_path: - _static html_theme: sphinx_rtd_theme html_theme_options: - style_nav_header_background: 'white' - sticky_navigation: 'False' + style_nav_header_background: "white" + sticky_navigation: "False" diff --git a/examples/conf.yaml b/examples/conf.yaml index bfac326..d260739 100644 --- a/examples/conf.yaml +++ b/examples/conf.yaml @@ -6,7 +6,7 @@ version: 1.2.3 author: OpenDaylight Project copyright: 2018, OpenDaylight Project a Series of LF Projects, LLC -needs_sphinx: '1.6.5' +needs_sphinx: "1.6.5" extensions: - sphinx.ext.autodoc - sphinx.ext.doctest -- 2.16.6