From 41e5e8ea00354da153193fd36c3eda8d26740c45 Mon Sep 17 00:00:00 2001 From: "jessdtate@gmail.com" Date: Fri, 28 Jun 2024 12:17:12 -0600 Subject: [PATCH 1/7] adding heroku to allowed hosts --- shapeworks_cloud/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shapeworks_cloud/settings.py b/shapeworks_cloud/settings.py index 2612ab59..25370ad5 100644 --- a/shapeworks_cloud/settings.py +++ b/shapeworks_cloud/settings.py @@ -63,5 +63,5 @@ class ProductionConfiguration(ShapeworksCloudMixin, ProductionBaseConfiguration) class HerokuProductionConfiguration(ShapeworksCloudMixin, HerokuProductionBaseConfiguration): - ALLOWED_HOSTS = ['shapeworks-cloud.herokuapp.com', 'app.shapeworks-cloud.org'] + ALLOWED_HOSTS = ['shapeworks-cloud.herokuapp.com', 'herokuapp.com', 'app.shapeworks-cloud.org'] LOGIN_REDIRECT_URL = 'https://www.shapeworks-cloud.org' From 50ddcbaa5c52a424aa6d50162a17b0fcd10fbf37 Mon Sep 17 00:00:00 2001 From: Jake Wagoner Date: Mon, 1 Jul 2024 12:10:25 -0600 Subject: [PATCH 2/7] Use CI/CD keyword for download-upload-cycle --- swcc/tests/test_download_upload.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/swcc/tests/test_download_upload.py b/swcc/tests/test_download_upload.py index 43d520d3..466b3d32 100644 --- a/swcc/tests/test_download_upload.py +++ b/swcc/tests/test_download_upload.py @@ -54,12 +54,8 @@ def public_server_download(download_dir): dataset_subset = [ d for d in all_datasets - if d.name - in [ - 'deep_ssm_femur_tiny_test', - 'ellipsoid_multiple_domain_tiny_test', - 'left_atrium_tiny_test', - ] + if 'CI/CD' + in d.keywords ] project_subset = [next(d.projects, None) for d in dataset_subset] for project in project_subset: From 84775f4cdffdd497722021a5ea94017b1f37a3ad Mon Sep 17 00:00:00 2001 From: Jake Wagoner Date: Mon, 1 Jul 2024 12:22:00 -0600 Subject: [PATCH 3/7] Tox format --- swcc/tests/test_download_upload.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/swcc/tests/test_download_upload.py b/swcc/tests/test_download_upload.py index 466b3d32..17ec0c97 100644 --- a/swcc/tests/test_download_upload.py +++ b/swcc/tests/test_download_upload.py @@ -51,12 +51,7 @@ def public_server_download(download_dir): with swcc_session() as public_server_session: public_server_session.login('testuser@noemail.nil', 'cicdtest') all_datasets = list(models.Dataset.list()) - dataset_subset = [ - d - for d in all_datasets - if 'CI/CD' - in d.keywords - ] + dataset_subset = [d for d in all_datasets if 'CI/CD' in d.keywords] project_subset = [next(d.projects, None) for d in dataset_subset] for project in project_subset: if project is not None: From 460002a1dafd6d58f400ed8f7bd127b79c01f4a3 Mon Sep 17 00:00:00 2001 From: Jake Wagoner Date: Mon, 1 Jul 2024 13:06:13 -0600 Subject: [PATCH 4/7] Set GH secrets to hide CI user information --- .github/workflows/download_upload_cycle.yml | 3 +++ dev/prod.celery.env.json | 2 +- swcc/tests/test_download_upload.py | 12 +++++++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/download_upload_cycle.yml b/.github/workflows/download_upload_cycle.yml index ae2703cf..a8c4bb38 100644 --- a/.github/workflows/download_upload_cycle.yml +++ b/.github/workflows/download_upload_cycle.yml @@ -35,6 +35,9 @@ jobs: resource: 'http://localhost:8000/api/docs/swagger/' - name: Run tox + env: + CICD_PUBLIC_USER: ${{ env.CICD_PUBLIC_USER }} + CICD_PUBLIC_PASSWORD: ${{ env.CICD_PUBLIC_PASSWORD }} run: tox -e download_upload_cycle working-directory: ./swcc diff --git a/dev/prod.celery.env.json b/dev/prod.celery.env.json index 4dc822cd..fa170136 100644 --- a/dev/prod.celery.env.json +++ b/dev/prod.celery.env.json @@ -7,7 +7,7 @@ "DJANGO_CORS_ORIGIN_REGEX_WHITELIST": "", "DJANGO_CORS_ORIGIN_WHITELIST": "https://www.shapeworks-cloud.org", "DJANGO_HOMEPAGE_REDIRECT_URL": "https://www.shapeworks-cloud.org", - "DJANGO_DEFAULT_FROM_EMAIL": "admin@app.shapeworks-cloud.org", + "DJANGO_DEFAULT_FROM_EMAIL": "admin@shapeworks-cloud.org", "DJANGO_STORAGE_BUCKET_NAME": "shapeworks-cloud-storage", "SSL_CERT_DIR": "/etc/ssl/certs" } diff --git a/swcc/tests/test_download_upload.py b/swcc/tests/test_download_upload.py index 17ec0c97..8c312b53 100644 --- a/swcc/tests/test_download_upload.py +++ b/swcc/tests/test_download_upload.py @@ -49,7 +49,17 @@ def is_same(dir1, dir2): def public_server_download(download_dir): with swcc_session() as public_server_session: - public_server_session.login('testuser@noemail.nil', 'cicdtest') + username = ( + os.environ['CICD_PUBLIC_USER'] + if 'CICD_PUBLIC_USER' in os.environ + else '' + ) + password = ( + os.environ['CICD_PUBLIC_PASSWORD'] + if 'CICD_PUBLIC_PASSWORD' in os.environ + else '' + ) + public_server_session.login(username, password) all_datasets = list(models.Dataset.list()) dataset_subset = [d for d in all_datasets if 'CI/CD' in d.keywords] project_subset = [next(d.projects, None) for d in dataset_subset] From 41ae93cb96e8bd409412a4835dc9624004390e34 Mon Sep 17 00:00:00 2001 From: Jake Wagoner Date: Mon, 1 Jul 2024 13:28:39 -0600 Subject: [PATCH 5/7] Pass env vars through tox into pytest --- swcc/tests/test_download_upload.py | 12 ++---------- swcc/tox.ini | 4 +++- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/swcc/tests/test_download_upload.py b/swcc/tests/test_download_upload.py index 8c312b53..6601aecf 100644 --- a/swcc/tests/test_download_upload.py +++ b/swcc/tests/test_download_upload.py @@ -49,16 +49,8 @@ def is_same(dir1, dir2): def public_server_download(download_dir): with swcc_session() as public_server_session: - username = ( - os.environ['CICD_PUBLIC_USER'] - if 'CICD_PUBLIC_USER' in os.environ - else '' - ) - password = ( - os.environ['CICD_PUBLIC_PASSWORD'] - if 'CICD_PUBLIC_PASSWORD' in os.environ - else '' - ) + username = os.getenv('CICD_PUBLIC_USERNAME', '') + password = os.getenv('CICD_PUBLIC_PASSWORD', '') public_server_session.login(username, password) all_datasets = list(models.Dataset.list()) dataset_subset = [d for d in all_datasets if 'CI/CD' in d.keywords] diff --git a/swcc/tox.ini b/swcc/tox.ini index 3431996f..0d36ea2b 100644 --- a/swcc/tox.ini +++ b/swcc/tox.ini @@ -47,6 +47,8 @@ passenv = DJANGO_BASE_URL DJANGO_SUPERUSER_EMAIL DJANGO_SUPERUSER_PASSWORD + CICD_PUBLIC_USER + CICD_PUBLIC_PASSWORD deps = pytest click @@ -66,7 +68,7 @@ deps = pytest-factoryboy pytest-mock commands = - pytest -k "cycle" {posargs} + pytest -k "cycle" -s {posargs} [testenv:py37] install_command = pip install --ignore-requires-python {opts} {packages} From 1cfac0258ef10e91051adfc7a8647f3e83b79f82 Mon Sep 17 00:00:00 2001 From: Jake Wagoner Date: Mon, 1 Jul 2024 13:40:22 -0600 Subject: [PATCH 6/7] pass env through tox --- swcc/tests/test_download_upload.py | 4 ++-- swcc/tox.ini | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/swcc/tests/test_download_upload.py b/swcc/tests/test_download_upload.py index 6601aecf..2c6c2f3a 100644 --- a/swcc/tests/test_download_upload.py +++ b/swcc/tests/test_download_upload.py @@ -49,8 +49,8 @@ def is_same(dir1, dir2): def public_server_download(download_dir): with swcc_session() as public_server_session: - username = os.getenv('CICD_PUBLIC_USERNAME', '') - password = os.getenv('CICD_PUBLIC_PASSWORD', '') + username = os.getenv('CICD_PUBLIC_USER') + password = os.getenv('CICD_PUBLIC_PASSWORD') public_server_session.login(username, password) all_datasets = list(models.Dataset.list()) dataset_subset = [d for d in all_datasets if 'CI/CD' in d.keywords] diff --git a/swcc/tox.ini b/swcc/tox.ini index 0d36ea2b..e368ac2e 100644 --- a/swcc/tox.ini +++ b/swcc/tox.ini @@ -47,8 +47,6 @@ passenv = DJANGO_BASE_URL DJANGO_SUPERUSER_EMAIL DJANGO_SUPERUSER_PASSWORD - CICD_PUBLIC_USER - CICD_PUBLIC_PASSWORD deps = pytest click @@ -62,13 +60,15 @@ passenv = DJANGO_BASE_URL DJANGO_SUPERUSER_EMAIL DJANGO_SUPERUSER_PASSWORD + CICD_PUBLIC_USER + CICD_PUBLIC_PASSWORD deps = pytest click pytest-factoryboy pytest-mock commands = - pytest -k "cycle" -s {posargs} + pytest -k "cycle" {posargs} [testenv:py37] install_command = pip install --ignore-requires-python {opts} {packages} From 4e3a89c4dd645b551807a37eec76af19ebc1fc54 Mon Sep 17 00:00:00 2001 From: Jake Wagoner Date: Mon, 1 Jul 2024 14:37:32 -0600 Subject: [PATCH 7/7] Move env in workflow to job context --- .github/workflows/download_upload_cycle.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/download_upload_cycle.yml b/.github/workflows/download_upload_cycle.yml index a8c4bb38..e078dd70 100644 --- a/.github/workflows/download_upload_cycle.yml +++ b/.github/workflows/download_upload_cycle.yml @@ -9,6 +9,8 @@ jobs: DJANGO_SUPERUSER_PASSWORD: django-password DJANGO_SUPERUSER_USERNAME: admin DJANGO_SUPERUSER_EMAIL: admin@noemail.com + CICD_PUBLIC_USER: ${{ secrets.CICD_PUBLIC_USER }} + CICD_PUBLIC_PASSWORD: ${{ secrets.CICD_PUBLIC_PASSWORD }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -35,9 +37,6 @@ jobs: resource: 'http://localhost:8000/api/docs/swagger/' - name: Run tox - env: - CICD_PUBLIC_USER: ${{ env.CICD_PUBLIC_USER }} - CICD_PUBLIC_PASSWORD: ${{ env.CICD_PUBLIC_PASSWORD }} run: tox -e download_upload_cycle working-directory: ./swcc