Skip to content

Commit

Permalink
Implement stage tests for connect (borked)
Browse files Browse the repository at this point in the history
  • Loading branch information
ianpittwood committed Apr 3, 2024
1 parent bf20f94 commit d02d71d
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 40 deletions.
9 changes: 8 additions & 1 deletion connect-content-init/Dockerfile.ubuntu2204
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"

# Install required tools:
Expand All @@ -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
12 changes: 3 additions & 9 deletions connect-content-init/test/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 15 additions & 1 deletion connect/Dockerfile.ubuntu2204
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"

COPY --chmod=0775 startup.sh /usr/local/bin/startup.sh
Expand Down Expand Up @@ -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
12 changes: 3 additions & 9 deletions connect/test/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
87 changes: 67 additions & 20 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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 = {
Expand All @@ -229,16 +236,16 @@ 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, ".", "-")}"]
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 = [
"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}"
Expand All @@ -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"
Expand All @@ -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}"
Expand All @@ -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 = [
Expand All @@ -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"]

Expand Down Expand Up @@ -380,6 +425,8 @@ target "workbench" {
}
}

### Specialty image targets ###

target "workbench-for-google-cloud-workstations" {
inherits = ["base"]

Expand Down

0 comments on commit d02d71d

Please sign in to comment.