From 5d7e1291ce5ccdcf2c959821c6a65923a4f5f88e Mon Sep 17 00:00:00 2001 From: Jelte Fennema-Nio Date: Mon, 20 Oct 2025 17:26:50 +0200 Subject: [PATCH 1/2] CI: Add task that runs pgindent At PGConf.dev 2025 one thing that came up in the "Scaling PostgreSQL Development" unconference session is that new hackers don't know all the details of our development flow by heart yet. Of course it's documented on the wiki, but even if they find the relevant wiki pages they often still miss/forget things. One of the things they often forget is formatting their code. The consensus at that session was that it was probably worth adding a CI task for this to nudge newcomers to indent their code. We're not too worried about this new requirement scaring away newcomers, since autoformatting has become fairly commonplace in open source development. Also committers can of course still choose to format the patch themselves before committing if the formatting is failing. This might also help reduce the number of unindented commits that committers push, which require a follow up "fix indent" commit to make the koel buildfarm animal happy again. --- .cirrus.star | 1 + .cirrus.tasks.yml | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/.cirrus.star b/.cirrus.star index e9bb672b9593..b1662850ed07 100644 --- a/.cirrus.star +++ b/.cirrus.star @@ -96,6 +96,7 @@ def compute_environment_vars(): operating_systems = [ 'compilerwarnings', + 'formattingcheck', 'freebsd', 'linux', 'macos', diff --git a/.cirrus.tasks.yml b/.cirrus.tasks.yml index 038d043d00e7..a47d95d1cd16 100644 --- a/.cirrus.tasks.yml +++ b/.cirrus.tasks.yml @@ -1021,3 +1021,40 @@ task: always: upload_caches: ccache + + +# Check that code follows formatting standards +task: + name: FormattingCheck + + env: + CPUS: 2 + IMAGE_FAMILY: pg-ci-bookworm + + <<: *linux_task_template + + depends_on: SanityCheck + only_if: $CI_FORMATTINGCHECK_ENABLED + allow_failures: true + + create_user_script: | + useradd -m postgres + chown -R postgres:postgres . + + # Configure and build pg_bsd_indent + configure_script: | + su postgres <<-EOF + meson setup --auto-features=disabled build + EOF + + build_pg_bsd_indent_script: | + su postgres <<-EOF + ninja -C build src/tools/pg_bsd_indent/pg_bsd_indent + EOF + + # Check C code formatting with pgindent + check_pgindent_script: | + su postgres <<-EOF + export PATH="$(pwd)/build/src/tools/pg_bsd_indent:\$PATH" + src/tools/pgindent/pgindent --check --diff src contrib + EOF From 43032c4e70a97cabe3e8e9742c43f9c85748d0b8 Mon Sep 17 00:00:00 2001 From: Jelte Fennema-Nio Date: Wed, 22 Oct 2025 10:03:31 +0200 Subject: [PATCH 2/2] Wrong indent to test job --- src/backend/tcop/postgres.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 7dd75a490aab..d49be15100bd 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -5218,8 +5218,8 @@ enable_statement_timeout(void) if (StatementTimeout > 0 && (StatementTimeout < TransactionTimeout || TransactionTimeout == 0)) { - if (!get_timeout_active(STATEMENT_TIMEOUT)) - enable_timeout_after(STATEMENT_TIMEOUT, StatementTimeout); +if (!get_timeout_active(STATEMENT_TIMEOUT)) + enable_timeout_after(STATEMENT_TIMEOUT, StatementTimeout); } else {