Skip to content

Commit f1d71d5

Browse files
add tests for collections search links (#310)
* add tests for collections search links * fix issues with docker and scripts. fix tests. fix issue with collection_search links * set break-system-packages for ci * remove slashes from branch name --------- Co-authored-by: David W Bitner <[email protected]>
1 parent 8a37c99 commit f1d71d5

File tree

16 files changed

+4923
-67
lines changed

16 files changed

+4923
-67
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ env:
1010
REGISTRY: ghcr.io
1111
IMAGE_NAME: ${{ github.repository }}
1212
DOCKER_BUILDKIT: 1
13+
PIP_BREAK_SYSTEM_PACKAGES: 1
1314

1415
jobs:
1516
changes:
@@ -35,12 +36,11 @@ jobs:
3536
- id: check
3637
run: |
3738
buildpg=false;
38-
ref=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}};
39+
ref=$(echo ${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} | tr / _);
3940
[[ "${{ steps.filter.outputs.pgstac }}" == "true" ]] && buildpg=true || ref=main;
4041
echo "pgtag=${{ env.REGISTRY }}/stac-utils/pgstac-postgres:$ref" >>$GITHUB_OUTPUT;
4142
echo "buildpg=$buildpg" >>$GITHUB_OUTPUT;
4243
buildy=false;
43-
ref=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}};
4444
[[ "${{ steps.filter.outputs.pypgstac }}" == "true" ]] && buildpy=true || ref=main;
4545
echo "pytag=${{ env.REGISTRY }}/stac-utils/pgstac-pyrust:$ref" >>$GITHUB_OUTPUT;
4646
echo "buildpy=$buildpg" >>$GITHUB_OUTPUT;

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ services:
44
image: pgstac
55
build:
66
context: .
7+
network: host
78
dockerfile: docker/pgstac/Dockerfile
89
target: pgstac
910
platform: linux/amd64
@@ -24,6 +25,7 @@ services:
2425
image: pypgstac
2526
build:
2627
context: .
28+
network: host
2729
dockerfile: docker/pypgstac/Dockerfile
2830
target: pypgstac
2931
platform: linux/amd64

docker/pgstac/Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ ARG PG_MAJOR=15
22
ARG POSTGIS_MAJOR=3
33

44
# Base postgres image that pgstac can be installed onto
5-
FROM postgres:${PG_MAJOR}-bullseye as pgstacbase
5+
FROM postgres:${PG_MAJOR}-bullseye AS pgstacbase
66
ARG POSTGIS_MAJOR
77
RUN \
88
apt-get update \
@@ -19,7 +19,7 @@ RUN \
1919
COPY docker/pgstac/dbinit/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
2020

2121
# Base postgres image with plrust installed that can be used for future development using plrust
22-
FROM pgstacbase as pgstacbase-plrust
22+
FROM pgstacbase AS pgstacbase-plrust
2323
ENV PLRUSTVERSION=1.2.7
2424
ENV RUSTVERSION=1.72.0
2525
ENV PLRUSTDOWNLOADURL=https://github.com/tcdi/plrust/releases/download/
@@ -63,13 +63,13 @@ USER root
6363
RUN apt-get install -y /${PLRUSTFILE}
6464

6565
# The pgstacbase image with latest version of pgstac installed
66-
FROM pgstacbase as pgstac
66+
FROM pgstacbase AS pgstac
6767
WORKDIR /docker-entrypoint-initdb.d
6868
COPY docker/pgstac/dbinit/pgstac.sh 990_pgstac.sh
6969
COPY src/pgstac/pgstac.sql 999_pgstac.sql
7070

7171
# The pgstacbase-plrust image with the latest version of pgstac installed
72-
FROM pgstacbase-plrust as pgstac-plrust
72+
FROM pgstacbase-plrust AS pgstac-plrust
7373
WORKDIR /docker-entrypoint-initdb.d
7474
COPY docker/pgstac/dbinit/pgstac.sh 990_pgstac.sh
7575
COPY src/pgstac/pgstac.sql 999_pgstac.sql

docker/pypgstac/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM rust:1-slim-bullseye as pyrustbase
1+
FROM rust:1-slim-bullseye AS pyrustbase
22
ENV PYTHONWRITEBYTECODE=1
33
ENV PYTHONBUFFERED=1
44
ENV PIP_ROOT_USER_ACTION=ignore
@@ -17,14 +17,14 @@ RUN \
1717
&& apt-get clean && apt-get -y autoremove \
1818
&& rm -rf /var/lib/apt/lists/*
1919

20-
FROM pyrustbase as pypgstac
20+
FROM pyrustbase AS pypgstac
2121
COPY ./src/pypgstac/pyproject.toml /tmp/pyproject.toml
2222
WORKDIR /tmp
2323
RUN \
2424
uv pip compile --all-extras /tmp/pyproject.toml >/tmp/requirements.txt \
2525
&& uv pip install --system -r /tmp/requirements.txt
2626
COPY docker/pypgstac/bin /opt/docker/pypgstac/bin
2727
COPY src/pypgstac /opt/src/pypgstac
28-
COPY src/pgstac/migrations /opt/src/pgstac/migrations
28+
COPY src/pgstac /opt/src/pgstac
2929
WORKDIR /opt/src/pypgstac
3030
RUN uv pip install --system -e . && rm -rf /usr/local/cargo/registry

docker/pypgstac/bin/stageversion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ cd $BASEDIR/pgstac
4040

4141
# make the base pgstac.sql a symbolic link to the most recent version
4242
rm pgstac.sql
43-
ln -s migrations/pgstac.${VERSION}.sql pgstac.sql
43+
cp migrations/pgstac.${VERSION}.sql pgstac.sql
4444

4545
# Update the version number in the appropriate places
4646
[[ $VERSION == 'unreleased' ]] && PYVERSION="${OLDVERSION}-dev" || PYVERSION="$VERSION"

docker/pypgstac/bin/test

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
44
export SRCDIR=$SCRIPT_DIR/../../../src
55
export PGSTACDIR=$SRCDIR/pgstac
66

7+
echo $SCRIPT_DIR
8+
echo $SRCDIR
9+
echo $PGSTACDIR
10+
711
if [[ "${CI}" ]]; then
812
set -x
913
fi
@@ -42,7 +46,7 @@ function test_formatting(){
4246
cd $SRCDIR/pypgstac
4347

4448
echo "Running ruff"
45-
ruff python tests
49+
ruff -n python tests
4650

4751
echo "Running mypy"
4852
mypy python

scripts/runinpypgstac

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,30 @@ do
2525
NOCACHE="--no-cache"
2626
elif [[ $ARG == "--build" ]]; then
2727
BUILD=1
28+
elif [[ $ARG == "--cpfiles" ]]; then
29+
CPFILES=1
2830
else
2931
CONTAINER_ARGS+=($ARG)
3032
fi
3133
done
3234
if [[ $BUILD == 1 ]]; then
3335
echo "Building docker images..."
36+
docker compose down -v --remove-orphans
3437
docker compose build $NOCACHE
38+
docker compose up -d pgstac
39+
sleep 4
3540
fi
3641
PGSTAC_RUNNING=$(docker compose ps pgstac --status running -q)
37-
docker compose run -T --rm -u $(id -u):$(id -g) pypgstac "${CONTAINER_ARGS[@]}"
42+
if [[ $CPFILES == 1 ]]; then
43+
docker ps | grep pypgstacworker
44+
[[ $? == 0 ]] && echo "Killing pypgstacworker" && docker kill pypgstacworker
45+
docker compose run -d --rm --name pypgstacworker pypgstac /bin/bash
46+
docker compose exec pypgstac "${CONTAINER_ARGS[@]}"
47+
docker cp pypgstacworker:/opt/src $SCRIPT_DIR/..
48+
docker kill pypgstacworker
49+
else
50+
docker compose run -T --rm pypgstac "${CONTAINER_ARGS[@]}"
51+
fi
3852
JOBEXITCODE=$?
3953
[[ $PGSTAC_RUNNING == "" ]] && docker compose stop pgstac
4054
exit $JOBEXITCODE

scripts/stageversion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/bash
22
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
33
cd $SCRIPT_DIR/..
4-
$SCRIPT_DIR/runinpypgstac stageversion "$@"
4+
$SCRIPT_DIR/runinpypgstac --build --cpfiles stageversion "$@"

scripts/test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
22
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
3-
$SCRIPT_DIR/runinpypgstac test "$@"
3+
$SCRIPT_DIR/runinpypgstac --build test "$@"

0 commit comments

Comments
 (0)