Skip to content

Commit 9856e7c

Browse files
committed
add go and r tests in postgres client tests
1 parent 62c8a16 commit 9856e7c

13 files changed

Lines changed: 613 additions & 122 deletions

File tree

.github/workflows/ci-postgres-client-tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ jobs:
2525
- name: Set up Docker
2626
uses: docker/setup-docker-action@v4
2727
- name: Build Docker image
28-
run: docker build -t postgres-client-tests --file testing/PostgresDockerfile .
28+
run: docker build -t postgres-client-tests --file testing/postgres-client-tests/Dockerfile .
2929
- name: Run tests
3030
run: docker run --detach=false postgres-client-tests

testing/PostgresDockerfile

Lines changed: 0 additions & 112 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
java/PostgresTest.class
22
java/postgresql-42.7.3.jar
33
node/node_modules/
4+
elixir/postgrex/_build
5+
elixir/postgrex/mix.lock
6+
elixir/postgrex/dep
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
# syntax=docker/dockerfile:1
2+
FROM golang:1.26.2-alpine AS golang_cgo
3+
ENV CGO_ENABLED=1
4+
ENV GO_LDFLAGS="-linkmode external -extldflags '-static'"
5+
RUN apk add --no-cache build-base
6+
7+
# --- Build doltgres binary ---
8+
FROM golang_cgo AS doltgres_build
9+
RUN apk add --no-cache icu-dev icu-static
10+
RUN apk update && apk add --no-cache bash
11+
WORKDIR /root/building
12+
COPY go.mod doltgresql/
13+
WORKDIR doltgresql
14+
RUN go mod download
15+
COPY --exclude=testing/postgres-client-tests/ . .
16+
WORKDIR /root/building/doltgresql/postgres/parser
17+
RUN sh ./build.sh
18+
WORKDIR /root/building/doltgresql/cmd/doltgres
19+
RUN go build -ldflags "-linkmode external -extldflags '-static'" -o /build/bin/doltgres .
20+
21+
# --- Build Go postgres clients (pgx, lib/pq) ---
22+
FROM golang:1.26.4 AS go_clients_build
23+
COPY testing/postgres-client-tests/go/pgx/ /build/go/pgx/
24+
WORKDIR /build/go/pgx
25+
RUN go build -o /build/bin/pgx-test .
26+
COPY testing/postgres-client-tests/go/libpq/ /build/go/libpq/
27+
WORKDIR /build/go/libpq
28+
RUN go build -o /build/bin/libpq-test .
29+
30+
# --- Build Rust sqlx client ---
31+
FROM rust:1.96-slim-bookworm AS rust_clients_build
32+
RUN apt-get update && apt-get install -y pkg-config libssl-dev && rm -rf /var/lib/apt/lists/*
33+
COPY testing/postgres-client-tests/rust/ /build/rust/
34+
WORKDIR /build/rust
35+
RUN cargo build --release
36+
37+
# --- Build C libpq client ---
38+
FROM debian:bookworm-slim AS c_clients_build
39+
RUN apt-get update && apt-get install -y gcc make libpq-dev pkg-config && rm -rf /var/lib/apt/lists/*
40+
COPY testing/postgres-client-tests/c/ /build/c/
41+
WORKDIR /build/c
42+
RUN make
43+
44+
# --- Install Node postgres client deps ---
45+
FROM node:22-bookworm-slim AS node_clients_build
46+
COPY testing/postgres-client-tests/node/package.json /build/node/
47+
COPY testing/postgres-client-tests/node/package-lock.json /build/node/
48+
WORKDIR /build/node
49+
RUN npm install
50+
COPY testing/postgres-client-tests/node/ /build/node/
51+
52+
# --- Install Ruby pg gem ---
53+
FROM ruby:3.4-bookworm AS ruby_clients_build
54+
RUN apt-get update && apt-get install -y libpq-dev && rm -rf /var/lib/apt/lists/*
55+
COPY testing/postgres-client-tests/ruby/Gemfile /build/ruby/
56+
COPY testing/postgres-client-tests/ruby/Gemfile.lock /build/ruby/
57+
WORKDIR /build/ruby
58+
RUN bundle install
59+
COPY testing/postgres-client-tests/ruby/ /build/ruby/
60+
61+
# --- Install Python deps ---
62+
FROM python:3.14-slim-bookworm AS python_clients_build
63+
RUN pip3 install --no-cache-dir --target /build/python-deps sqlalchemy==2.0.46
64+
COPY testing/postgres-client-tests/python/ /build/python/
65+
WORKDIR /build/python/
66+
67+
# --- Runtime ---
68+
FROM debian:bookworm-slim
69+
70+
ENV DEBIAN_FRONTEND=noninteractive
71+
72+
RUN apt-get update && apt-get install -y \
73+
curl \
74+
gnupg \
75+
lsb-release && \
76+
sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' && \
77+
curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg && \
78+
curl -fsSL https://deb.nodesource.com/setup_22.x | bash -
79+
80+
# java JDBC dependencies
81+
COPY testing/postgres-client-tests/java/ /postgres-client-tests/java/
82+
RUN apt-get install -y \
83+
openjdk-17-jdk && \
84+
curl -L -o /postgres-client-tests/java/postgresql-42.7.3.jar https://jdbc.postgresql.org/download/postgresql-42.7.3.jar
85+
86+
# perl dependencies
87+
RUN apt-get install -y \
88+
python3 \
89+
python3-pip \
90+
python3-psycopg2 \
91+
perl \
92+
cpanminus \
93+
php \
94+
php-pgsql \
95+
r-base \
96+
libpq-dev \
97+
ca-certificates-java \
98+
bats \
99+
lsof \
100+
postgresql-client-15 \
101+
nodejs \
102+
elixir \
103+
git && \
104+
update-ca-certificates -f && \
105+
rm -rf /var/lib/apt/lists/*
106+
107+
# cpan dependencies
108+
RUN cpanm --force DBD::Pg
109+
110+
# r dependencies
111+
COPY testing/postgres-client-tests/r/ /postgres-client-tests/r/
112+
RUN Rscript -e 'install.packages("RPostgres", repos="https://cloud.r-project.org")'
113+
114+
ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64/
115+
ENV GEM_HOME="/usr/local/bundle"
116+
ENV PYTHONPATH=/usr/local/lib/python-deps
117+
118+
COPY --from=ruby_clients_build /usr/local/bin/ruby /usr/local/bin/
119+
COPY --from=ruby_clients_build /usr/local/lib/ /usr/local/lib/
120+
COPY --from=ruby_clients_build /usr/local/bundle/ /usr/local/bundle/
121+
RUN ldconfig
122+
123+
COPY --from=doltgres_build /build/bin/doltgres /usr/local/bin/doltgres
124+
COPY --from=go_clients_build /build/bin/pgx-test /build/bin/go/pgx-test
125+
COPY --from=go_clients_build /build/bin/libpq-test /build/bin/go/libpq-test
126+
COPY --from=rust_clients_build /build/rust/target/release/sqlx_exists_demo /build/bin/rust/sqlx_exists_demo
127+
COPY --from=c_clients_build /build/c/postgres-c-connector-test /build/bin/c/postgres-c-connector-test
128+
COPY --from=node_clients_build /build/node/ /postgres-client-tests/node/
129+
COPY --from=python_clients_build /build/python/ /postgres-client-tests/python/
130+
COPY --from=python_clients_build /build/python-deps/ /usr/local/lib/python-deps/
131+
COPY --from=ruby_clients_build /build/ruby/ /postgres-client-tests/ruby/
132+
133+
COPY testing/postgres-client-tests/c/ /postgres-client-tests/c/
134+
COPY testing/postgres-client-tests/drizzle/ /postgres-client-tests/drizzle/
135+
COPY testing/postgres-client-tests/helpers.bash /postgres-client-tests/
136+
COPY testing/postgres-client-tests/php/ /postgres-client-tests/php/
137+
COPY testing/postgres-client-tests/perl/ /postgres-client-tests/perl/
138+
COPY testing/postgres-client-tests/postgres-client-tests.bats /postgres-client-tests/
139+
COPY testing/postgres-client-tests/postgres-client-tests-entrypoint.sh /postgres-client-tests/entrypoint.sh
140+
141+
WORKDIR /postgres-client-tests
142+
ENTRYPOINT ["/postgres-client-tests/entrypoint.sh"]

testing/postgres-client-tests/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on pull requests.
55
These tests can be run locally using Docker. From the doltgresql directory of the repo, run:
66

77
```bash
8-
$ docker build -t postgres-client-tests -f testing/PostgresDockerfile .
8+
$ docker build -t postgres-client-tests -f testing/postgres-client-tests/Dockerfile .
99
$ docker run postgres-client-tests:latest
1010
```
1111

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module libpq-test
2+
3+
go 1.26.3
4+
5+
require github.com/lib/pq v1.12.3 // indirect
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github.com/lib/pq v1.12.3 h1:tTWxr2YLKwIvK90ZXEw8GP7UFHtcbTtty8zsI+YjrfQ=
2+
github.com/lib/pq v1.12.3/go.mod h1:/p+8NSbOcwzAEI7wiMXFlgydTwcgTr3OSKMsD2BitpA=

0 commit comments

Comments
 (0)