Verified Commit a640d0b7 authored by Thomas Haller's avatar Thomas Haller
Browse files

build: merge branch 'th/python-black'

!1174
parents 5d440610 bb605eab
Pipeline #548087 passed with stages
in 37 minutes and 6 seconds
......@@ -47,11 +47,11 @@ variables:
#
# This is done by running `ci-fairy generate-template` and possibly bump
# ".default_tag".
FEDORA_TAG: '2022-03-15.0-a017895d3124'
UBUNTU_TAG: '2022-03-15.0-0d592fa70bc5'
DEBIAN_TAG: '2022-03-15.0-0d592fa70bc5'
CENTOS_TAG: '2022-03-15.0-a017895d3124'
ALPINE_TAG: '2022-03-15.0-65bef47ff3ce'
FEDORA_TAG: '2022-03-15.0-7b3d39bfc5ca'
UBUNTU_TAG: '2022-03-15.0-2cd0d40675ab'
DEBIAN_TAG: '2022-03-15.0-2cd0d40675ab'
CENTOS_TAG: '2022-03-15.0-7b3d39bfc5ca'
ALPINE_TAG: '2022-03-15.0-17672b94a192'
FEDORA_EXEC: 'bash .gitlab-ci/fedora-install.sh'
UBUNTU_EXEC: 'bash .gitlab-ci/debian-install.sh'
......@@ -980,7 +980,7 @@ check-tree:
- "fedora:35@container-prep"
stage: test
script:
- date '+%Y%m%d-%H%M%S'; black --check . examples/python/gi/nm-wg-set
- date '+%Y%m%d-%H%M%S'; contrib/scripts/nm-python-black-format.sh --check
- date '+%Y%m%d-%H%M%S'; git ls-files -z -- 'po/*.po' | xargs -0 -n1 msgfmt -vc
- date '+%Y%m%d-%H%M%S'; contrib/scripts/nm-code-format.sh -n
- date '+%Y%m%d-%H%M%S'; ci-fairy generate-template && git diff --exit-code
......
......@@ -220,7 +220,7 @@ check-tree:
- "{{pages_build.name}}:{{pages_build.version}}@container-prep"
stage: test
script:
- date '+%Y%m%d-%H%M%S'; black --check . examples/python/gi/nm-wg-set
- date '+%Y%m%d-%H%M%S'; contrib/scripts/nm-python-black-format.sh --check
- date '+%Y%m%d-%H%M%S'; git ls-files -z -- 'po/*.po' | xargs -0 -n1 msgfmt -vc
- date '+%Y%m%d-%H%M%S'; contrib/scripts/nm-code-format.sh -n
- date '+%Y%m%d-%H%M%S'; ci-fairy generate-template && git diff --exit-code
......
......@@ -21,12 +21,6 @@ meson --version
! command -v yum &>/dev/null || yum list installed
! command -v apk &>/dev/null || apk -v info
# The formatting depends on the version of python black.
# We have a dedicated test that checks our formatting, which
# uses the right version. We should disable the check during
# `make check`.
export NMTST_SKIP_PYTHON_BLACK=1
# We have a unit test that check that `ci-fairy generate-template`
# is equal to our .gitlab-ci.yml file. However, on gitlab-ci we
# also have a dedicate test for the same thing. We don't need
......
......@@ -5679,12 +5679,6 @@ CLEANFILES += \
include Makefile.examples
if WITH_PYTHON_BLACK
check-python-black:
test "$$NMTST_SKIP_PYTHON_BLACK" == 1 || $(BLACK) --check $(top_srcdir) $(top_srcdir)/examples/python/gi/nm-wg-set
check_local += check-python-black
endif
###############################################################################
check-tree:
......
......@@ -1320,10 +1320,6 @@ 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 \
......
......@@ -52,7 +52,6 @@ usage() {
printf "Usage: %s [OPTION]... [FILE]...\n" "$(basename "$0")"
printf "Reformat source files using NetworkManager's code-style.\n\n"
printf "If no file is given the script runs on the whole codebase.\n"
printf "If no flag is given no file is touch but errors are reported.\n\n"
printf "OPTIONS:\n"
printf " -i Reformat files (this is the default)\n"
printf " -n|--dry-run Only check the files (contrary to \"-i\")\n"
......
#!/bin/bash
set -e
_print() {
printf '%s\n' "$*" >&2
}
die() {
_print "$*"
exit 1
}
NM_ROOT="$(git rev-parse --show-toplevel)" || die "not inside a git repository"
NM_PREFIX="$(git rev-parse --show-prefix)" || die "not inside a git repository"
cd "$NM_ROOT" || die "failed to cd into \$NM_ROOT\""
if [ ! -f "./src/core/main.c" ]; then
die "Error: \"$NM_ROOT\" does not look like NetworkManager source tree"
fi
BLACK="${BLACK:-black}"
if ! command -v "$BLACK" &> /dev/null; then
_print "Error: black is not installed. On RHEL/Fedora/CentOS run 'dnf install black'"
exit 77
fi
OLD_IFS="$IFS"
IFS=$'\n'
FILES=( $(git ls-tree --name-only -r HEAD | grep '\.py$') )
IFS="$OLD_IFS"
FILES+=(
"examples/python/gi/nm-wg-set"
)
usage() {
printf "Usage: %s [OPTION]...\n" "$(basename "$0")"
printf "Reformat python source files using python black.\n\n"
printf "OPTIONS:\n"
printf " -i Reformat files (this is the default)\n"
printf " -n|--dry-run|--check Only check the files (contrary to \"-i\")\n"
printf " --show-filenames Only print the filenames that would be checked/formatted\n"
printf " -h Print this help message\n"
}
TEST_ONLY=0
SHOW_FILENAMES=0
while (( $# )); do
case "$1" in
-h)
usage
exit 0
;;
-n|--dry-run|--check)
TEST_ONLY=1
shift
continue
;;
-i)
TEST_ONLY=0
shift
continue
;;
--show-filenames)
SHOW_FILENAMES=1
shift
continue
;;
*)
usage
exit 1
;;
esac
done
if [ $SHOW_FILENAMES = 1 ]; then
printf '%s\n' "${FILES[@]}"
exit 0
fi
EXTRA_ARGS=()
if [ $TEST_ONLY = 1 ]; then
EXTRA_ARGS+=('--check')
fi
"$BLACK" "${EXTRA_ARGS[@]}" "${FILES[@]}"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment