run pgindent in CI

Поиск
Список
Период
Сортировка
Искать

run pgindent in CI

От:
Peter Eisentraut <peter@eisentraut.org>
Дата:
Вложения:
Previously discussed in [0].  People seemed to generally like the idea 
of running pgindent in CI but didn't want the job to fail outright if 
there were violations.  My proposal here is to use a combination of 
GitHub Actions features [1] to create job annotations and step summaries 
to create some kind of warning output.  I have attached an example 
screenshot.

I also added a git whitespace check in the same way.  Additional 
formatting checks like pgperltidy, Python stuff, etc. could be added 
similarly.

(I imagine there could be some cfbot integration that represents these 
annotations in a non-threatening way, but I have not looked into that at 
all.)

One surprise from this is that this generates a massive pgindent diff 
against the current tree, because there are a bunch of entries missing 
or wrong in src/tools/pgindent/exclude_file_patterns.  I guess most 
people don't see this because these are mostly generated files, which 
would get reindented but then ignored via gitignore, but if you run 
pgindent --check --diff, then this will show up.

I don't exactly know how the buildfarm member koel gets away with this. 
The notes say "Runs pgindent --show-diff", but that is not an actual 
existing option.  One evident difference is that koel runs meson, but I 
have added this to the existing CompilerWarnings job and reused the tree 
from the headerscheck step, which uses autoconf.  Anyway, maybe this 
could be improved sometime to reduce variability, but for now I have 
just included a patch to update exclude_file_patterns as needed.

Thoughts?


[0]: 
https://www.postgresql.org/message-id/flat/DDNZTVO6E6GF.17IEQGZ1GC9D7%40jeltef.nl

[1]: 
https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-commands

Re: run pgindent in CI

От:
Andrew Dunstan <andrew@dunslane.net>
Дата:

On 2026-09-22 Tu 3:10 AM, Peter Eisentraut wrote:
> Previously discussed in [0].  People seemed to generally like the idea 
> of running pgindent in CI but didn't want the job to fail outright if 
> there were violations.  My proposal here is to use a combination of 
> GitHub Actions features [1] to create job annotations and step 
> summaries to create some kind of warning output.  I have attached an 
> example screenshot.
>
> I also added a git whitespace check in the same way.  Additional 
> formatting checks like pgperltidy, Python stuff, etc. could be added 
> similarly.
>
> (I imagine there could be some cfbot integration that represents these 
> annotations in a non-threatening way, but I have not looked into that 
> at all.)
>
> One surprise from this is that this generates a massive pgindent diff 
> against the current tree, because there are a bunch of entries missing 
> or wrong in src/tools/pgindent/exclude_file_patterns.  I guess most 
> people don't see this because these are mostly generated files, which 
> would get reindented but then ignored via gitignore, but if you run 
> pgindent --check --diff, then this will show up.
>
> I don't exactly know how the buildfarm member koel gets away with 
> this. The notes say "Runs pgindent --show-diff", but that is not an 
> actual existing option.  One evident difference is that koel runs 
> meson, but I have added this to the existing CompilerWarnings job and 
> reused the tree from the headerscheck step, which uses autoconf.  
> Anyway, maybe this could be improved sometime to reduce variability, 
> but for now I have just included a patch to update 
> exclude_file_patterns as needed.


The notes are out of date re --show-diff.

You can see what koel does - it's a special buildfarm module at 
https://github.com/PGBuildFarm/client-code/blob/main/PGBuild/Modules/CheckIndent.pm

It just runs:

    src/tools/pgindent/pgindent --diff --check .

Of course, that's against a pure source tree. The build tree is 
elsewhere and the module never points pgindent at it. Even if koel were 
using configure/make, I would have set it up to do vpath builds.

Note that you can specify extra exclude files on pgindent's command line 
as well, so if your builddir is inside your source tree it would make 
sense to specify one pointing at the builddir. That's not going to help 
you if you build in-tree using configure/make. I guess I would say don't 
do that and then run pgindent.


cheers


andrew


--
Andrew Dunstan
EDB: https://www.enterprisedb.com



Re: run pgindent in CI

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Andrew Dunstan  writes:
> On 2026-09-22 Tu 3:10 AM, Peter Eisentraut wrote:
>> One surprise from this is that this generates a massive pgindent diff 
>> against the current tree, because there are a bunch of entries missing 
>> or wrong in src/tools/pgindent/exclude_file_patterns.  I guess most 
>> people don't see this because these are mostly generated files, which 
>> would get reindented but then ignored via gitignore, but if you run 
>> pgindent --check --diff, then this will show up.

> [koel] just runs:
>     src/tools/pgindent/pgindent --diff --check .
> Of course, that's against a pure source tree.

Yeah, I generally run pgindent against a clean tree as well.  We have
made some efforts to make generated files be pgindent-clean, but
it's been pretty haphazard, and I doubt we want to make a project
policy requiring that.  So really the right thing is to make this
CI module do likewise.

			regards, tom lane


Re: run pgindent in CI

От:
Nathan Bossart <nathandbossart@gmail.com>
Дата:
On Tue, Sep 22, 2026 at 09:10:23AM +0200, Peter Eisentraut wrote:
> Previously discussed in [0].  People seemed to generally like the idea of
> running pgindent in CI but didn't want the job to fail outright if there
> were violations.  My proposal here is to use a combination of GitHub Actions
> features [1] to create job annotations and step summaries to create some
> kind of warning output.  I have attached an example screenshot.

+1.  I think it'd be nice if the commitfest app showed some sort of
indicator, too.

FWIW I've been using my own custom pgindent for a couple of months that is
much faster, which might be nice if we're going to start running it in CI.
I just haven't gotten to posting the patches.  The main ideas are 1)
running in parallel and 2) parsing typedefs.list once per run.  That pretty
dramatically decreases the duration of a whole-tree indent.

-- 
nathan


Re: run pgindent in CI

От:
Peter Eisentraut <peter@eisentraut.org>
Дата:
On 22.09.26 16:04, Tom Lane wrote:
> Andrew Dunstan  writes:
>> On 2026-09-22 Tu 3:10 AM, Peter Eisentraut wrote:
>>> One surprise from this is that this generates a massive pgindent diff
>>> against the current tree, because there are a bunch of entries missing
>>> or wrong in src/tools/pgindent/exclude_file_patterns.  I guess most
>>> people don't see this because these are mostly generated files, which
>>> would get reindented but then ignored via gitignore, but if you run
>>> pgindent --check --diff, then this will show up.
> 
>> [koel] just runs:
>>      src/tools/pgindent/pgindent --diff --check .
>> Of course, that's against a pure source tree.
> 
> Yeah, I generally run pgindent against a clean tree as well.  We have
> made some efforts to make generated files be pgindent-clean, but
> it's been pretty haphazard, and I doubt we want to make a project
> policy requiring that.  So really the right thing is to make this
> CI module do likewise.

For clarification:  We already have a exclude_file_patterns that 
excludes many generated files.  It just didn't exclude enough of them. 
Things were just forgotten.  So this proposal is not introducing a new 
policy or requirement, it just fixes things so that the implementation 
of the current apparent policy is complete.

We could also desupport running pgindent in a tree with both sources and 
built files.  But then we should do that explicitly and remove the 
leftover support for that.  However, I wouldn't be in favor of that 
unless we desupported in-tree (non-vpath) builds altogether.  In any 
case, a patch to complete the exclude_file_patterns list for the time 
being does exist, so this does not have to be decided urgently.



Re: run pgindent in CI

От:
Nazir Bilal Yavuz <byavuz81@gmail.com>
Дата:
Hi,

On Tue, 22 Sept 2026 at 10:11, Peter Eisentraut  wrote:
>
> Previously discussed in [0].  People seemed to generally like the idea
> of running pgindent in CI but didn't want the job to fail outright if
> there were violations.  My proposal here is to use a combination of
> GitHub Actions features [1] to create job annotations and step summaries
> to create some kind of warning output.  I have attached an example
> screenshot.
>
> I also added a git whitespace check in the same way.  Additional
> formatting checks like pgperltidy, Python stuff, etc. could be added
> similarly.
>
> Thoughts?

For the 0003, what do you think about just mentioning that 'the
style-check steps in the CompilerWarnings have failed' instead of
printing the diff? That would make sense since we won't actually need
to understand the diff (AFAIK), we just need to run some tools.

--
Regards,
Nazir Bilal Yavuz
Microsoft


Re: run pgindent in CI

От:
Peter Eisentraut <peter@eisentraut.org>
Дата:
On 22.09.26 18:33, Nathan Bossart wrote:
> FWIW I've been using my own custom pgindent for a couple of months that is
> much faster, which might be nice if we're going to start running it in CI.
> I just haven't gotten to posting the patches.  The main ideas are 1)
> running in parallel and 2) parsing typedefs.list once per run.  That pretty
> dramatically decreases the duration of a whole-tree indent.

The timing of pgindent runs in this CI job aren't terribly critical in 
the overall context (8-10s).  Faster is better of course.  But I would 
be very interested in this improvement for local interactive use.



Re: run pgindent in CI

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Peter Eisentraut  writes:
> For clarification:  We already have a exclude_file_patterns that 
> excludes many generated files.  It just didn't exclude enough of them. 
> Things were just forgotten.  So this proposal is not introducing a new 
> policy or requirement, it just fixes things so that the implementation 
> of the current apparent policy is complete.

My point is exactly that that list hasn't been maintained, because
there was nothing to remind developers to do so.  So I'm doubtful
that there can meaningfully be claimed to be a policy requiring it.

If we want to change that, then making CI bitch about non-ignored
files would be a good step, but it's incomplete unless the buildfarm
implementation enforces indent cleanliness the same way.  IOW, what
I'm complaining about here is that what you want to do doesn't match
what koel does.  They need to match.

			regards, tom lane


Re: run pgindent in CI

От:
Jelte Fennema-Nio <postgres@jeltef.nl>
Дата:
On Tue, 22 Sept 2026 at 18:33, Nathan Bossart  wrote:
> FWIW I've been using my own custom pgindent for a couple of months that is
> much faster, which might be nice if we're going to start running it in CI.
> I just haven't gotten to posting the patches.  The main ideas are 1)
> running in parallel and 2) parsing typedefs.list once per run.  That pretty
> dramatically decreases the duration of a whole-tree indent.

See also[1] which adds parallel support and a bunch of other things.
Only parsing typedefs.list once sounds nice though. Would be good to
combine these efforts I think.

[1]: https://www.postgresql.org/message-id/DHJCUQA4HF9H.10EN25MHG0YRW%40jeltef.nl


Re: run pgindent in CI

От:
Peter Eisentraut <peter@eisentraut.org>
Дата:
On 23.09.26 16:35, Tom Lane wrote:
> If we want to change that, then making CI bitch about non-ignored
> files would be a good step, but it's incomplete unless the buildfarm
> implementation enforces indent cleanliness the same way.  IOW, what
> I'm complaining about here is that what you want to do doesn't match
> what koel does.  They need to match.

I have launched two new threads to prepare for this:

pgindent to ignore build directories
(https://www.postgresql.org/message-id/fc77b35a-34c4-4229-82f1-8cf0ce67f276%40eisentraut.org)

convert CI CompilerWarnings job to meson
(https://www.postgresql.org/message-id/e52e2c29-4834-4c64-a200-eddcba38fb4d%40eisentraut.org)

When those are done, it will be possible to reproduce the koel 
environment on CI, and we can come back to this.



Re: run pgindent in CI

От:
Peter Eisentraut <peter@eisentraut.org>
Дата:
Вложения:
On 24.09.26 17:15, Peter Eisentraut wrote:
> On 23.09.26 16:35, Tom Lane wrote:
>> If we want to change that, then making CI bitch about non-ignored
>> files would be a good step, but it's incomplete unless the buildfarm
>> implementation enforces indent cleanliness the same way.  IOW, what
>> I'm complaining about here is that what you want to do doesn't match
>> what koel does.  They need to match.
> 
> I have launched two new threads to prepare for this:
> 
> pgindent to ignore build directories
> (https://www.postgresql.org/message-id/ 
> fc77b35a-34c4-4229-82f1-8cf0ce67f276%40eisentraut.org)
> 
> convert CI CompilerWarnings job to meson
> (https://www.postgresql.org/message-id/e52e2c29-4834-4c64-a200- 
> eddcba38fb4d%40eisentraut.org)
> 
> When those are done, it will be possible to reproduce the koel 
> environment on CI, and we can come back to this.

The above have been done, so here we are back on this.

I have adapted the workflow code to use meson now.  I have also dropped 
the github step summary display; the output (pgindent diff etc.) is now 
just inline in the job logs.  It's all pretty simple and straightforward 
now.

I've kept the exclude_file_patterns patch here.  I think we should still 
apply this.  As long as that file exists, we should keep it up to date, 
and the patch was already written.


Re: run pgindent in CI

От:
Peter Geoghegan <pg@bowt.ie>
Дата:
On Thu, Nov 5, 2026 at 3:01 PM Peter Eisentraut  wrote:
> The above have been done, so here we are back on this.

It takes me about 7 seconds to run pgindent locally, on my fast
workstation. I prefer to run it exactly as koel does, for obvious
reasons.

Are you sure that this is an appropriate use of CI cycles? Nathan had
a patch that made pgindent run much faster. Perhaps that should be
committed first?

-- 
Peter Geoghegan


Re: run pgindent in CI

От:
Nathan Bossart <nathandbossart@gmail.com>
Дата:
On Thu, Nov 05, 2026 at 03:26:31PM -0500, Peter Geoghegan wrote:
> Are you sure that this is an appropriate use of CI cycles? Nathan had
> a patch that made pgindent run much faster. Perhaps that should be
> committed first?

(apologies for not getting this posted yet, I still plan to do so)

-- 
nathan


Re: run pgindent in CI

От:
Peter Eisentraut <peter@eisentraut.org>
Дата:
On 05.11.26 21:26, Peter Geoghegan wrote:
> On Thu, Nov 5, 2026 at 3:01 PM Peter Eisentraut  wrote:
>> The above have been done, so here we are back on this.
> 
> It takes me about 7 seconds to run pgindent locally, on my fast
> workstation. I prefer to run it exactly as koel does, for obvious
> reasons.
> 
> Are you sure that this is an appropriate use of CI cycles?

Based on my testing, 7 seconds is trivial compared to everything else 
that is going on in a CI run.  The CompilerWarnings job is regularly 
faster than all the other jobs.  We have about 5 minutes we can fill 
with stuff there before it would affect the overall experience, not that 
I'm proposing to do that.

> Nathan had
> a patch that made pgindent run much faster. Perhaps that should be
> committed first?

I think that would be lost in the noise on CI.  It would be welcome for 
local use, of course.


Re: run pgindent in CI

От:
Tomas Vondra <tomas@vondra.me>
Дата:


On 11/5/26 22:34, Peter Eisentraut wrote:
> On 05.11.26 21:26, Peter Geoghegan wrote:
>> On Thu, Nov 5, 2026 at 3:01 PM Peter Eisentraut 
>> wrote:
>>> The above have been done, so here we are back on this.
>>
>> It takes me about 7 seconds to run pgindent locally, on my fast
>> workstation. I prefer to run it exactly as koel does, for obvious
>> reasons.
>>
>> Are you sure that this is an appropriate use of CI cycles?
> 
> Based on my testing, 7 seconds is trivial compared to everything else
> that is going on in a CI run.  The CompilerWarnings job is regularly
> faster than all the other jobs.  We have about 5 minutes we can fill
> with stuff there before it would affect the overall experience, not that
> I'm proposing to do that.
> 

+1

pgindent is one of things I regularly forget to run before pushing,
after some last minute changes and waiting for CI. And then I remember
one second after pushing. 7s is worth getting rid of that stress.

>> Nathan had
>> a patch that made pgindent run much faster. Perhaps that should be
>> committed first?
> 
> I think that would be lost in the noise on CI.  It would be welcome for
> local use, of course.


I don't know how Nathan's patch works, but couldn't we keep track of
"high watermark" of commits that are pgindent-free, and then run
pgindent only on files modified by commits since then? The watermark
would need to be updated somewhat regularly, ofc.

regards

-- 
Tomas Vondra



Re: run pgindent in CI

От:
Peter Geoghegan <pg@bowt.ie>
Дата:
On Thu, Nov 5, 2026 at 4:35 PM Peter Eisentraut  wrote:
> I think that would be lost in the noise on CI.  It would be welcome for
> local use, of course.

Another way of looking at it: if we're now going to start requiring
that every patch be pgindent'ed at all times, or else we get these
soft CI failures, it really should be as easy as possible to be in
compliance.

-- 
Peter Geoghegan


Re: run pgindent in CI

От:
Andrew Dunstan <andrew@dunslane.net>
Дата:

On 2026-11-05 Th 4:47 PM, Tomas Vondra wrote:
>
> On 11/5/26 22:34, Peter Eisentraut wrote:
>> On 05.11.26 21:26, Peter Geoghegan wrote:
>>> On Thu, Nov 5, 2026 at 3:01 PM Peter Eisentraut 
>>> wrote:
>>>> The above have been done, so here we are back on this.
>>> It takes me about 7 seconds to run pgindent locally, on my fast
>>> workstation. I prefer to run it exactly as koel does, for obvious
>>> reasons.
>>>
>>> Are you sure that this is an appropriate use of CI cycles?
>> Based on my testing, 7 seconds is trivial compared to everything else
>> that is going on in a CI run.  The CompilerWarnings job is regularly
>> faster than all the other jobs.  We have about 5 minutes we can fill
>> with stuff there before it would affect the overall experience, not that
>> I'm proposing to do that.
>>
> +1
>
> pgindent is one of things I regularly forget to run before pushing,
> after some last minute changes and waiting for CI. And then I remember
> one second after pushing. 7s is worth getting rid of that stress.
>
>

I have a bunch of git hooks that do a lot of this checking for me. See 
https://github.com/adunstan/pg-git-hooks

The indent piece only tries to indent files changed in the commit, so 
it's almost always lightning fast.


cheers


andrew


--
Andrew Dunstan
EDB: https://www.enterprisedb.com



FAQ