diff --git a/.travis.yml b/.travis.yml index 6e6dbf6c..85640a9e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,14 +31,6 @@ script: after_success: - sonar-scanner -deploy: - provider: script - script: bash deploy.sh sartography/cr-connect-workflow - skip_cleanup: true - on: - all_branches: true - condition: $TRAVIS_BRANCH =~ ^(dev|testing|demo|training|staging|master|rrt\/.*)$ - notifications: email: on_success: change diff --git a/Dockerfile b/Dockerfile index bc602d09..ef931d08 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,24 @@ -FROM sartography/cr-connect-python-base +FROM python:3.8 + +RUN pip install pipenv +RUN useradd _gunicorn --no-create-home --user-group + +RUN apt-get update && \ + apt-get install -y -q \ + gcc libssl-dev \ + curl postgresql-client git-core \ + gunicorn3 postgresql-client WORKDIR /app COPY Pipfile Pipfile.lock /app/ +RUN cd /app && pipenv lock --keep-outdated --requirements > requirements.txt +RUN pip install -r /app/requirements.txt RUN set -xe \ - && pipenv install --dev \ && apt-get remove -y gcc python3-dev libssl-dev \ && apt-get autoremove -y \ && apt-get clean -y \ - && rm -rf /var/lib/apt/lists/* \ - && useradd _gunicorn --no-create-home --user-group + && rm -rf /var/lib/apt/lists/* COPY . /app/ WORKDIR /app diff --git a/crc/scripts/email.py b/crc/scripts/email.py index 3160dc22..dcef5e8e 100644 --- a/crc/scripts/email.py +++ b/crc/scripts/email.py @@ -26,7 +26,7 @@ Example: email ("My Subject", "dhf8r@virginia.edu", pi.email) """ - def do_task_validate_only(self, task, *args, **kwargs): + def do_task_validate_only(self, task, study_id, workflow_id, *args, **kwargs): self.get_subject(args) self.get_email_recipients(task, args) self.get_content(task) diff --git a/crc/services/workflow_service.py b/crc/services/workflow_service.py index 4ddc6118..f8fe759e 100644 --- a/crc/services/workflow_service.py +++ b/crc/services/workflow_service.py @@ -172,6 +172,8 @@ class WorkflowService(object): # If we have a default_value or value_expression, try to set the default if field.has_property(Task.FIELD_PROP_VALUE_EXPRESSION) or (hasattr(field, 'default_value') and field.default_value): form_data[field.id] = WorkflowService.get_default_value(field, task) + if not field.has_property(Task.FIELD_PROP_REPEAT): + continue # If we are only populating required fields, and this isn't required. stop here. if required_only: diff --git a/deploy.sh b/deploy.sh deleted file mode 100755 index 04e3e81c..00000000 --- a/deploy.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash - -######################################################################### -# Builds the Docker image for the current git branch on Travis CI and -# publishes it to Docker Hub. -# -# Parameters: -# $1: Docker Hub repository to publish to -# -# Required environment variables (place in Settings menu on Travis CI): -# $DOCKER_USERNAME: Docker Hub username -# $DOCKER_TOKEN: Docker Hub access token -######################################################################### - -echo 'Building Docker image...' -DOCKER_REPO="$1" - -function branch_to_tag () { - if [ "$1" == "master" ]; then echo "latest"; else echo "$1" ; fi -} - -function branch_to_deploy_group() { - if [[ $1 =~ ^(rrt\/.*)$ ]]; then echo "rrt"; else echo "crconnect" ; fi -} - -DOCKER_TAG=$(branch_to_tag "$TRAVIS_BRANCH") - -DEPLOY_GROUP=$(branch_to_deploy_group "$TRAVIS_BRANCH") - -if [ "$DEPLOY_GROUP" == "rrt" ]; then - IFS='/' read -ra ARR <<< "$TRAVIS_BRANCH" # Split branch on '/' character - DOCKER_TAG=$(branch_to_tag "rrt_${ARR[1]}") -fi - -echo "DOCKER_REPO = $DOCKER_REPO" -echo "DOCKER_TAG = $DOCKER_TAG" - -echo "$DOCKER_TOKEN" | docker login -u "$DOCKER_USERNAME" --password-stdin || exit 1 -docker build -f Dockerfile -t "$DOCKER_REPO:$DOCKER_TAG" . || exit 1 - - -# Push Docker image to Docker Hub -echo "Publishing to Docker Hub..." -docker push "$DOCKER_REPO" || exit 1 -echo "Done." diff --git a/tests/test_email_script.py b/tests/test_email_script.py index ee3d7219..d1520314 100644 --- a/tests/test_email_script.py +++ b/tests/test_email_script.py @@ -1,9 +1,19 @@ from tests.base_test import BaseTest from crc import mail +import json class TestEmailScript(BaseTest): + def test_email_script_validation(self): + # This validates scripts.email.do_task_validate_only + # It also tests that we don't overwrite the default email_address with random text during validation + # Otherwise json would have an error about parsing the email address + self.load_example_data() + spec_model = self.load_test_spec('email_script') + rv = self.app.get('/v1.0/workflow-specification/%s/validate' % spec_model.id, headers=self.logged_in_headers()) + self.assertEqual([], rv.json) + def test_email_script(self): with mail.record_messages() as outbox: @@ -12,6 +22,7 @@ class TestEmailScript(BaseTest): first_task = self.get_workflow_api(workflow).next_task workflow = self.get_workflow_api(workflow) + self.assertEqual('dan@sartography.com', workflow.next_task.data['email_address']) self.complete_form(workflow, first_task, {'email_address': 'test@example.com'}) self.assertEqual(1, len(outbox))