On Tue, 21 Oct 2025 at 16:49, Jelte Fennema-Nio <[email protected]> wrote:
> By having it be a separate job I can easily make the
> cfbot and commitfest app report it as "yellow" instead of "red" if
> this job fails.

I set "allow_failures: true" in the cirrus task, so that a formatting
failure won't show the whole build as failed. I updated the commitfest
app to now show it with an orange cross instead of a red one (see
attached png). I included a patch that breaks indentation so I can
easily test this new behaviour end-to-end.
From 46a42d19f243e2844907d231e3f0d8155cffaa31 Mon Sep 17 00:00:00 2001
From: Jelte Fennema-Nio <[email protected]>
Date: Mon, 20 Oct 2025 17:26:50 +0200
Subject: [PATCH v2 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 e9bb672b959..b1662850ed0 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 eca9d62fc22..933426dd3b1 100644
--- a/.cirrus.tasks.yml
+++ b/.cirrus.tasks.yml
@@ -1010,3 +1010,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

base-commit: d74cfe3263fa0a35cb962570697f422775cd12d6
-- 
2.51.1

From 43a62a38f37e50580cc7b96a1a24407301aa5892 Mon Sep 17 00:00:00 2001
From: Jelte Fennema-Nio <[email protected]>
Date: Wed, 22 Oct 2025 10:03:31 +0200
Subject: [PATCH v2 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 7dd75a490aa..d49be15100b 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
 	{
-- 
2.51.1

Reply via email to