diff --git a/.dockerignore b/.dockerignore index 39979854..c7eca478 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,8 +1,2 @@ -build/ -dist/ -notebooks*/ -*/node_modules/ -*.egg-info/ -.eggs/ -*.pyc -.git/ +* +!Pipfile* diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bfb8114e..25c77ec2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -52,9 +52,15 @@ jobs: - run: make install - run: make lint - run: make test - # - run: make image${{ matrix.python-version }} - # - run: make -C selenium build - # - run: make test-selenium + - if: false + name: currently busted selenium test stuff + run: > + make image${{ matrix.python-version }} + make -C selenium build + make -C selenium clean + make -C selenium test-env-up + make -C selenium jupyter-up + make -C selenium test distributions: needs: test runs-on: ubuntu-latest diff --git a/Dockerfile b/Dockerfile index 72bd8faa..29b8870c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,18 +5,30 @@ LABEL maintainer="RStudio Connect " ARG NB_UID ARG NB_GID ARG PY_VERSION -RUN apt-get update -qq \ - && apt-get install -y make +RUN apt-get update -qq && \ + apt-get install -y make curl xz-utils git && \ + curl -fsSL "https://nodejs.org/dist/v12.18.1/node-v12.18.1-linux-x64.tar.xz" | \ + tar --strip-components=1 -C /usr/local -xJf - && \ + npm install -g yarn + RUN getent group ${NB_GID} || groupadd -g ${NB_GID} builder RUN useradd --password password \ --create-home \ --home-dir /home/builder \ --uid ${NB_UID} \ --gid ${NB_GID} \ - builder - -RUN conda update conda + builder && \ + mkdir -p /rsconnect_jupyter && \ + chown ${NB_UID}:${NB_GID} /rsconnect_jupyter USER ${NB_UID}:${NB_GID} -RUN bash -c 'cd /home/builder \ - && conda create --yes --channel conda-forge --name py${PY_VERSION/./} python=${PY_VERSION} jupyter numpy matplotlib setuptools pip pipenv' +WORKDIR /rsconnect_jupyter +ENV WORKON_HOME=/home/builder \ + PIPENV_DONT_LOAD_ENV=1 \ + PIPENV_SHELL=/bin/bash \ + PATH=/home/builder/.local/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +COPY Pipfile Pipfile +COPY Pipfile.lock Pipfile.lock +RUN python -m pip install -I -U pip pipenv && \ + pipenv install --dev --python=/usr/local/bin/python && \ + rm -vf Pipfile* diff --git a/Makefile b/Makefile index ab4bc71d..b9cc600c 100644 --- a/Makefile +++ b/Makefile @@ -22,28 +22,12 @@ image%: docker build \ --tag $(IMAGE)$* \ --file Dockerfile \ - --build-arg BASE_IMAGE=continuumio/miniconda:4.4.10 \ + --build-arg BASE_IMAGE=python:$*-slim \ --build-arg NB_UID=$(NB_UID) \ --build-arg NB_GID=$(NB_GID) \ --build-arg PY_VERSION=$* \ . -.PHONY: launch -launch: - docker run --rm -i -t \ - -v $(CURDIR)/notebooks$(PY_VERSION):/notebooks \ - -v $(CURDIR):/rsconnect_jupyter \ - -e NB_UID=$(NB_UID) \ - -e NB_GID=$(NB_GID) \ - -e PY_VERSION=$(PY_VERSION) \ - -p :$(PORT):9999 \ - $(DOCKER_IMAGE) \ - /rsconnect_jupyter/run.sh $(TARGET) - - -notebook%: - make DOCKER_IMAGE=$(IMAGE)$* PY_VERSION=$* TARGET=run launch - .PHONY: all-tests all-tests: test2.7 test3.5 test3.6 test3.7 test3.8 @@ -51,9 +35,6 @@ all-tests: test2.7 test3.5 test3.6 test3.7 test3.8 test: version-frontend pipenv run pytest -vv --cov=rsconnect_jupyter tests/ -test%: version-frontend - make DOCKER_IMAGE=rstudio/rsconnect-jupyter-py$* PY_VERSION=$* TARGET=test launch - .PHONY: test-selenium test-selenium: $(MAKE) -C selenium clean test-env-up jupyter-up test || EXITCODE=$$? ; \ @@ -79,6 +60,7 @@ run: install .PHONY: install install: yarn pipenv install --dev + $(MAKE) version-frontend pipenv run pip install -e . pipenv run jupyter-nbextension install --symlink --user --py rsconnect_jupyter pipenv run jupyter-nbextension enable --py rsconnect_jupyter diff --git a/mock_connect.py b/mock_connect.py index 41ed19b7..d95b2f1c 100644 --- a/mock_connect.py +++ b/mock_connect.py @@ -17,7 +17,16 @@ from pprint import pprint # noinspection PyPackageRequirements -from flask import Flask, Blueprint, abort, after_this_request, g, request, url_for, jsonify +from flask import ( + Flask, + Blueprint, + abort, + after_this_request, + g, + request, + url_for, + jsonify, +) def error(code, reason): @@ -307,8 +316,7 @@ def get_task(task): @api.route("server_settings") @json def server_settings(): - # for our purposes, any non-error response will do - return {} + return {"not_empty": True} # noinspection PyUnresolvedReferences diff --git a/rsconnect_jupyter/__init__.py b/rsconnect_jupyter/__init__.py index c82a6856..3e0d3e52 100644 --- a/rsconnect_jupyter/__init__.py +++ b/rsconnect_jupyter/__init__.py @@ -74,6 +74,15 @@ def post(self, action): disable_tls_check = data["disable_tls_check"] cadata = data.get("cadata", None) + self.log.warning( + "server_address=%r api_key=%r disable_tls_check=%r cadata=%r", + server_address, + api_key, + disable_tls_check, + cadata, + ) + canonical_address = None + result = None try: canonical_address, result = test_server( RSConnectServer(server_address, api_key, disable_tls_check, cadata) @@ -96,6 +105,8 @@ def post(self, action): + u' upload it using "Upload TLS Certificate Bundle" below.', ) except Exception as err: + self.log.exception("Unable to verify that the provided server is running RStudio Connect") + self.log.warning("canonical_address=%r result=%r", canonical_address, result) raise web.HTTPError( 400, u"Unable to verify that the provided server is running RStudio Connect: %s" % err, ) diff --git a/selenium/Makefile b/selenium/Makefile index fc9ea7cf..d1216002 100644 --- a/selenium/Makefile +++ b/selenium/Makefile @@ -34,7 +34,7 @@ SCALE_FIREFOX=${SCALE} SCALE_CHROME=${SCALE} SELENIUM_VERSION=3.8.1-dubnium TMP_PIPE=tmp.pipe -TRE_IMAGE?=rstudio/checkrs-tew:0.1.0 +TRE_IMAGE?=rstudio/checkrs-tew:0.3.2 # Allocate a tty and keep stdin open when running locally # Jenkins nodes don't have input tty, so we set this to "" @@ -46,7 +46,7 @@ DOCKER_RUN_COMMAND=docker run --rm --init \ --network=$(NETWORK) \ --volume=$(CURDIR)/..:${RSCONNECT_DIR} \ --volume=$(CURDIR)/../notebooks$(PY_VERSION):${NOTEBOOKS_DIR} \ - --user=`id -u`:`id -g` \ + --user=$(NB_UID):$(NB_GID) \ --workdir=${RSCONNECT_DIR}/selenium \ ${TRE_IMAGE} @@ -82,8 +82,8 @@ build-mock-connect: docker build -t ${CONNECT_IMAGE} ${CONNECT_DOCKERFILE_DIR} clean: - rm -f *.png *.log *.xml ${TMP_PIPE}; - rm -rf .pytest_cache; + rm -f *.png *.log *.xml ${TMP_PIPE} + rm -rf .pytest_cache distclean: clean @@ -123,7 +123,7 @@ wait-for-systems-up: --name=systemstat \ --network=$(NETWORK) \ --volume=${CURDIR}/..:${RSCONNECT_DIR} \ - --user=`id -u`:`id -g` \ + --user=$(NB_UID):$(NB_GID) \ --workdir=${RSCONNECT_DIR}/selenium \ ${TRE_IMAGE} \ ./wait_for_systems_up.sh \ @@ -156,7 +156,7 @@ network-up: @if [ "${NETWORK_EXISTS}" = "1" ] ; then \ echo "Creating network: ${NETWORK}"; \ docker network create --driver bridge ${NETWORK} ; \ - fi; + fi network-down: connect-down grid-down $(eval NETWORK_EXISTS=$(shell docker network inspect ${NETWORK} > /dev/null 2>&1 && echo 0 || echo 1)) @@ -167,13 +167,10 @@ network-down: connect-down grid-down done; \ echo "Removing network: ${NETWORK}"; \ docker network rm ${NETWORK}; \ - fi; - -# I think we need TINI_SUBREAPER set because we are using --init, but run.sh -# calls a make command which launches another command. + fi jupyter-up: - @echo -n "Creating ${JUPYTER_HOST} ..." + @echo "Creating ${JUPYTER_HOST} ..." @docker run --rm -d --init \ ${DOCKER_TTY_FLAGS} \ --name=${JUPYTER_HOST} \ @@ -187,7 +184,7 @@ jupyter-up: --publish=:${JUPYTER_PORT}:${JUPYTER_PORT} \ --workdir=${RSCONNECT_DIR} \ $(JUPYTER_IMAGE) \ - ${RSCONNECT_DIR}/run.sh run \ + make -C ${RSCONNECT_DIR} run \ 1>/dev/null @docker logs -f ${JUPYTER_HOST} > ${JUPYTER_LOG} & @echo " done" @@ -195,13 +192,13 @@ jupyter-up: jupyter-down: $(eval JUPYTER_EXISTS=$(shell docker container inspect ${JUPYTER_HOST} > /dev/null 2>&1 && echo 0 || echo 1)) @if [ "${JUPYTER_EXISTS}" = "0" ] ; then \ - echo -n "Stopping ${JUPYTER_HOST} ..."; \ + echo "Stopping ${JUPYTER_HOST} ..."; \ docker stop ${JUPYTER_HOST} 1>/dev/null; \ echo " done"; \ - fi; + fi connect-up: - @echo -n "Creating ${CONNECT_HOST} ..." + @echo "Creating ${CONNECT_HOST} ..." @docker run --rm -d --init \ ${DOCKER_TTY_FLAGS} \ --name=${CONNECT_HOST} \ @@ -219,10 +216,10 @@ connect-up: connect-down: $(eval CONNECT_EXISTS=$(shell docker container inspect ${CONNECT_HOST} > /dev/null 2>&1 && echo 0 || echo 1)) @if [ "${CONNECT_EXISTS}" = "0" ] ; then \ - echo -n "Stopping ${CONNECT_HOST} ..."; \ + echo "Stopping ${CONNECT_HOST} ..."; \ docker stop ${CONNECT_HOST} 1>/dev/null; \ echo " done"; \ - fi; + fi .PHONY: all