diff --git a/.github/workflows/pgindent.yml b/.github/workflows/pgindent.yml new file mode 100644 index 00000000000..745b02be5c7 --- /dev/null +++ b/.github/workflows/pgindent.yml @@ -0,0 +1,34 @@ +name: PgIndent +on: + pull_request: + workflow_dispatch: + +defaults: + run: + working-directory: ./src + +jobs: + check: + name: Check + runs-on: ubuntu-22.04 + steps: + + - name: Clone repository + uses: actions/checkout@v4 + with: + path: 'src' + submodules: recursive + + - name: Install dependencies + run: ci_scripts/ubuntu-deps.sh + + - name: Build postgres + run: ci_scripts/make-build.sh debug + + - name: Update typedefs + run: ci_scripts/dump-typedefs.sh + + - name: Run pgindent + run: ci_scripts/run-pgindent.sh --check --diff + + diff --git a/.gitignore b/.gitignore index a880c1e3838..049dc2cc016 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,4 @@ lib*.pc /Release/ /tmp_install/ /portlock/ +/*.typedefs diff --git a/ci_scripts/dump-typedefs.sh b/ci_scripts/dump-typedefs.sh new file mode 100755 index 00000000000..a8bb1e66c47 --- /dev/null +++ b/ci_scripts/dump-typedefs.sh @@ -0,0 +1,32 @@ +SCRIPT_DIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" +cd "$SCRIPT_DIR/../" + +if ! test -f src/backend/postgres; then + echo "src/backend/postgres doesn't exists, run make-build.sh first in debug mode" + exit 1 +fi + +if ! test -f contrib/pg_tde/pg_tde.so; then + echo "contrib/pg_tde/pg_tde.so doesn't exists, run make-build.sh first in debug mode" + exit 1 +fi + +objdump -W src/backend/postgres |\ + egrep -A3 DW_TAG_typedef |\ + perl -e ' while (<>) { chomp; @flds = split;next unless (1 < @flds);\ + next if $flds[0] ne "DW_AT_name" && $flds[1] ne "DW_AT_name";\ + next if $flds[-1] =~ /^DW_FORM_str/;\ + print $flds[-1],"\n"; }' |\ + sort | uniq > percona.typedefs + +objdump -W contrib/pg_tde/pg_tde.so |\ + egrep -A3 DW_TAG_typedef |\ + perl -e ' while (<>) { chomp; @flds = split;next unless (1 < @flds);\ + next if $flds[0] ne "DW_AT_name" && $flds[1] ne "DW_AT_name";\ + next if $flds[-1] =~ /^DW_FORM_str/;\ + print $flds[-1],"\n"; }' |\ + sort | uniq > tde.typedefs + +# Combine with original typedefs + +cat percona.typedefs tde.typedefs src/tools/pgindent/typedefs.list | sort | uniq > combined.typedefs diff --git a/ci_scripts/make-build.sh b/ci_scripts/make-build.sh index 9450e115c52..ebfec59ef8f 100755 --- a/ci_scripts/make-build.sh +++ b/ci_scripts/make-build.sh @@ -14,4 +14,5 @@ if [ "$1" = "debugoptimized" ]; then fi ./configure --enable-debug --enable-cassert --enable-tap-tests --prefix=$INSTALL_DIR -make install-world -j \ No newline at end of file +make install-world -j + diff --git a/ci_scripts/make-test.sh b/ci_scripts/make-test.sh index 4477175139d..e9022432fb3 100755 --- a/ci_scripts/make-test.sh +++ b/ci_scripts/make-test.sh @@ -7,4 +7,5 @@ INSTALL_DIR="$SCRIPT_DIR/../../pginst" cd "$SCRIPT_DIR/../" -make check-world \ No newline at end of file +make check-world + diff --git a/ci_scripts/run-pgindent.sh b/ci_scripts/run-pgindent.sh new file mode 100755 index 00000000000..d03da1345a6 --- /dev/null +++ b/ci_scripts/run-pgindent.sh @@ -0,0 +1,19 @@ + +SCRIPT_DIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" +INSTALL_DIR="$SCRIPT_DIR/../../pginst" +cd "$SCRIPT_DIR/../" + +if ! test -f combined.typedefs; then + echo "combined.typedefs doesn't exists, run dump-typedefs.sh first" + exit 1 +fi + +cd src/tools/pg_bsd_indent +make install + +cd "$SCRIPT_DIR/../" + + +export PATH=$SCRIPT_DIR/../src/tools/pgindent/:$INSTALL_DIR/bin/:$PATH + +pgindent --typedefs=combined.typedefs "$@" . \ No newline at end of file diff --git a/src/tools/pgindent/exclude_file_patterns b/src/tools/pgindent/exclude_file_patterns index 68aae9b97a4..03ad8b50887 100644 --- a/src/tools/pgindent/exclude_file_patterns +++ b/src/tools/pgindent/exclude_file_patterns @@ -63,3 +63,8 @@ src/tools/pg_bsd_indent/.* /tmp_install/ # ... and for paranoia's sake, don't touch git stuff. /\.git/ +# Percona excludes +contrib/pg_tde/src16/.* +contrib/pg_tde/src17.* +contrib/pg_tde/src/libkmip/.* +src/backend/nodes/nodetags.h