mirror of
https://github.com/postgres/postgres.git
synced 2025-05-31 00:01:57 -04:00
Added scripts and github CI action for formatting / format checking
This commit is contained in:
parent
5e3f82c785
commit
4842a99090
34
.github/workflows/pgindent.yml
vendored
Normal file
34
.github/workflows/pgindent.yml
vendored
Normal file
@ -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
|
||||
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -44,3 +44,4 @@ lib*.pc
|
||||
/Release/
|
||||
/tmp_install/
|
||||
/portlock/
|
||||
/*.typedefs
|
||||
|
32
ci_scripts/dump-typedefs.sh
Executable file
32
ci_scripts/dump-typedefs.sh
Executable file
@ -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
|
@ -14,4 +14,5 @@ if [ "$1" = "debugoptimized" ]; then
|
||||
fi
|
||||
|
||||
./configure --enable-debug --enable-cassert --enable-tap-tests --prefix=$INSTALL_DIR
|
||||
make install-world -j
|
||||
make install-world -j
|
||||
|
||||
|
@ -7,4 +7,5 @@ INSTALL_DIR="$SCRIPT_DIR/../../pginst"
|
||||
|
||||
cd "$SCRIPT_DIR/../"
|
||||
|
||||
make check-world
|
||||
make check-world
|
||||
|
||||
|
19
ci_scripts/run-pgindent.sh
Executable file
19
ci_scripts/run-pgindent.sh
Executable file
@ -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 "$@" .
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user