@@ -326,6 +326,63 @@ schemasgen: requirements .schemasgen
326326 . $(VIRTUALENV_DIR ) /bin/activate; pylint -j $(PYLINT_CONCURRENCY ) -E --rcfile=./lint-configs/python/.pylintrc --load-plugins=pylint_plugins.api_models tools/* .py || exit 1;
327327 . $(VIRTUALENV_DIR ) /bin/activate; pylint -j $(PYLINT_CONCURRENCY ) -E --rcfile=./lint-configs/python/.pylintrc pylint_plugins/* .py || exit 1;
328328
329+ # Black task which checks if the code comforts to black code style
330+ .PHONY : black-check
331+ black : requirements .black-check
332+
333+ .PHONY : .black-check
334+ .black :
335+ @echo
336+ @echo " ================== black-check ===================="
337+ @echo
338+ # st2 components
339+ @for component in $(COMPONENTS ) ; do\
340+ echo " ===========================================================" ; \
341+ echo " Running black on" $$ component; \
342+ echo " ===========================================================" ; \
343+ . $(VIRTUALENV_DIR ) /bin/activate ; black --check --config pyproject.toml $$ component/ || exit 1; \
344+ done
345+ # runner modules and packages
346+ @for component in $(COMPONENTS_RUNNERS ) ; do\
347+ echo " ===========================================================" ; \
348+ echo " Running black on" $$ component; \
349+ echo " ===========================================================" ; \
350+ . $(VIRTUALENV_DIR ) /bin/activate ; black --check --config pyproject.toml $$ component/ || exit 1; \
351+ done
352+ # Python pack management actions
353+ . $(VIRTUALENV_DIR ) /bin/activate; black --check --config pyproject.toml contrib/* || exit 1;
354+ . $(VIRTUALENV_DIR ) /bin/activate; black --check --config pyproject.toml scripts/* .py || exit 1;
355+ . $(VIRTUALENV_DIR ) /bin/activate; black --check --config pyproject.toml tools/* .py || exit 1;
356+ . $(VIRTUALENV_DIR ) /bin/activate; black --check --config pyproject.toml pylint_plugins/* .py || exit 1;
357+
358+ # Black task which reformats the code using black
359+ .PHONY : black-format
360+ black : requirements .black-format
361+
362+ .PHONY : .black-format
363+ .black-format :
364+ @echo
365+ @echo " ================== black ===================="
366+ @echo
367+ # st2 components
368+ @for component in $(COMPONENTS ) ; do\
369+ echo " ===========================================================" ; \
370+ echo " Running black on" $$ component; \
371+ echo " ===========================================================" ; \
372+ . $(VIRTUALENV_DIR ) /bin/activate ; black --config pyproject.toml $$ component/ || exit 1; \
373+ done
374+ # runner modules and packages
375+ @for component in $(COMPONENTS_RUNNERS ) ; do\
376+ echo " ===========================================================" ; \
377+ echo " Running black on" $$ component; \
378+ echo " ===========================================================" ; \
379+ . $(VIRTUALENV_DIR ) /bin/activate ; black --config pyproject.toml $$ component/ || exit 1; \
380+ done
381+ . $(VIRTUALENV_DIR ) /bin/activate; black --config pyproject.toml contrib/ || exit 1;
382+ . $(VIRTUALENV_DIR ) /bin/activate; black --config pyproject.toml scripts/* .py || exit 1;
383+ . $(VIRTUALENV_DIR ) /bin/activate; black --config pyproject.toml tools/* .py || exit 1;
384+ . $(VIRTUALENV_DIR ) /bin/activate; black --config pyproject.toml pylint_plugins/* .py || exit 1;
385+
329386.PHONY : lint-api-spec
330387lint-api-spec : requirements .lint-api-spec
331388
@@ -979,7 +1036,7 @@ debs:
9791036ci : ci-checks ci-unit ci-integration ci-packs-tests
9801037
9811038.PHONY : ci-checks
982- ci-checks : .generated-files-check .pylint .flake8 check-requirements check-sdist-requirements .st2client-dependencies-check .st2common-circular-dependencies-check circle-lint-api-spec .rst-check .st2client-install-check check-python-packages
1039+ ci-checks : .generated-files-check .black-check . pylint .flake8 check-requirements check-sdist-requirements .st2client-dependencies-check .st2common-circular-dependencies-check circle-lint-api-spec .rst-check .st2client-install-check check-python-packages
9831040
9841041.PHONY : .rst-check
9851042.rst-check :
0 commit comments