Skip to content

Commit

Permalink
Implement stage tests for ppm
Browse files Browse the repository at this point in the history
  • Loading branch information
ianpittwood committed Apr 3, 2024
1 parent b164335 commit bf20f94
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 14 deletions.
38 changes: 36 additions & 2 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,20 @@ group "base-images" {
]
}

group "package-manager-images" {
targets = [
"package-manager",
"test-package-manager",
]
}

### Base Images ###

target "base" {
labels = {
"maintainer" = "Posit Docker <[email protected]>"
}
}
}

target "product-base" {
inherits = ["base"]
Expand Down Expand Up @@ -220,9 +229,11 @@ target "test-product-base-pro" {
}
}

### Package Manager ###

target "package-manager" {
inherits = ["base"]
inherits = ["product-base-${builds.os}-r${replace(builds.r_primary, ".", "-")}_${replace(builds.r_alternate, ".", "-")}-py${replace(builds.py_primary, ".", "-")}_${replace(builds.py_alternate, ".", "-")}"]
target = "build"

name = "package-manager-${builds.os}-r${replace(builds.r_primary, ".", "-")}_${replace(builds.r_alternate, ".", "-")}-py${replace(builds.py_primary, ".", "-")}_${replace(builds.py_alternate, ".", "-")}"
tags = [
Expand All @@ -246,6 +257,29 @@ target "package-manager" {
}
}

target "test-package-manager" {
inherits = ["package-manager-${builds.os}-r${replace(builds.r_primary, ".", "-")}_${replace(builds.r_alternate, ".", "-")}-py${replace(builds.py_primary, ".", "-")}_${replace(builds.py_alternate, ".", "-")}"]
target = "test"

name = "package-manager-${builds.os}-r${replace(builds.r_primary, ".", "-")}_${replace(builds.r_alternate, ".", "-")}-py${replace(builds.py_primary, ".", "-")}_${replace(builds.py_alternate, ".", "-")}"
tags = [
"ghcr.io/rstudio/product-package-manager:${builds.os}-r${builds.r_primary}_${builds.r_alternate}-py${builds.py_primary}_${builds.py_alternate}",
"docker.io/rstudio/product-package-manager:${builds.os}-r${builds.r_primary}_${builds.r_alternate}-py${builds.py_primary}_${builds.py_alternate}",
]

dockerfile = "Dockerfile.${builds.os}"
context = "package-manager"

matrix = PACKAGE_MANAGER_BUILD_MATRIX
args = {
R_VERSION = builds.r_primary
R_VERSION_ALT = builds.r_alternate
PYTHON_VERSION = builds.py_primary
PYTHON_VERSION_ALT = builds.py_alternate
RSPM_VERSION = PACKAGE_MANAGER_VERSION
}
}

target "connect" {
inherits = ["base"]

Expand Down
14 changes: 13 additions & 1 deletion package-manager/Dockerfile.ubuntu2204
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ARG PYTHON_VERSION=3.12.1
ARG PYTHON_VERSION_ALT=3.11.7
ARG SRC_IMAGE_NAME=product-base
ARG REGISTRY=ghcr.io
FROM ${REGISTRY}/rstudio/${SRC_IMAGE_NAME}:ubuntu2204-r${R_VERSION}_${R_VERSION_ALT}-py${PYTHON_VERSION}_${PYTHON_VERSION_ALT}
FROM ${REGISTRY}/rstudio/${SRC_IMAGE_NAME}:ubuntu2204-r${R_VERSION}_${R_VERSION_ALT}-py${PYTHON_VERSION}_${PYTHON_VERSION_ALT} as build
LABEL maintainer="RStudio Docker <[email protected]>"

ARG PYTHON_VERSION=3.9.17
Expand Down Expand Up @@ -50,3 +50,15 @@ RUN license-manager initialize --userspace || true

ENTRYPOINT ["tini", "--"]
CMD ["/usr/local/bin/startup.sh"]

FROM build as test

ARG R_VERSION=4.2.3
ARG R_VERSION_ALT=4.1.3
ARG PYTHON_VERSION=3.12.1
ARG PYTHON_VERSION_ALT=3.11.7
ARG RSPM_VERSION=2023.12.0-13
ARG OS=ubuntu2204

RUN --mount=type=bind,target=/tmp/test,source=test/ \
/tmp/test/run_tests.sh
15 changes: 4 additions & 11 deletions package-manager/test/run_tests.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash

# start connect
trap 'err=$?; echo >&2 "run_tests.sh encountered an error: $err"; cat /tmp/startup.log; exit $err' ERR

# start package manager
Expand All @@ -8,21 +9,13 @@ tini -- /usr/local/bin/startup.sh >/tmp/startup.log 2>&1 &
echo '--> Waiting for startup'
sleep 15

echo '--> Startup (hopefully) complete'

GOSS_FILE=${GOSS_FILE:-/tmp/goss.yaml}
GOSS_VARS=${GOSS_VARS:-/tmp/goss_vars.yaml}
GOSS_VERSION=${GOSS_VERSION:-0.3.16}
GOSS_FILE=${GOSS_FILE:-/tmp/test/goss.yaml}
GOSS_VERSION=${GOSS_VERSION:-0.4.6}
GOSS_MAX_CONCURRENT=${GOSS_MAX_CONCURRENT:-50}

# default to empty var file (since vars are not necessary)
if [ ! -f "$GOSS_VARS" ]; then
touch $GOSS_VARS
fi

# install goss to tmp location and make executable
curl -sL https://github.com/aelsabbahy/goss/releases/download/v$GOSS_VERSION/goss-linux-amd64 -o /tmp/goss \
&& chmod +x /tmp/goss \
&& GOSS=/tmp/goss

GOSS_FILE=$GOSS_FILE GOSS_VARS=$GOSS_VARS $GOSS v --format documentation --max-concurrent $GOSS_MAX_CONCURRENT
GOSS_FILE=$GOSS_FILE $GOSS v --format documentation --max-concurrent $GOSS_MAX_CONCURRENT

0 comments on commit bf20f94

Please sign in to comment.