From d02d71d5840868ce6b43ca6cc4c83bd3f9072b27 Mon Sep 17 00:00:00 2001 From: Ian Pittwood Date: Wed, 3 Apr 2024 08:40:31 -0700 Subject: [PATCH] Implement stage tests for connect (borked) --- connect-content-init/Dockerfile.ubuntu2204 | 9 ++- connect-content-init/test/run_tests.sh | 12 +-- connect/Dockerfile.ubuntu2204 | 16 +++- connect/test/run_tests.sh | 12 +-- docker-bake.hcl | 87 +++++++++++++++++----- 5 files changed, 96 insertions(+), 40 deletions(-) diff --git a/connect-content-init/Dockerfile.ubuntu2204 b/connect-content-init/Dockerfile.ubuntu2204 index ac1e8be5..b6533d0b 100644 --- a/connect-content-init/Dockerfile.ubuntu2204 +++ b/connect-content-init/Dockerfile.ubuntu2204 @@ -1,5 +1,5 @@ # Tag from https://hub.docker.com/_/ubuntu/ -FROM ubuntu:22.04 +FROM ubuntu:22.04 as build LABEL maintainer="RStudio Connect " # Install required tools: @@ -23,3 +23,10 @@ RUN mkdir -p /rsc-staging && \ COPY --chmod=755 entrypoint.sh /usr/local/bin/entrypoint.sh CMD ["/usr/local/bin/entrypoint.sh"] + +FROM build as test + +ARG RSC_VERSION=2024.02.0 + +RUN --mount=type=bind,target=/tmp/test,source=test/ \ + /tmp/test/run_tests.sh diff --git a/connect-content-init/test/run_tests.sh b/connect-content-init/test/run_tests.sh index ff787bca..139739f3 100755 --- a/connect-content-init/test/run_tests.sh +++ b/connect-content-init/test/run_tests.sh @@ -2,19 +2,13 @@ # install goss -GOSS_FILE=${GOSS_FILE:-/tmp/goss.yaml} -GOSS_VARS=${GOSS_VARS:-/tmp/goss_vars.yaml} -GOSS_VERSION=${GOSS_VERSION:-0.3.8} +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 diff --git a/connect/Dockerfile.ubuntu2204 b/connect/Dockerfile.ubuntu2204 index ead6a71d..cc11a80c 100644 --- a/connect/Dockerfile.ubuntu2204 +++ b/connect/Dockerfile.ubuntu2204 @@ -1,10 +1,11 @@ +# syntax=docker/dockerfile:1-labs ARG R_VERSION=4.2.3 ARG R_VERSION_ALT=4.1.3 ARG PYTHON_VERSION=3.9.17 ARG PYTHON_VERSION_ALT=3.8.17 ARG SRC_IMAGE_NAME=product-base-pro 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 " COPY --chmod=0775 startup.sh /usr/local/bin/startup.sh @@ -44,3 +45,16 @@ VOLUME ["/data"] 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 RSC_VERSION=2024.02.0 +ARG OS=ubuntu2204 + +RUN --mount=type=bind,target=/tmp/test,source=test/ \ + --security=insecure \ + /tmp/test/run_tests.sh diff --git a/connect/test/run_tests.sh b/connect/test/run_tests.sh index 250f2161..eb91cfaf 100755 --- a/connect/test/run_tests.sh +++ b/connect/test/run_tests.sh @@ -10,19 +10,13 @@ sleep 15 echo '--> Startup 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 diff --git a/docker-bake.hcl b/docker-bake.hcl index 58d0b328..29f3784c 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -121,7 +121,21 @@ group "package-manager-images" { ] } -### Base Images ### +group "connect-images" { + targets = [ + "connect", + "test-connect", + ] +} + +group "connect-content-init-images" { + targets = [ + "connect-content-init", + "test-connect-content-init", + ] +} + +### Base Image targets ### target "base" { labels = { @@ -205,17 +219,10 @@ target "test-product-base-pro" { inherits = ["product-base-pro-${builds.os}-r${replace(builds.r_primary, ".", "-")}_${replace(builds.r_alternate, ".", "-")}-py${replace(builds.py_primary, ".", "-")}_${replace(builds.py_alternate, ".", "-")}"] target = "test" - name = "product-base-pro-${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-base-pro:${builds.os}-r${builds.r_primary}_${builds.r_alternate}-py${builds.py_primary}_${builds.py_alternate}", - "docker.io/rstudio/product-base-pro:${builds.os}-r${builds.r_primary}_${builds.r_alternate}-py${builds.py_primary}_${builds.py_alternate}", - ] + name = "test-product-base-pro-${builds.os}-r${replace(builds.r_primary, ".", "-")}_${replace(builds.r_alternate, ".", "-")}-py${replace(builds.py_primary, ".", "-")}_${replace(builds.py_alternate, ".", "-")}" dockerfile = "Dockerfile.${builds.os}" context = "product/pro" - contexts = { - baseapp = "target:product-base-${builds.os}-r${replace(builds.r_primary, ".", "-")}_${replace(builds.r_alternate, ".", "-")}-py${replace(builds.py_primary, ".", "-")}_${replace(builds.py_alternate, ".", "-")}" - } matrix = PRO_BUILD_MATRIX args = { @@ -229,7 +236,7 @@ target "test-product-base-pro" { } } -### Package Manager ### +### Package Manager targets ### target "package-manager" { inherits = ["product-base-${builds.os}-r${replace(builds.r_primary, ".", "-")}_${replace(builds.r_alternate, ".", "-")}-py${replace(builds.py_primary, ".", "-")}_${replace(builds.py_alternate, ".", "-")}"] @@ -237,8 +244,8 @@ target "package-manager" { 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}", + "ghcr.io/rstudio/rstudio-package-manager:${builds.os}-r${builds.r_primary}_${builds.r_alternate}-py${builds.py_primary}_${builds.py_alternate}", + "docker.io/rstudio/rstudio-package-manager:${builds.os}-r${builds.r_primary}_${builds.r_alternate}-py${builds.py_primary}_${builds.py_alternate}", ] dockerfile = "Dockerfile.${builds.os}" @@ -261,11 +268,7 @@ 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}", - ] + name = "test-package-manager-${builds.os}-r${replace(builds.r_primary, ".", "-")}_${replace(builds.r_alternate, ".", "-")}-py${replace(builds.py_primary, ".", "-")}_${replace(builds.py_alternate, ".", "-")}" dockerfile = "Dockerfile.${builds.os}" context = "package-manager" @@ -280,13 +283,16 @@ target "test-package-manager" { } } +### Connect targets ### + target "connect" { - inherits = ["base"] + inherits = ["product-base-pro-${builds.os}-r${replace(builds.r_primary, ".", "-")}_${replace(builds.r_alternate, ".", "-")}-py${replace(builds.py_primary, ".", "-")}_${replace(builds.py_alternate, ".", "-")}"] + target = "build" name = "connect-${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-connect:${builds.os}-r${builds.r_primary}_${builds.r_alternate}-py${builds.py_primary}_${builds.py_alternate}", - "docker.io/rstudio/product-connect:${builds.os}-r${builds.r_primary}_${builds.r_alternate}-py${builds.py_primary}_${builds.py_alternate}", + "ghcr.io/rstudio/rstudio-connect:${builds.os}-r${builds.r_primary}_${builds.r_alternate}-py${builds.py_primary}_${builds.py_alternate}", + "docker.io/rstudio/rstudio-connect:${builds.os}-r${builds.r_primary}_${builds.r_alternate}-py${builds.py_primary}_${builds.py_alternate}", ] dockerfile = "Dockerfile.${builds.os}" @@ -305,8 +311,29 @@ target "connect" { } } +# FIXME: This target requires a privileged environment which bake cannot provide +target "test-connect" { + inherits = ["connect-${builds.os}-r${replace(builds.r_primary, ".", "-")}_${replace(builds.r_alternate, ".", "-")}-py${replace(builds.py_primary, ".", "-")}_${replace(builds.py_alternate, ".", "-")}"] + target = "test" + + name = "test-connect-${builds.os}-r${replace(builds.r_primary, ".", "-")}_${replace(builds.r_alternate, ".", "-")}-py${replace(builds.py_primary, ".", "-")}_${replace(builds.py_alternate, ".", "-")}" + + dockerfile = "Dockerfile.${builds.os}" + context = "connect" + + matrix = CONNECT_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 + RSC_VERSION = CONNECT_VERSION + } +} + target "connect-content-init" { inherits = ["base"] + target = "build" name = "connect-content-init-${builds.os}" tags = [ @@ -324,6 +351,24 @@ target "connect-content-init" { } } +target "test-connect-content-init" { + inherits = ["connect-content-init-${builds.os}"] + target = "test" + + name = "test-connect-content-init-${builds.os}" + + dockerfile = "Dockerfile.${builds.os}" + context = "connect-content-init" + + matrix = CONNECT_CONTENT_INIT_BUILD_MATRIX + + args = { + RSC_VERSION = CONNECT_VERSION + } +} + +### Workbench targets ### + target "r-session-complete" { inherits = ["base"] @@ -380,6 +425,8 @@ target "workbench" { } } +### Specialty image targets ### + target "workbench-for-google-cloud-workstations" { inherits = ["base"]