Skip to content

Commit

Permalink
Streamline the setup workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
JerrySievert committed Nov 8, 2024
1 parent 53e6388 commit 0a3611d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 36 deletions.
31 changes: 14 additions & 17 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,26 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
version: [REL_16_STABLE, REL_17_STABLE]
version: [16, 17]
runs-on: ${{ matrix.os }}

steps:
- name: Test details
run: echo Build and test pljs on ${{ matrix.os }} with PostgreSQL ${{ matrix.version }} branch
run: echo Build and test pljs on ${{ matrix.os }} PostgreSQL version ${{ matrix.version }}

- name: Checkout and build PostgreSQL code
run: |
sudo apt-get update -qq
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
sudo apt-get install -y build-essential libreadline-dev zlib1g-dev flex bison libxml2-dev libxslt-dev libssl-dev libxml2-utils xsltproc ccache pkg-config libc++-dev libc++abi-dev libglib2.0-dev libtinfo6 cmake libstdc++-12-dev
rm -rf postgres
git clone --branch ${{ matrix.version }} --single-branch --depth 1 https://github.com/postgres/postgres.git
pushd postgres
git branch
./configure --prefix=$PWD/inst/ --enable-cassert --enable-debug --with-openssl
make -j4 install
sudo apt-get install -y build-essential pkg-config cmake curl ca-certificates
sudo sh -c 'echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
sudo apt update
sudo apt install -y postgresql-${{ matrix.version }} postgresql-server-dev-${{ matrix.version }}
- name: Start Postgres
run: |
pushd postgres
cd inst/bin
./initdb -D data
./pg_ctl -D data -l logfile start
popd
sudo service postgresql start
sudo -u postgres createuser -s runner
ps ax | grep postgres
- name: Checkout pljs extension code
uses: actions/checkout@v4
Expand All @@ -42,9 +36,12 @@ jobs:
- name: Build and test pljs extension
id: regression-tests
run: |
export PATH="${PWD}/postgres/inst/bin:$PATH"
export PATH="/usr/lib/postgresql/${{ matrix.version }}/bin/:$PATH"
pushd pljs
make install
make
sudo PATH="/usr/lib/postgresql/${{ matrix.version }}/bin/:$PATH" make install
which pg_config
which psql
make installcheck
popd
Expand Down
26 changes: 7 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: lintcheck format cleandepend cleansql docs clean test all
.PHONY: lintcheck format cleansql docs clean test all

PLJS_VERSION = 0.8.1

Expand All @@ -10,7 +10,7 @@ INCLUDEDIR_SERVER := ${shell $(PG_CONFIG) --includedir-server}

CP = cp
SRCS = src/pljs.c src/cache.c src/functions.c src/types.c src/params.c
OBJS = src/pljs.o src/cache.o src/functions.o src/types.o src/params.o deps/quickjs/libquickjs.a
OBJS = src/pljs.o src/cache.o src/functions.o src/types.o src/params.o
MODULE_big = pljs
EXTENSION = pljs
DATA = pljs.control pljs--$(PLJS_VERSION).sql
Expand All @@ -21,19 +21,18 @@ REGRESS = init-extension function json jsonb json_conv types bytea context \
cursor array_spread plv8_regressions memory_limits inline composites \
trigger procedure find_function

all: deps/quickjs/libquickjs.a pljs--$(PLJS_VERSION).sql

all: deps/quickjs/quickjs.h deps/quickjs/libquickjs.a pljs--$(PLJS_VERSION).sql

include $(PGXS)


src/pljs.o: deps/quickjs/libquickjs.a

deps/quickjs/quickjs.h:
mkdir -p deps
git submodule update --init --recursive
patch -p1 <patches/01-shared-lib-build

deps/quickjs/libquickjs.a:
deps/quickjs/libquickjs.a: deps/quickjs/quickjs.h
cd deps/quickjs && make

format:
Expand All @@ -45,23 +44,12 @@ pljs--$(PLJS_VERSION).sql: pljs.sql
lintcheck:
clang-tidy $(SRCS) -- -I$(INCLUDEDIR) -I$(INCLUDEDIR_SERVER) -I$(PWD) --std=c11

.depend: deps/quickjs/quickjs.h
$(RM) -f .depend
$(foreach SRC,$(SRCS),$(CC) $(PG_CFLAGS) -I$(INCLUDEDIR) -I$(INCLUDEDIR_SERVER) \
-I$(PWD) -MM -MT $(SRC:.c=.o) $(SRC) >> .depend;)

all: deps/quickjs/quickjs.h deps/quickjs/libquickjs.a pljs--$(PLJS_VERSION).sql

all: deps/quickjs/libquickjs.a pljs--$(PLJS_VERSION).sql

clean: cleandepend cleansql

cleandepend:
$(RM) -f .depend
clean: cleansql

cleansql:
$(RM) -f pljs--$(PLJS_VERSION).sql

docs:
doxygen src/Doxyfile

include .depend

0 comments on commit 0a3611d

Please sign in to comment.