WIP Create a zuul for black style

Create a format check

Test Plan
TODO - SUCCESS on black zuul

Closes-bug: #####

Change-Id: I5d7b537e83931304ffd5f67ce51e8ebb44f7e65b
Signed-off-by: Hugo Brito <hugo.brito@windriver.com>
This commit is contained in:
Hugo Brito 2024-03-01 17:38:15 -03:00
parent 8405f3b47c
commit 562e515de7
5 changed files with 50 additions and 9 deletions

View File

@ -10,12 +10,14 @@
- stx-distcloud-client-tox-pep8
- stx-distcloud-client-tox-py39
- stx-distcloud-client-tox-pylint
- stx-distcloud-client-tox-black
gate:
jobs:
- openstack-tox-linters
- stx-distcloud-client-tox-pep8
- stx-distcloud-client-tox-py39
- stx-distcloud-client-tox-pylint
- stx-distcloud-client-tox-black
post:
jobs:
- stx-distcloud-client-upload-git-mirror
@ -50,6 +52,22 @@
tox_envlist: pep8
tox_extra_args: -c distributedcloud-client/tox.ini
- job:
name: stx-distcloud-client-tox-black
parent: tox
description: Run black for distcloud-client
nodeset: debian-bullseye
voting: false
vars:
python_version: 3.9
tox_envlist: black_zuul
tox_extra_args: -c distributedcloud-client/tox.ini
pre-run:
- git:
name: Get modified Python files
commands:
- diff HEAD^ --name-only -- '*.py' > modified_files.txt
- job:
name: stx-distcloud-client-upload-git-mirror
parent: upload-git-mirror

View File

@ -23,7 +23,8 @@ import logging
import os
import sys
from cliff import app, commandmanager
from cliff import app
from cliff import commandmanager
from cliff import help as cliff_help
from osc_lib.command import command

View File

@ -263,7 +263,8 @@ FAKE_INSTALL_VALUES = {
class FakeResponse:
"""Fake response for testing DC Manager Client."""
def __init__(self, status_code, content=None):
def __init__(self,
status_code, content=None):
self.status_code = status_code
self.content = content
self.headers = {}

View File

@ -1,8 +1,7 @@
[tox]
envlist = py39,pep8,pylint
minversion = 2.3
minversion = 4.4.0
skipsdist = True
toxworkdir = /tmp/{env:USER}_dc_client_tox
[dcclient]
@ -10,17 +9,16 @@ client_base_dir = .
[testenv]
basepython = python3.9
install_command = pip install \
-c{env:UPPER_CONSTRAINTS_FILE:https://opendev.org/starlingx/root/raw/branch/master/build-tools/requirements/debian/upper-constraints.txt} \
{opts} {packages}
setenv =
VIRTUAL_ENV={envdir}
OS_STDOUT_CAPTURE=1
OS_STDERR_CAPTURE=1
OS_TEST_TIMEOUT=60
deps = -r{toxinidir}/test-requirements.txt
-r{toxinidir}/requirements.txt
deps =
-c{env:UPPER_CONSTRAINTS_FILE:https://opendev.org/starlingx/root/raw/branch/master/build-tools/requirements/debian/upper-constraints.txt}
-r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
allowlist_externals =
rm
@ -51,6 +49,23 @@ exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build
commands =
pylint {posargs} dcmanagerclient --rcfile=./.pylintrc
[testenv:black]
# To check only the files that will be modified, use the following command:
# tox -e black -- --diff --check
deps =
black>=23.11.0 # MIT
commands =
black --line-length 85 {posargs} .
[testenv:black_zuul]
setenv =
{[testenv]setenv}
MODIFIED_FILES={toxinidir}/modified_files.txt
deps =
black>=23.11.0 # MIT
commands =
black --line-length 85 --diff --check {env:MODIFIED_FILES}
[testenv:cover]
setenv =
PYTHON=coverage run --parallel-mode

View File

@ -27,6 +27,12 @@ description = Dummy environment to allow pep8 to be run in subdir tox
[testenv:pylint]
description = Dummy environment to allow pylint to be run in subdir tox
[testenv:black]
description = Dummy environment to allow black to be run in subdir tox
[testenv:black_zuul]
description = Dummy environment to allow black_zuul check to be run in subdir tox
[testenv:docs]
deps = -r{toxinidir}/doc/requirements.txt
commands =