diff --git a/CHANGELOG.rst b/CHANGELOG.rst index da697aaa6..2592a1aaa 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,19 @@ Changelog [0.7.dev8] ---------- +Docker +~~~~~~ + +* ``PANUSER`` owns ``conda``. #1068 +* Dockerfile cleanup for better builds. #1068 +* Docker image does not contain ``focuser`` extras by default. #1068 + +Testing +~~~~~~~ + +* Fix the log level in conftest. #1068 +* Move all tests into ``tests`` subdir from project root. #1068 +* Cleanup of testing setup, especially for GHA. #1068 [0.7.7] - 2021-01-19 -------------------- diff --git a/conftest.py b/conftest.py index 04f3f7f2c..5f0e26cc6 100644 --- a/conftest.py +++ b/conftest.py @@ -20,7 +20,7 @@ TESTING_LOG_LEVEL = 'TRACE' LOGGER_INFO = PanLogger() -logger = get_logger(console_log_file=TESTING_LOG_LEVEL) +logger = get_logger(console_log_level=TESTING_LOG_LEVEL) logger.enable('panoptes') # Add a level above TRACE and below DEBUG logger.level("testing", no=15, icon="🤖", color="") diff --git a/docker/Dockerfile b/docker/Dockerfile index 1958edfc7..c46b8a9a8 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -10,10 +10,13 @@ ENV LANG=C.UTF-8 LC_ALL=C.UTF-8 ARG panuser=pocs-user ARG userid=1000 ARG pan_dir=/var/panoptes +ARG pocs_dir="${pan_dir}/POCS" +ARG pip_install_extras="[google,testing]" ENV PANUSER $panuser ENV USERID $userid ENV PANDIR $pan_dir +ENV POCS $pocs_dir # Install system dependencies. RUN apt-get update && apt-get install --no-install-recommends --yes \ @@ -26,35 +29,42 @@ RUN apt-get update && apt-get install --no-install-recommends --yes \ useradd -u ${USERID} -o -c "PANOPTES POCS" \ -p panoptes -m -G plugdev,dialout,users,sudo ${PANUSER} && \ # Allow sudo without password. - echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers + echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \ + # Setup SSH so localhost works without password + mkdir -p "/home/${panuser}/.ssh" && \ + echo "Host localhost\n\tStrictHostKeyChecking no\n" >> "/home/${panuser}/.ssh/config" + +USER "${userid}" # Miniconda WORKDIR /tmp -RUN wget "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-$(uname -m).sh" \ +RUN echo "Installing conda via miniforge" && \ + sudo mkdir -p /conda && \ + sudo chown -R "${PANUSER}:${PANUSER}" /conda && \ + # Miniforge + wget "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-$(uname -m).sh" \ -O install-miniforge.sh && \ - /bin/sh /tmp/install-miniforge.sh -b -f -p /conda && \ + /bin/sh install-miniforge.sh -b -f -p /conda && \ # Initialize conda for the shells. /conda/bin/conda init bash -COPY environment.yaml . -RUN /conda/bin/conda env update -n base -f environment.yaml && \ +ENV PATH "/home/${PANUSER}/.local/bin:$PATH" + +RUN echo "Setting up filesystem and installing conda." && \ # Create PANOPTES directories. - mkdir -p ${PANDIR} && \ + sudo mkdir -p ${PANDIR} && \ + sudo chown -R "${PANUSER}:${PANUSER}" ${PANDIR} && \ mkdir -p ${PANDIR}/logs && \ - mkdir -p ${PANDIR}/images + mkdir -p ${PANDIR}/images && \ + mkdir -p ${POCS} -ARG pocs_dir="${PANDIR}/POCS" -ENV POCS $pocs_dir -ENV PATH "/home/${PANUSER}/.local/bin:$PATH" - -ARG pip_extras="[google,testing]" +COPY environment.yaml . +RUN /conda/bin/conda env update -n base -f environment.yaml -USER "${userid}" WORKDIR "${POCS}" COPY --chown="${userid}:${userid}" . . -RUN echo "Installing editable module with ${pip_extras}" && \ - sudo chown -R ${PANUSER}:${PANUSER} ${PANDIR} && \ - /conda/bin/pip install -e ".${pip_extras}" && \ +RUN echo "Installing editable module with ${pip_install_extras}" && \ + /conda/bin/pip install -e ".${pip_install_extras}" && \ # Remove git folder rm -rf "${POCS}/.git" && \ # Cleanup diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index d70c81d43..a9b54a9fc 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -41,6 +41,7 @@ services: PANOPTES_CONFIG_FILE: volumes: - pocsdir:/var/panoptes/POCS + - /var/panoptes/logs:/var/panoptes/logs # No-op to keep machine running, use $POCS/bin/pocs-shell to access command: [ "wait-for-it ${PANOPTES_CONFIG_PORT}:${PANOPTES_CONFIG_PORT} -- echo POCS yo!" ] volumes: diff --git a/setup.cfg b/setup.cfg index 058094fa7..aff69ef8a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -93,6 +93,7 @@ extras = True addopts = --cov panoptes.pocs --cov panoptes.peas + --cov tests --cov-branch --cov-report term-missing:skip-covered --cov-report xml:build/coverage.xml diff --git a/src/panoptes/pocs/tests/__init__.py b/tests/__init__.py similarity index 100% rename from src/panoptes/pocs/tests/__init__.py rename to tests/__init__.py diff --git a/src/panoptes/pocs/tests/bisque/__init__.py b/tests/bisque/__init__.py similarity index 100% rename from src/panoptes/pocs/tests/bisque/__init__.py rename to tests/bisque/__init__.py diff --git a/src/panoptes/pocs/tests/bisque/test_dome.py b/tests/bisque/test_dome.py similarity index 100% rename from src/panoptes/pocs/tests/bisque/test_dome.py rename to tests/bisque/test_dome.py diff --git a/src/panoptes/pocs/tests/bisque/test_mount.py b/tests/bisque/test_mount.py similarity index 100% rename from src/panoptes/pocs/tests/bisque/test_mount.py rename to tests/bisque/test_mount.py diff --git a/src/panoptes/pocs/tests/bisque/test_run.py b/tests/bisque/test_run.py similarity index 100% rename from src/panoptes/pocs/tests/bisque/test_run.py rename to tests/bisque/test_run.py diff --git a/src/panoptes/pocs/tests/test_base.py b/tests/test_base.py similarity index 100% rename from src/panoptes/pocs/tests/test_base.py rename to tests/test_base.py diff --git a/src/panoptes/pocs/tests/test_base_scheduler.py b/tests/test_base_scheduler.py similarity index 100% rename from src/panoptes/pocs/tests/test_base_scheduler.py rename to tests/test_base_scheduler.py diff --git a/src/panoptes/pocs/tests/test_camera.py b/tests/test_camera.py similarity index 100% rename from src/panoptes/pocs/tests/test_camera.py rename to tests/test_camera.py diff --git a/src/panoptes/pocs/tests/test_codestyle.py b/tests/test_codestyle.py similarity index 100% rename from src/panoptes/pocs/tests/test_codestyle.py rename to tests/test_codestyle.py diff --git a/src/panoptes/pocs/tests/test_constraints.py b/tests/test_constraints.py similarity index 100% rename from src/panoptes/pocs/tests/test_constraints.py rename to tests/test_constraints.py diff --git a/src/panoptes/pocs/tests/test_dispatch_scheduler.py b/tests/test_dispatch_scheduler.py similarity index 100% rename from src/panoptes/pocs/tests/test_dispatch_scheduler.py rename to tests/test_dispatch_scheduler.py diff --git a/src/panoptes/pocs/tests/test_dome_astrohaven.py b/tests/test_dome_astrohaven.py similarity index 100% rename from src/panoptes/pocs/tests/test_dome_astrohaven.py rename to tests/test_dome_astrohaven.py diff --git a/src/panoptes/pocs/tests/test_dome_simulator.py b/tests/test_dome_simulator.py similarity index 100% rename from src/panoptes/pocs/tests/test_dome_simulator.py rename to tests/test_dome_simulator.py diff --git a/src/panoptes/pocs/tests/test_field.py b/tests/test_field.py similarity index 100% rename from src/panoptes/pocs/tests/test_field.py rename to tests/test_field.py diff --git a/src/panoptes/pocs/tests/test_filterwheel.py b/tests/test_filterwheel.py similarity index 100% rename from src/panoptes/pocs/tests/test_filterwheel.py rename to tests/test_filterwheel.py diff --git a/src/panoptes/pocs/tests/test_focuser.py b/tests/test_focuser.py similarity index 100% rename from src/panoptes/pocs/tests/test_focuser.py rename to tests/test_focuser.py diff --git a/src/panoptes/pocs/tests/test_images.py b/tests/test_images.py similarity index 100% rename from src/panoptes/pocs/tests/test_images.py rename to tests/test_images.py diff --git a/src/panoptes/pocs/tests/test_ioptron.py b/tests/test_ioptron.py similarity index 100% rename from src/panoptes/pocs/tests/test_ioptron.py rename to tests/test_ioptron.py diff --git a/src/panoptes/pocs/tests/test_mount.py b/tests/test_mount.py similarity index 100% rename from src/panoptes/pocs/tests/test_mount.py rename to tests/test_mount.py diff --git a/src/panoptes/pocs/tests/test_mount_simulator.py b/tests/test_mount_simulator.py similarity index 100% rename from src/panoptes/pocs/tests/test_mount_simulator.py rename to tests/test_mount_simulator.py diff --git a/src/panoptes/pocs/tests/test_observation.py b/tests/test_observation.py similarity index 100% rename from src/panoptes/pocs/tests/test_observation.py rename to tests/test_observation.py diff --git a/src/panoptes/pocs/tests/test_observatory.py b/tests/test_observatory.py similarity index 100% rename from src/panoptes/pocs/tests/test_observatory.py rename to tests/test_observatory.py diff --git a/src/panoptes/pocs/tests/test_pocs.py b/tests/test_pocs.py similarity index 100% rename from src/panoptes/pocs/tests/test_pocs.py rename to tests/test_pocs.py diff --git a/src/panoptes/pocs/tests/test_scheduler.py b/tests/test_scheduler.py similarity index 100% rename from src/panoptes/pocs/tests/test_scheduler.py rename to tests/test_scheduler.py diff --git a/src/panoptes/peas/tests/test_sensors.py b/tests/test_sensors.py similarity index 100% rename from src/panoptes/peas/tests/test_sensors.py rename to tests/test_sensors.py diff --git a/src/panoptes/pocs/tests/test_state_machine.py b/tests/test_state_machine.py similarity index 100% rename from src/panoptes/pocs/tests/test_state_machine.py rename to tests/test_state_machine.py diff --git a/src/panoptes/pocs/tests/utils/test_logger.py b/tests/utils/test_logger.py similarity index 100% rename from src/panoptes/pocs/tests/utils/test_logger.py rename to tests/utils/test_logger.py