From 3c346d1da6479dd2ff2da37be5edb27e4ac2c423 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Tue, 22 Sep 2026 07:55:39 +0200 Subject: [PATCH 3/3] Add advisory pgindent check to CompilerWarnings CI job Run pgindent --check --diff over the whole tree at the end of the CompilerWarnings job, reusing the configured tree left behind by the headerscheck step to build pg_bsd_indent. Also run a git whitespace check. These checks are advisory only: violations produce a warning annotation and the output in the job's step summary, but do not fail the workflow. Discussion: https://www.postgresql.org/message-id/flat/DDNZTVO6E6GF.17IEQGZ1GC9D7%40jeltef.nl --- .github/workflows/pg-ci.yml | 68 ++++++++++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pg-ci.yml b/.github/workflows/pg-ci.yml index a2629c8335a..5e47ef0bdad 100644 --- a/.github/workflows/pg-ci.yml +++ b/.github/workflows/pg-ci.yml @@ -1150,7 +1150,7 @@ jobs: # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have # a history of getting accidentally broken; the matrix is there to - # catch that. + # catch that. Also runs some other source-level checks. # # The autoconf cache files (gcc.cache / clang.cache) are intentionally # reused across the matrix entries that share a compiler, so we don't @@ -1271,6 +1271,72 @@ jobs: headerscheck cpluspluscheck \ EXTRAFLAGS='-fmax-errors=10' + ### + # Verify the tree is pgindent-clean + # + # Advisory only: reports violations as a warning annotation and in the + # step summary, but does not fail the workflow. + # + # Relies on the preceding headerscheck step having configured the tree, + # which is needed to build pg_bsd_indent. + ### + - name: pgindent check + if: ${{ !cancelled() }} + run: | + echo "::group::build pg_bsd_indent" + make -s -C src/tools/pg_bsd_indent all + echo "::endgroup::" + + rc=0 + src/tools/pgindent/pgindent \ + --indent=src/tools/pg_bsd_indent/pg_bsd_indent \ + --check --diff . > pgindent.diff || rc=$? + + if [ "$rc" -eq 2 ]; then + echo "::warning title=pgindent::Tree is not pgindent-clean, see the CompilerWarnings job summary for the diff" + { + echo "### pgindent found formatting differences" + echo '```diff' + head -c 900000 pgindent.diff # step summaries are capped at 1 MiB + echo '```' + } >> "$GITHUB_STEP_SUMMARY" + elif [ "$rc" -ne 0 ]; then + # pgindent itself failed; that is a real error + cat pgindent.diff + exit "$rc" + fi + + ### + # Verify the tree is git whitespace clean + # + # Advisory only: reports violations as a warning annotation and in the + # step summary, but does not fail the workflow. + ### + - name: git whitespace check + if: ${{ !cancelled() }} + run: | + # This job runs in a container, where the checkout is owned by a + # different user than the one running the steps, so git would + # otherwise refuse to operate on it ("dubious ownership"). + git config --global --add safe.directory "$GITHUB_WORKSPACE" + + rc=0 + git diff-tree --check `git hash-object -t tree /dev/null` HEAD > git-whitespace.out || rc=$? + + if [ "$rc" -eq 2 ]; then + echo "::warning title=git::Tree is not git whitespace-clean, see the CompilerWarnings job summary for the output" + { + echo "### git whitespace check output" + echo '```' + cat git-whitespace.out + echo '```' + } >> "$GITHUB_STEP_SUMMARY" + elif [ "$rc" -ne 0 ]; then + # git itself failed; that is a real error + cat git-whitespace.out + exit "$rc" + fi + - *ccache_decide_save_step - *ccache_save_step - *upload_logs_step -- 2.55.0