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.
From fa860c40316df10ff8c09286607d53882f6ac6c6 Mon Sep 17 00:00:00 2001 From: Jelte Fennema-Nio <[email protected]> Date: Mon, 20 Oct 2025 17:26:50 +0200 Subject: [PATCH v1 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 | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 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..3d50cafc64c 100644 --- a/.cirrus.tasks.yml +++ b/.cirrus.tasks.yml @@ -1010,3 +1010,39 @@ 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 + + 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
