From 9f77d26ad0ffaa51d9b262ea4d9b28bbc58b6f68 Mon Sep 17 00:00:00 2001 From: Sayed Shah Date: Tue, 9 Jun 2020 16:22:51 -0400 Subject: [PATCH 1/4] build: create check for python black If python black is install then it would check the formating of all of the python files and test the for it. Otherwise, it would just simply ignore the python black if python black is not installed. --- Makefile.am | 5 +++++ configure.ac | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/Makefile.am b/Makefile.am index 285e07778f..71643080b0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5235,6 +5235,11 @@ CLEANFILES += \ ############################################################################### include Makefile.examples +if WITH_PYTHON_BLACK +check-python-black: + $(BLACK) --check $(top_srcdir) +check_local += check-python-black +endif ############################################################################### diff --git a/configure.ac b/configure.ac index 175ee554ed..2ace7ecaee 100644 --- a/configure.ac +++ b/configure.ac @@ -1272,6 +1272,10 @@ else have_introspection=no fi +# check for python black. And check if all files are formatted with python black +AC_PATH_PROG(BLACK, black) +AM_CONDITIONAL(WITH_PYTHON_BLACK, test "${BLACK}" != "") + # check for pregenerated manpages and documentation to be installed use_pregen_docs=no if test "$build_docs" != "yes" -a \ From c537852231a63431ee95ceb14968382e37e7aaea Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 19 Jun 2020 12:36:49 +0200 Subject: [PATCH 2/4] build: optionally skip python black check by setting NMTST_SKIP_PYTHON_BLACK=1 --- Makefile.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 71643080b0..db9f4c80c6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5235,9 +5235,10 @@ CLEANFILES += \ ############################################################################### include Makefile.examples + if WITH_PYTHON_BLACK check-python-black: - $(BLACK) --check $(top_srcdir) + test "$$NMTST_SKIP_PYTHON_BLACK" != 1 && $(BLACK) --check $(top_srcdir) check_local += check-python-black endif From 70f3ad6785d9e0e6a65b10789d7322ab802afb03 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 19 Jun 2020 12:47:07 +0200 Subject: [PATCH 3/4] gitlab-ci: run checkpatch test against fedora:32 target --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5e1ea7a99a..fa5ad46ad4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -74,7 +74,7 @@ stages: - date '+%Y%m%d-%H%M%S'; test "$NM_BUILD_TARBALL" != 1 || mv /tmp/NetworkManager-1*.tar.xz /tmp/NetworkManager-1*.src.rpm ./ checkpatch: - image: fedora:29 + image: fedora:32 stage: test script: - date '+%Y%m%d-%H%M%S'; dnf install -y git From 8c3ee4e8574d84258f34068486b33e10f0e87313 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 19 Jun 2020 12:43:38 +0200 Subject: [PATCH 4/4] gitlab-ci: enable python black check in gitlab-ci --- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fa5ad46ad4..389da67218 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -77,8 +77,9 @@ checkpatch: image: fedora:32 stage: test script: - - date '+%Y%m%d-%H%M%S'; dnf install -y git + - date '+%Y%m%d-%H%M%S'; dnf install -y git black - date '+%Y%m%d-%H%M%S'; NM_CHECKPATCH_FETCH_UPSTREAM=1 contrib/scripts/checkpatch-feature-branch.sh 2>&1 | tee checkpatch-out.txt + - date '+%Y%m%d-%H%M%S'; black --check . allow_failure: true artifacts: when: on_failure