From c95fa1c2129666fd632cc29a4352d9e6ce719ae0 Mon Sep 17 00:00:00 2001 From: Bharath Rupireddy Date: Fri, 8 Dec 2023 11:27:50 +0000 Subject: [PATCH v1] Add code indentation check to cirrus-ci --- .cirrus.tasks.yml | 59 ++++++++++++++++++++++++ src/tools/pgindent/exclude_file_patterns | 4 ++ 2 files changed, 63 insertions(+) diff --git a/.cirrus.tasks.yml b/.cirrus.tasks.yml index e137769850..a16375b9e7 100644 --- a/.cirrus.tasks.yml +++ b/.cirrus.tasks.yml @@ -777,3 +777,62 @@ task: always: upload_caches: ccache + +task: + name: IndentationCheck + + depends_on: SanityCheck + only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' + + env: + CPUS: 2 + BUILD_JOBS: 4 + IMAGE_FAMILY: pg-ci-bullseye + # only for indentation check no tests, should be small + CCACHE_MAXSIZE: "150M" + CCACHE_DIR: "/tmp/ccache_dir" + + <<: *linux_task_template + + sysinfo_script: | + id + uname -a + cat /proc/cmdline + ulimit -a -H && ulimit -a -S + gcc -v + g++ -v + export + + ccache_cache: + folder: $CCACHE_DIR + + ### + # Compile the source code with gcc. Enable code under assert macro for + # indentation check. + ### + build_script: | + time ./configure \ + --cache gcc.cache \ + --enable-cassert \ + ${LINUX_CONFIGURE_FEATURES} \ + CC="ccache gcc" CXX="ccache g++" + make -s -j${BUILD_JOBS} clean + time make -s -j${BUILD_JOBS} world-bin + + ### + # Check the source code indentation. + ### + test_code_indentation_script: | + make -C src/tools/pg_bsd_indent/ -j${BUILD_JOBS} install + time src/tools/pgindent/pgindent \ + --indent=src/tools/pg_bsd_indent/pg_bsd_indent \ + --show-diff \ + $(pwd) > pgindent.diffs + test -s pgindent.diffs && cat pgindent.diffs && exit 1 || exit 0 + + on_failure: + indentation_artifacts: + path: "pgindent.diffs" + type: text/plain + + upload_caches: ccache diff --git a/src/tools/pgindent/exclude_file_patterns b/src/tools/pgindent/exclude_file_patterns index 6405a00511..a311507249 100644 --- a/src/tools/pgindent/exclude_file_patterns +++ b/src/tools/pgindent/exclude_file_patterns @@ -46,6 +46,10 @@ src/include/pg_config\.h$ src/pl/plperl/ppport\.h$ src/pl/plperl/SPI\.c$ src/pl/plperl/Util\.c$ +src/backend/nodes/nodetags\.h$ +src/backend/utils/activity/pgstat_wait_event\.c$ +src/backend/utils/activity/wait_event_types\.h$ +src/backend/utils/activity/wait_event_funcs_data\.c$ # # pg_bsd_indent has its own, idiosyncratic indentation style. # We'll stick to that to permit comparison with the FreeBSD upstream. -- 2.34.1