Skip to content

Commit 0e13623

Browse files
Switch from alpine to debian for CI (#259)
* Switch from alpine to debian
1 parent 4c1b608 commit 0e13623

File tree

5 files changed

+46
-41
lines changed

5 files changed

+46
-41
lines changed

.github/workflows/run-tests.yaml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,14 @@ jobs:
1313
strategy:
1414
matrix:
1515
include:
16-
- base_image: "golang:1.20.14-alpine3.19"
17-
pg_package: "postgresql14"
18-
- base_image: "golang:1.20.14-alpine3.19"
19-
pg_package: "postgresql15"
20-
- base_image: "golang:1.20.14-alpine3.19"
21-
pg_package: "postgresql16"
22-
- base_image: "golang:1.22.10-alpine3.21"
23-
pg_package: "postgresql17"
16+
- pg_version: "14"
17+
- pg_version: "15"
18+
- pg_version: "16"
19+
- pg_version: "17"
2420
steps:
2521
- name: Checkout code
2622
uses: actions/checkout@v3
2723
- name: Build Docker image
28-
run: docker build -t pg-schema-diff-test-runner -f ./build/Dockerfile.test --build-arg BASE_IMAGE=${{ matrix.base_image }} --build-arg POSTGRES_PACKAGE=${{ matrix.pg_package }} .
24+
run: docker build -t pg-schema-diff-test-runner -f ./build/Dockerfile.test --build-arg PG_VERSION=${{ matrix.pg_version }} .
2925
- name: Run tests
3026
run: docker run pg-schema-diff-test-runner

build/Dockerfile.codegen

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
FROM golang:1.20.14-alpine3.19
1+
FROM golang:1.20-bookworm
22

3-
RUN apk update && \
4-
apk add --no-cache \
5-
build-base \
6-
git \
7-
make
3+
RUN apt-get update && apt-get install -y --no-install-recommends \
4+
build-essential \
5+
git \
6+
make \
7+
&& rm -rf /var/lib/apt/lists/*
88

99
RUN go install -tags=nowasm github.com/kyleconroy/sqlc/cmd/[email protected]
1010
ENTRYPOINT make code_gen

build/Dockerfile.lint

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
# Use a newer version of go to appease #golangci-lint
2-
FROM golang:1.20.6-alpine3.18
1+
FROM golang:1.20-bookworm
2+
3+
RUN apt-get update && apt-get install -y --no-install-recommends \
4+
make \
5+
python3 \
6+
python3-pip \
7+
wget \
8+
&& rm -rf /var/lib/apt/lists/*
39

4-
RUN apk update && \
5-
apk add --no-cache \
6-
make \
7-
python3 \
8-
py3-pip
910
# Install golang-ci-lint
1011
RUN wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.56.2
11-
# Install sqlfluff
12-
RUN pip install wheel # It complains if we attempt to install this in the same command as Cython
13-
RUN pip install "Cython<3.0" pyyaml --no-build-isolation # Fix for https://github.com/yaml/pyyaml/issues/601
14-
RUN pip install "sqlfluff==3.3.0"
12+
13+
# Install sqlfluff (use --break-system-packages for Debian 12+)
14+
RUN pip install --break-system-packages wheel
15+
RUN pip install --break-system-packages "Cython<3.0" pyyaml --no-build-isolation
16+
RUN pip install --break-system-packages "sqlfluff==3.3.0"
1517

1618
WORKDIR /pg-schema-diff
1719
COPY . .

build/Dockerfile.test

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
1-
ARG BASE_IMAGE=golang:1.20.14-alpine3.19
1+
FROM golang:1.22-bookworm
22

3-
FROM $BASE_IMAGE
3+
ARG PG_VERSION=14
44

5-
ARG POSTGRES_PACKAGE=postgresql14
6-
RUN apk update && \
7-
apk add --no-cache \
8-
build-base \
9-
make \
10-
$POSTGRES_PACKAGE \
11-
$POSTGRES_PACKAGE-contrib \
12-
$POSTGRES_PACKAGE-client
5+
# Install build dependencies and PostgreSQL from official apt repository
6+
RUN apt-get update && apt-get install -y --no-install-recommends \
7+
build-essential \
8+
make \
9+
gnupg \
10+
wget \
11+
ca-certificates \
12+
lsb-release \
13+
&& apt install -y postgresql-common \
14+
&& YES=yes /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh \
15+
&& apt-get update \
16+
&& apt-get install -y --no-install-recommends \
17+
postgresql-${PG_VERSION} \
18+
postgresql-contrib-${PG_VERSION} \
19+
postgresql-client-${PG_VERSION} \
20+
&& rm -rf /var/lib/apt/lists/*
21+
22+
# Add PostgreSQL bin directory to PATH (Debian installs to /usr/lib/postgresql/<version>/bin/)
23+
ENV PATH="/usr/lib/postgresql/${PG_VERSION}/bin:${PATH}"
1324

1425
WORKDIR /pg-schema-diff
1526

@@ -20,7 +31,7 @@ RUN go mod download
2031

2132
# Run all tests from non-root. This will also prevent Postgres from complaining when
2233
# we try to launch it within tests
23-
RUN adduser --disabled-password --gecos '' testrunner
34+
RUN useradd --create-home testrunner
2435
USER testrunner
2536

2637
# Run tests serially so logs can be streamed. Set overall timeout to 30m (the default is 10m, which is not enough)

internal/pgdump/dump.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ const (
1919
var (
2020
// versionRe matches the version returned by pg_dump.
2121
versionRe = regexp.MustCompile(`pg_dump \(PostgreSQL\) (\d+(?:\.\d+)?)`)
22-
23-
version15 = version.Must(version.NewSemver("15.0"))
2422
)
2523

2624
// Parameter represents a parameter to be pg_dump. Don't use a type alias for a string slice
@@ -50,8 +48,6 @@ func WithSchemaOnly() Parameter {
5048
func WithRestrictKey(restrictKey string) Parameter {
5149
return Parameter{
5250
values: []string{"--restrict-key", restrictKey},
53-
// Added in 17.6. https://www.postgresql.org/docs/release/17.6/.
54-
minimumVersion: version15,
5551
}
5652
}
5753

0 commit comments

Comments
 (0)