jjb: babeltrace: run tools/format-cpp.sh to check C++ formatting
authorSimon Marchi <simon.marchi@efficios.com>
Fri, 8 Dec 2023 16:10:40 +0000 (11:10 -0500)
committerMichael Jeanson <mjeanson@efficios.com>
Fri, 15 Dec 2023 21:24:12 +0000 (16:24 -0500)
Change-Id: I87ce874d12792697522c4a5b92dd120e138791b3
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
jobs/babeltrace.yaml
scripts/babeltrace/lint.sh [new file with mode: 0755]
scripts/babeltrace/pylint.sh [deleted file]

index ffcf5c3b9ebb4f448f739922b73f5c74965c0502..2d5fe2aa39b56cd9a230e8cd37ebedf43fab5a4e 100644 (file)
     <<: *babeltrace_publishers_review
 
 - job-template:
-    name: 'dev_review_babeltrace_{version}_pylint'
+    name: 'dev_review_babeltrace_{version}_lint'
     defaults: babeltrace
     concurrent: true
 
 
     builders:
       - shell:
-         !include-raw-escape: scripts/babeltrace/pylint.sh
+         !include-raw-escape: scripts/babeltrace/lint.sh
 
     properties:
       - inject:
           days-to-keep: 1
 
     publishers:
+      - archive:
+          artifacts: 'black.out,flake8.out,isort.out,clang-format.out'
+          allow-empty: false
       - workspace-cleanup: *babeltrace_publisher_workspace-cleanup_defaults
 
 - job-template:
       - ircbot: *babeltrace_publisher_ircbot_defaults
 
 - job-template:
-    name: babeltrace_{version}_pylint
+    name: babeltrace_{version}_lint
     defaults: babeltrace
     node: 'deb12-amd64'
 
 
     builders:
        - shell:
-          !include-raw-escape: scripts/babeltrace/pylint.sh
+          !include-raw-escape: scripts/babeltrace/lint.sh
 
     publishers:
       - workspace-cleanup: *babeltrace_publisher_workspace-cleanup_defaults
       - archive:
-          artifacts: 'black.out,flake8.out,isort.out'
+          artifacts: 'black.out,flake8.out,isort.out,clang-format.out'
           allow-empty: false
       - ircbot: *babeltrace_publisher_ircbot_defaults
       - email-ext: *babeltrace_publisher_email-ext_defaults
       - 'babeltrace_{version}_release':
           version: v2.0
       - 'babeltrace_{version}_scan-build'
-      - 'babeltrace_{version}_pylint'
+      - 'babeltrace_{version}_lint'
       - 'babeltrace_{version}_coverity':
           version: master
       - '{job_prefix}babeltrace_{version}_glib-2.28.6':
           filter: ''
           touchstone: ''
       - 'dev_review_babeltrace_{version}_check-format'
-      - 'dev_review_babeltrace_{version}_pylint'
+      - 'dev_review_babeltrace_{version}_lint'
 
 
 - project:
diff --git a/scripts/babeltrace/lint.sh b/scripts/babeltrace/lint.sh
new file mode 100755 (executable)
index 0000000..9471f43
--- /dev/null
@@ -0,0 +1,68 @@
+#!/bin/bash
+#
+# Copyright (C) 2019 Michael Jeanson <mjeanson@efficios.com>
+# Copyright (C) 2019 Francis Deslauriers <francis.deslauriers@efficios.com>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+set -exu
+
+set -o pipefail
+
+PYTHON3=python3
+
+SRCDIR="$WORKSPACE/src/babeltrace"
+PYENV_HOME="$WORKSPACE/.pyenv/"
+
+# Delete previously built virtualenv
+if [ -d "$PYENV_HOME" ]; then
+    rm -rf "$PYENV_HOME"
+fi
+
+# Create virtualenv and install necessary packages
+virtualenv --system-site-packages -p ${PYTHON3} "$PYENV_HOME"
+
+set +ux
+# shellcheck disable=SC1090,SC1091
+. "$PYENV_HOME/bin/activate"
+set -ux
+
+if [ -f "$SRCDIR/dev-requirements.txt" ]; then
+    pip install -r "$SRCDIR/dev-requirements.txt"
+else
+    pip install black flake8 isort
+fi
+
+exit_code=0
+
+cd "$SRCDIR"
+
+black --diff --check . | tee ../../black.out || exit_code=1
+flake8 --output-file=../../flake8.out --tee || exit_code=1
+
+ISORT_UNSUPPORTED_BRANCH_REGEX='.*(stable-1\.5|stable-2\.0)$'
+
+if [[ ! ${GIT_BRANCH:-} =~ $ISORT_UNSUPPORTED_BRANCH_REGEX ]] && \
+    [[ ! ${GERRIT_BRANCH:-} =~ $ISORT_UNSUPPORTED_BRANCH_REGEX ]]; then
+    isort . --diff --check | tee ../../isort.out || exit_code=1
+else
+    echo "isort is not supported on the 'stable-2.0' branch" > ../../isort.out
+fi
+
+if [[ -f tools/format-cpp.sh ]]; then
+    FORMATTER="clang-format-15 -i" tools/format-cpp.sh
+    git diff --exit-code | tee ../../clang-format.out || exit_code=1
+fi
+
+exit $exit_code
diff --git a/scripts/babeltrace/pylint.sh b/scripts/babeltrace/pylint.sh
deleted file mode 100755 (executable)
index 63e02a8..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-#!/bin/bash
-#
-# Copyright (C) 2019 Michael Jeanson <mjeanson@efficios.com>
-# Copyright (C) 2019 Francis Deslauriers <francis.deslauriers@efficios.com>
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-set -exu
-
-set -o pipefail
-
-PYTHON3=python3
-
-SRCDIR="$WORKSPACE/src/babeltrace"
-PYENV_HOME="$WORKSPACE/.pyenv/"
-
-# Delete previously built virtualenv
-if [ -d "$PYENV_HOME" ]; then
-    rm -rf "$PYENV_HOME"
-fi
-
-# Create virtualenv and install necessary packages
-virtualenv --system-site-packages -p ${PYTHON3} "$PYENV_HOME"
-
-set +ux
-# shellcheck disable=SC1090,SC1091
-. "$PYENV_HOME/bin/activate"
-set -ux
-
-if [ -f "$SRCDIR/dev-requirements.txt" ]; then
-    pip install -r "$SRCDIR/dev-requirements.txt"
-else
-    pip install black flake8 isort
-fi
-
-exit_code=0
-
-cd "$SRCDIR"
-
-black --diff --check . | tee ../../black.out || exit_code=1
-flake8 --output-file=../../flake8.out --tee || exit_code=1
-
-ISORT_UNSUPPORTED_BRANCH_REGEX='.*(stable-1\.5|stable-2\.0)$'
-
-if [[ ! ${GIT_BRANCH:-} =~ $ISORT_UNSUPPORTED_BRANCH_REGEX ]] && \
-    [[ ! ${GERRIT_BRANCH:-} =~ $ISORT_UNSUPPORTED_BRANCH_REGEX ]]; then
-    isort . --diff --check | tee ../../isort.out || exit_code=1
-else
-    echo "isort is not supported on the 'stable-2.0' branch" > ../../isort.out
-fi
-
-exit $exit_code
This page took 0.030565 seconds and 4 git commands to generate.