diff --git a/.sonarcloud.properties b/.sonarcloud.properties new file mode 100644 index 0000000..5140b43 --- /dev/null +++ b/.sonarcloud.properties @@ -0,0 +1,7 @@ +sonar.organization=sartography +sonar.projectKey=sartography_protocol-builder-mock +sonar.host.url=https://sonarcloud.io +sonar.exclusions=docs/**,config/**,instance/**,migrations/**,postgres/**,readme_images/**,schema/**,templates/** +sonar.sources=pb +sonar.test.inclusions=tests +sonar.python.coverage.reportPaths=coverage.xml diff --git a/.travis.yml b/.travis.yml index 3813a8e..385b5c6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,25 +1,36 @@ language: python +python: + - "3.7" + services: - postgresql - docker -python: - - "3.7" +addons: + chrome: stable + sonarcloud: + organization: "sartography" before_install: - - cp config/travis-testing.py config/testing.py - psql -c 'create database pb_test;' -U postgres install: - - pip install pipenv pytest + - pip install pipenv pytest coverage - export PATH=$PATH:$HOME/.local/bin; - - pipenv install - - pytest # <== This runs in Pipenv (a/k/a virtualenv) + - pipenv install --dev + +env: + global: + - TESTING=true + - SQLALCHEMY_DATABASE_URI="postgresql://postgres:@localhost:5432/crc_test" -# command to run tests script: - - pytest + - pipenv run coverage run -m pytest + - pipenv run coverage xml -i + +after_success: + - sonar-scanner deploy: provider: script diff --git a/Pipfile.lock b/Pipfile.lock index 923bcda..8eb6333 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -154,32 +154,37 @@ }, "gevent": { "hashes": [ - "sha256:0fd5fbdaf5de55c38c45584489f73f263fbb4e06dd22496e9ba75ff42f469437", - "sha256:12565278b65f958686199fe7d06e3c2aed5f0587be2e66e62e90b2df0a62a6c7", - "sha256:1f5407c045fcdcf16f3c1e032c09e868eab4e2971a13003cdc38944cfef4a661", - "sha256:261413e577a6c8ca41b9fdf5ab5370bd470e3b32e176ad18e786cc45175e3af4", - "sha256:2d36ea41da5347e165f8988718dca481f12711d62d999db953101516852d63fa", - "sha256:2fb496f3b4de6591a293a65d04a14b32881d9e4e424defaa7193769489bc7c6d", - "sha256:4070b229638ddba19850e9e648727462c0c8f0dc4277a753ae84faa7ac489712", - "sha256:4776da6ba4a784d80b6d9b6055929ebc2e09c1d2a5876f38b32c7d6435b59eb6", - "sha256:48ab796f200d2730fded2669ca52e36b68a57d114420ef36adf301bc3f593398", - "sha256:50af4b6a54d3b2b631a73c5c0100e2366e66c6d48ad9634f3c8fbdc0fa537964", - "sha256:53fdc591806b1ed3a747a8a27839f7c6ae229155aad309e265682f0f398eb488", - "sha256:68cc23bbf79f80f5313f94be0d5679c6862ce5bc45b34eb927472a327798f691", - "sha256:691e8f96b6357657eb6cd4d76affdac6e1648b3be69e3841b0dc331270c3835c", - "sha256:75fcbe5b50ba3b55a7a0683f58f02ece099714429e2120bfaa62f1d70d9dbfa5", - "sha256:7cb2bef61e59da4c4a6a3520b88ce8b7d5c3f1006657bc1355a693490a5d597a", - "sha256:9164c8d0c217cf1a290d549c51a06f1352cd2cc169dac36305f377169cd7828b", - "sha256:9d33866360dfd9457f509aa249746deba14f8790ca3544c0f1317fda773e3495", - "sha256:a498902a736382406d401d174df66ba99124b064d5e30db0e61e8bf2aeaf7bb1", - "sha256:ad47b503b590dd972f791f01539f8806af33dfe854cae1d577846f9689deeecd", - "sha256:db00eb55398844ff4a6dc78f4db80a7dd6acb5cdbd5a0de0d6acaddc52e9c82f", - "sha256:edc4c7213f9c4ee88ad5d03a8f24f3d80b4decd09129f4d1eb660d3068906a69", - "sha256:efdb51bcde9d604ab76d11e08c1adc62a5e87944b5435dcfad030d4cbbfe9a0f", - "sha256:f1dc96268bc3357cfb1d490eaf322c29a3649e63b672b718658e1797bd38cd64" + "sha256:0b16dd85eddaf6acdad373ce90ed4da09ef466cbc5e0ee5932d13f099929e844", + "sha256:0f3fbb1703b10609856e5dffb0e358bf5edf57e52dc7cd7226e3f8674fdc0a0f", + "sha256:13c74d6784ef5ada2666abf2bb310d27a1d14291f7cac46148f336b19f714d40", + "sha256:1ea0d34cb78cdf37870be3bfb9330ebda89197bed9e048c14f4a90dec19a33e0", + "sha256:354f932c284fa45826b32f42927d892096cce05671b50b3ff59528230217ad47", + "sha256:3cb2f6978615d52e4e4e667b035c11a7272bb68b14d119faf1b138164b2f354f", + "sha256:67776cb33b638a3c61a0351d9d1e8f33a46b47de619e249de1159892f9ff035c", + "sha256:68764aca061bbbbade43727e797f9c28042f6d90cca5fb6514ef726d43ab00ca", + "sha256:6c864b5604166ac8351e3128a1135b883b9e978fd24afbd75a249dcb42bc8ab5", + "sha256:73eb4cf3114fbb5dd801bd0b93941adfa2fa6d99e91976c20a121ea14b8b39b9", + "sha256:76ef4c6e3332e6f7278142d791b28695adfce39735900fccef2a0f1d894f6b36", + "sha256:78bd94f6f2ac366155169df3507068f6381f2ad77625633189ce183f86a57597", + "sha256:7d8408854ce892f987305a0e9bf5c051f4ea29453665454396d6afb620c719b6", + "sha256:9527087984f1659be899b3300d5d61c7c5b01d8beae106aff5160316da8bc56f", + "sha256:a18d8dd9bfa994a22f30adfa0563d80f0809140045c34f85535f422813d25855", + "sha256:a23c2abf08e851c988723f6a2996d495f513a2c0dc70f9956af03af8debdb5d1", + "sha256:a47556cac07e31b3cef8fd701599b3b1365961fe3736471f41807ffa27c5c848", + "sha256:b03890bbddbae5667f5baad517417056496ff5e92c3c7945b27cc08f55a9fcb2", + "sha256:b17915b65b49a425115ddc3087484c81b1e47ce38c931d18bb14e453753e4d06", + "sha256:bef18b8bd3b728240b9bbd699737216b793d6c97b482431f69dcbe328ad73692", + "sha256:c0f4340e40e0f9dfe93a52a12ddf5b1eeda9bbc89b99bf3b9b23acab0dfae0a4", + "sha256:d0a67a20ce325f6a2068e0bd9fbf83db8a5f5ced972ed8ac5c20079a7d98c7d1", + "sha256:d3baff87d935a5eeffb0e4f7cd5ffe258d2430cd62aeee2e5396f85da07df435", + "sha256:e5ca5ee80a9d9e697c9fc22b4bbce9ad06870f83fc8e7774e5504892ef702476", + "sha256:ea2e4584950186b71d648bde6af40dae4d4c6f43db25a732ec056b27a7a83afe", + "sha256:ebb8a545112110e3a6edf905ae1556b0538fc148c743aa7d8cfaebbbc23de31d", + "sha256:f2a02d9004ccb18edd9eaf6f25da9a7763de41a69754d5e4d872a8cbf8bd0b72", + "sha256:f41cc8e853ac2252bc58f6feabd74b8aae613e2d19097c5373463122f4dc08f0" ], "index": "pypi", - "version": "==20.6.1" + "version": "==20.6.2" }, "greenlet": { "hashes": [ diff --git a/config/testing.py b/config/testing.py index 656978c..6681d9b 100644 --- a/config/testing.py +++ b/config/testing.py @@ -1,9 +1,16 @@ +import re import os +from os import environ + basedir = os.path.abspath(os.path.dirname(__file__)) NAME = "CR Connect Protocol Builder Mock" -CORS_ENABLED = False +CORS_ALLOW_ORIGINS = re.split(r',\s*', environ.get('CORS_ALLOW_ORIGINS', default="localhost:5000")) DEVELOPMENT = True TESTING = True -SQLALCHEMY_DATABASE_URI = 'sqlite:///app.db' +SQLALCHEMY_DATABASE_URI = environ.get('SQLALCHEMY_DATABASE_URI', default="sqlite:///app.db") SECRET_KEY = 'a really really really really long secret key' + +print('### USING TESTING CONFIG: ###') +print('SQLALCHEMY_DATABASE_URI = ', SQLALCHEMY_DATABASE_URI) +print('TESTING = ', TESTING) diff --git a/config/travis-testing.py b/config/travis-testing.py deleted file mode 100644 index b1f4f8c..0000000 --- a/config/travis-testing.py +++ /dev/null @@ -1,14 +0,0 @@ -import os -basedir = os.path.abspath(os.path.dirname(__file__)) - -NAME = "CR Connect Protocol Builder Mock" -CORS_ENABLED = False -DEVELOPMENT = True -TESTING = True -SQLALCHEMY_DATABASE_URI = "postgresql://postgres:@localhost:5432/pb_test" -SECRET_KEY = 'a really really really really long secret key' - -print('+++ USING TRAVIS TESTING CONFIG: +++') -print('SQLALCHEMY_DATABASE_URI = ', SQLALCHEMY_DATABASE_URI) -print('DEVELOPMENT = ', DEVELOPMENT) -print('TESTING = ', TESTING)