Skip to content

Commit

Permalink
Use alpine images for GEOS tests
Browse files Browse the repository at this point in the history
The previous approach compiled the GEOS library from source. This was
quite annoying when new versions of GEOS came out, because new images
had to be created (they take several hours to build on a powerful
machine).

The new approach is simpler and is based on pre-built alpine images.
  • Loading branch information
peterstace committed Dec 17, 2023
1 parent 5ecf0fe commit b872c8d
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 114 deletions.
8 changes: 6 additions & 2 deletions .ci/docker-compose-cmpgeos.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
version: "3.7"
services:
cmprefimpl:
image: peterstace/simplefeatures-ci:geos-3.11.2-go-1.20.4
build:
dockerfile: geos.Dockerfile
args:
ALPINE_VERSION: 3.19
GEOS_VERSION: 3.12.1-r0
working_dir: /mnt/sf
entrypoint: sh -c "go run ./internal/cmprefimpl/cmpgeos"
entrypoint: go run ./internal/cmprefimpl/cmpgeos
volumes:
- ..:/mnt/sf
8 changes: 6 additions & 2 deletions .ci/docker-compose-geos.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
version: "2.1"
services:
geostests:
image: peterstace/simplefeatures-ci:geos-${GEOS_VERSION}-go-1.20.4
build:
dockerfile: geos.Dockerfile
args:
ALPINE_VERSION: $alpine_version
GEOS_VERSION: $geos_version
working_dir: /mnt/sf
entrypoint: go test -test.count=1 -test.run=. ./geos
entrypoint: go test -test.count=1 -test.run=. ./geos ./internal/rawgeos
volumes:
- ..:/mnt/sf
9 changes: 9 additions & 0 deletions .ci/geos.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ARG ALPINE_VERSION
FROM alpine:${ALPINE_VERSION}

ARG GEOS_VERSION
RUN apk add gcc musl-dev geos-dev=${GEOS_VERSION}

COPY --from=golang:1.21-alpine /usr/local/go /usr/local/go
ENV PATH=${PATH}:/usr/local/go/bin
RUN go version
1 change: 0 additions & 1 deletion .ci/geos_images/.dockerignore

This file was deleted.

1 change: 0 additions & 1 deletion .ci/geos_images/.gitignore

This file was deleted.

28 changes: 0 additions & 28 deletions .ci/geos_images/Dockerfile

This file was deleted.

54 changes: 0 additions & 54 deletions .ci/geos_images/README.md

This file was deleted.

22 changes: 11 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,36 +27,36 @@ cmpgeos:
task=cmpgeos; $(DC_RUN)

DC_GEOS_RUN = \
env GEOS_VERSION=$$version \
docker compose \
--project-name sf-geos-$$(echo $$version | sed 's/\./-/g') \
--project-name sf-geos-$$(echo $$geos_version | sed 's/\./-/g') \
--file .ci/docker-compose-geos.yml \
up \
--build \
--abort-on-container-exit

.PHONY: geos-3.12
geos-3.12:
export alpine_version=3.19 geos_version=3.12.1-r0; $(DC_GEOS_RUN)

.PHONY: geos-3.11
geos-3.11:
version=3.11.2; $(DC_GEOS_RUN)
export alpine_version=3.18 geos_version=3.11.2-r0; $(DC_GEOS_RUN)

.PHONY: geos-3.10
geos-3.10:
version=3.10.5; $(DC_GEOS_RUN)
export alpine_version=3.16 geos_version=3.10.3-r0; $(DC_GEOS_RUN)

.PHONY: geos-3.9
geos-3.9:
version=3.9.4; $(DC_GEOS_RUN)
export alpine_version=3.14 geos_version=3.9.1-r0; $(DC_GEOS_RUN)

.PHONY: geos-3.8
geos-3.8:
version=3.8.3; $(DC_GEOS_RUN)

.PHONY: geos-3.7
geos-3.7:
version=3.7.5; $(DC_GEOS_RUN)
export alpine_version=3.13 geos_version=3.8.1-r2; $(DC_GEOS_RUN)

.PHONY: geos
geos: geos-3.12
geos: geos-3.11
geos: geos-3.10
geos: geos-3.9
geos: geos-3.8
geos: geos-3.7
17 changes: 2 additions & 15 deletions internal/rawgeos/entrypoints_test.go → geos/entrypoints_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package rawgeos_test
package geos_test

import (
"math"
Expand Down Expand Up @@ -29,7 +29,7 @@ func expectNoErr(t *testing.T, err error) {
func expectErr(t *testing.T, err error) {
t.Helper()
if err == nil {
t.Fatal("unexpected error but got nil")
t.Fatal("expected error but got nil")
}
}

Expand Down Expand Up @@ -623,11 +623,6 @@ func TestUnion(t *testing.T) {
"POINT(3 4)",
"MULTIPOINT(1 2,3 4)",
},
{
"POINT EMPTY",
"POINT(3 4)",
"POINT(3 4)",
},
{
"POINT EMPTY",
"POINT EMPTY",
Expand Down Expand Up @@ -900,14 +895,6 @@ func TestCoverageUnion(t *testing.T) {
)`,
wantErr: true,
},
{
// Input constraint violated: not noded correctly.
input: `GEOMETRYCOLLECTION(
POLYGON((0 0,0 1,1 1,1 0,0 0)),
POLYGON((0 1,2 1,2 2,0 2,0 1))
)`,
wantErr: true,
},
{
// Input constraint violation: not everything is a polygon.
input: `GEOMETRYCOLLECTION(POINT(1 2),POLYGON((0 0,0 1,1 0,0 0)))`,
Expand Down

0 comments on commit b872c8d

Please sign in to comment.