Skip to content

Commit

Permalink
Refactor last bits of old-style build scripting (#882)
Browse files Browse the repository at this point in the history
The exceptions are `parquet_s3_fdw` and `postgresml`, which I cannot get
to build. The updated extensions are:

*   clickhouse_fdw
*   rdkit (which never built before?)

Also simplified the use of `cmake` in these extensions:

*   mobilitydb
*   pgrouting

And upgraded these extensions to:

*   rdkit 4.6.1
*   pgrouting 3.7.1

Next, make sure that pljava properly depends on `openjdk-11-jdk`.

Upgrade the build scripting in tests:

*   cli/tests/test_builders/Dockerfile.auto_explain
*   cli/tests/test_builders/Dockerfile.http
*   cli/tests/test_builders/Dockerfile.pg_stat_statements
*   cli/tests/test_pljava
*   cli/tests/test_postgresql_unit
*   cli/tests/test_postgresql_unit
*   cli/tests/test_trunk_toml_dirs/pg_cron
*   cli/tests/test_trunk_toml_dirs/postgis

Finally, update the README with the cleaner output and add some notes
for running tests in Docker Desktop.
  • Loading branch information
theory committed Jan 7, 2025
1 parent 309f435 commit 53d66d3
Show file tree
Hide file tree
Showing 23 changed files with 268 additions and 253 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/extensions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
changed_relative_to_ref="origin/${{ github.base_ref || 'not-a-branch' }}"
fi
echo "changed_relative_to_ref=${changed_relative_to_ref}" >> $GITHUB_OUTPUT
- name: Check out the coredb repo to reuse some actions
- name: Check out the repo to reuse some actions
uses: actions/checkout@v4
with:
repository: tembo-io/tembo
Expand Down
2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pg-trunk"
version = "0.15.7"
version = "0.15.8"
edition = "2021"
authors = ["Ian Stanton", "Vinícius Miguel", "David E. Wheeler"]
description = "A package manager for PostgreSQL extensions"
Expand Down
56 changes: 56 additions & 0 deletions cli/README-DEV.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,65 @@ The `--nocapture` option ensures all output prints to the terminal. The
`--test-threads=4` limits the number of threads so as not to overwhelm Docker
(seems especially prone with macOS Docker's VM).

## Docker Desktop

Start a pgxn-tools privileged container with the repository directory mounted:

```sh
cd trunk
docker run -it --rm -v "$PWD:/repo" --privileged --platform linux/amd64 -w /repo pgxn/pgxn-tools bash
```

Inside the container, follow the [installation instructions] to set up the Apt repo:

``` sh
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
```

Install Docker:

``` sh
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
```

Fix [bug] and start Docker:

``` sh
perl -i -pe 's/ulimit -Hn/ulimit -n/' /etc/init.d/docker
systemctl start docker
```

Install and start Postgres and upgrade Rust:

``` sh
pg-start 15
rustup update
```

Run the tests:

``` sh
cd cli
cargo test -- --nocapture --test-threads=4
```

[Postgres]: https://www.postgresql.org
"PostgreSQL: The World's Most Advanced Open Source Relational Database"
[`pg_config`]: https://www.postgresql.org/docs/current/app-pgconfig.html
"PostgreSQL Docs: pg_config"
[Docker]: https://www.docker.com
"Docker: Accelerated Container Application Development"
[installation instructions]: https://docs.docker.com/engine/install/debian/#install-using-the-repository
[bug]: https://forums.docker.com/t/etc-init-d-docker-62-ulimit-error-setting-limit-invalid-argument-problem/139424/2
43 changes: 24 additions & 19 deletions cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,21 +106,31 @@ Trunk can help us build and package these types of extensions as well.

Create a custom Dockerfile named `Dockerfile.pg_stat_statements` at the root of the [postgres/contrib](https://github.com/postgres/postgres/tree/master/contrib)
repository:

```dockerfile
ARG PG_VERSION=15
# Set up variables for build.
ARG PG_VERSION
FROM quay.io/coredb/c-builder:pg${PG_VERSION}
USER root

# Postgres build dependencies. Additional system dependencies for the extension can be added here.
# https://wiki.postgresql.org/wiki/Compile_and_Install_from_source_code
RUN apt-get update && apt-get install -y build-essential libreadline-dev zlib1g-dev flex bison libxml2-dev libxslt-dev libssl-dev libxml2-utils xsltproc ccache

# Copy working directory into container
COPY --chown=postgres:postgres . .
# Necessary step for building extensions in postgres/contrib
RUN ./configure
# Run make in the pg_stat_statements directory
RUN cd contrib/pg_stat_statements && make
# Extension build dependencies
USER root
RUN apt-get update && apt-get install -y \
build-essential \
libreadline-dev \
zlib1g-dev \
flex bison \
libxml2-dev \
libxslt-dev \
libssl-dev \
libxml2-utils \
xsltproc \
ccache

# Clone repository and build extension.
ARG EXTENSION_NAME
ARG PG_RELEASE
RUN git clone --depth 1 --branch "${PG_RELEASE}" https://github.com/postgres/postgres.git \
&& make -C postgres/contrib/${EXTENSION_NAME} USE_PGXS=1
```

Run `trunk build` with `--dockerfile` and `--install-command` flags:
Expand All @@ -130,16 +140,11 @@ Run `trunk build` with `--dockerfile` and `--install-command` flags:
--name pg_stat_statements \
--version 1.10.0 \
--dockerfile Dockerfile.pg_stat_statements \
--install-command \
"cd contrib/pg_stat_statements \
&& make install \
&& set -x \
&& mv /usr/local/pgsql/share/extension/* /usr/share/postgresql/15/extension \
&& mv /usr/local/pgsql/lib/* /usr/lib/postgresql/15/lib"
--install-command make -C contrib/pg_stat_statements USE_PGXS=1 install
Building from path .
Detected a Makefile, guessing that we are building an extension with 'make', 'make install...'
Using Dockerfile at Dockerfile.pg_stat_statements
Using install command /bin/sh -c cd contrib/pg_stat_statements && make install && set -x && mv /usr/local/pgsql/share/extension/* /usr/share/postgresql/15/extension && mv /usr/local/pgsql/lib/* /usr/lib/postgresql/15/lib
Using install command /bin/sh -c make -C contrib/pg_stat_statements USE_PGXS=1 install
Building with name pg_stat_statements
Building with version 1.10.0
.
Expand Down
Loading

0 comments on commit 53d66d3

Please sign in to comment.