Skip to content

Commit

Permalink
Merge pull request #612 from sartography/dev
Browse files Browse the repository at this point in the history
Merge dev into testing
  • Loading branch information
cullerton authored Sep 5, 2024
2 parents fff6324 + 4a918c9 commit caadc09
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 25 deletions.
98 changes: 98 additions & 0 deletions .github/workflows/build-test-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: build_test_image

on:
push:
branches: ['testing']
workflow_dispatch:


env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
TESTING: true
PB_ENABLED: false
SQLALCHEMY_DATABASE_URI: "postgresql://postgres:postgres@localhost:5432/crc_test"
PGPASSWORD: postgres

jobs:
sonarcloud:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0
- name: SonarCloud Scan
uses: sonarsource/sonarcloud-github-action@master
with:
args: >
-Dsonar.organization=sartography
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

run_tests:
runs-on: ubuntu-latest
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- name: Checkout repository
uses: actions/checkout@v2
- uses: browser-actions/setup-chrome@latest
with:
chrome-version: stable
- uses: actions/setup-python@v3
with:
python-version: '3.9'
architecture: 'x64'
- run: psql -h localhost -c 'create database crc_test;' -U postgres
- run: pip install pipenv
- run: pipenv install --dev
- run: pipenv run coverage run -m pytest
- run: pipenv run coverage xml -i

build-and-push-image:
needs:
- run_tests
- sonarcloud
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/testing'
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
10 changes: 8 additions & 2 deletions config/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'disable_existing_loggers': False,
"loggers": {
'': { # root logger
'handlers': ['console'],
'handlers': ['console', 'file'],
'level': 'INFO',
'propagate': True
},
Expand Down Expand Up @@ -36,7 +36,7 @@
"root": {
"level": "INFO",
"handlers": [
"console",
"console", "file"
]
},
"handlers": {
Expand All @@ -45,6 +45,12 @@
"class": "logging.StreamHandler",
"stream": "ext://sys.stdout",
"level": "INFO"
},
"file": {
"level": "INFO",
"formatter": "simple",
"class": "logging.FileHandler",
"filename": "cr_connect.log"
}
}
}
1 change: 1 addition & 0 deletions crc/services/study_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ def update_study_associate(study_id=None, uid=None, role="", send_email=False, a
if uid is None:
raise ApiError('uid not specified', "This function requires a uva uid parameter")

uid = uid.lower()
if not LdapService.user_exists(uid):
raise ApiError('trying_to_grant_access_to_user_not_found_in_ldap', "You are trying to grant access to "
"%s but they were not found in ldap "
Expand Down
45 changes: 22 additions & 23 deletions crc/services/workflow_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,31 +139,30 @@ def get_workflow_url(workflow):
return workflow_url

def process_erroring_workflows(self):
with app.app_context():
workflows = self.get_erroring_workflows()
if len(workflows) > 0:
workflow_urls = []
if len(workflows) == 1:
workflow = workflows[0]
workflows = self.get_erroring_workflows()
if len(workflows) > 0:
workflow_urls = []
if len(workflows) == 1:
workflow = workflows[0]
workflow_url_link = self.get_workflow_url(workflow)
workflow_urls.append(workflow_url_link)
message = 'There is one workflow in an error state.'
message += f'\n You can restart the workflow at {workflow_url_link}.'
else:
message = f'There are {len(workflows)} workflows in an error state.'
message += '\nYou can restart the workflows at these URLs:'
for workflow in workflows:
workflow_url_link = self.get_workflow_url(workflow)
workflow_urls.append(workflow_url_link)
message = 'There is one workflow in an error state.'
message += f'\n You can restart the workflow at {workflow_url_link}.'
else:
message = f'There are {len(workflows)} workflows in an error state.'
message += '\nYou can restart the workflows at these URLs:'
for workflow in workflows:
workflow_url_link = self.get_workflow_url(workflow)
workflow_urls.append(workflow_url_link)
message += f'\n{workflow_url_link}'

with push_scope() as scope:
scope.user = {"urls": workflow_urls}
scope.set_extra("workflow_urls", workflow_urls)
# this sends a message through sentry
capture_message(message)
# We return message so we can use it in a test
return message
message += f'\n{workflow_url_link}'

with push_scope() as scope:
scope.user = {"urls": workflow_urls}
scope.set_extra("workflow_urls", workflow_urls)
# this sends a message through sentry
capture_message(message)
# We return message so we can use it in a test
return message

@staticmethod
def test_spec(spec_id, validate_study_id=None, test_until=None, required_only=False):
Expand Down
2 changes: 2 additions & 0 deletions example_data.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# example data for testing

import glob
import os

Expand Down

0 comments on commit caadc09

Please sign in to comment.