Skip to content

Commit 3502447

Browse files
authored
♻️ Maintenance/refactors servicelib (ITISFoundation#2516)
- adds extra aiohttp to separate dependencies exclusive to aiohttp-services - can install and test using minimal installation (e.g. for fastapi-based services) or w/ aiohttp extra (for aiohttp-based services)
1 parent 7382c4e commit 3502447

File tree

219 files changed

+1100
-738
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

219 files changed

+1100
-738
lines changed

.github/workflows/ci-testing-deploy.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,63 @@ jobs:
804804
name: codeclimate-${{ github.job }}-coverage
805805
path: codeclimate.${{ github.job }}_coverage.json
806806

807+
unit-test-service-library-aiohttp:
808+
timeout-minutes: 14 # if this timeout gets too small, then split the tests
809+
name: "[unit] service-library[aiohttp]"
810+
runs-on: ${{ matrix.os }}
811+
strategy:
812+
matrix:
813+
python: [3.8]
814+
os: [ubuntu-20.04]
815+
docker_buildx: [v0.5.1]
816+
docker_compose: [1.29.1]
817+
include:
818+
- docker_compose: 1.29.1
819+
docker_compose_sha: 8097769d32e34314125847333593c8edb0dfc4a5b350e4839bef8c2fe8d09de7
820+
fail-fast: false
821+
steps:
822+
- uses: actions/checkout@v2
823+
- name: setup docker buildx
824+
id: buildx
825+
uses: docker/setup-buildx-action@v1
826+
with:
827+
version: ${{ matrix.docker_buildx }}
828+
driver: docker
829+
- name: setup docker-compose
830+
run: sudo ./ci/github/helpers/setup_docker_compose.bash ${{ matrix.docker_compose }} ${{ matrix.docker_compose_sha }}
831+
- name: setup python environment
832+
uses: actions/setup-python@v2
833+
with:
834+
python-version: ${{ matrix.python }}
835+
- name: show system version
836+
run: ./ci/helpers/show_system_versions.bash
837+
- uses: actions/cache@v2
838+
name: getting cached data
839+
with:
840+
path: ~/.cache/pip
841+
key: ${{ runner.os }}-pip-service-library-${{ hashFiles('packages/service-library/requirements/ci[aiohttp].txt') }}
842+
restore-keys: |
843+
${{ runner.os }}-pip-service-library-
844+
${{ runner.os }}-pip-
845+
${{ runner.os }}-
846+
- name: install
847+
run: ./ci/github/unit-testing/service-library.bash install_aiohttp
848+
- name: test
849+
run: ./ci/github/unit-testing/service-library.bash test_aiohttp
850+
- uses: codecov/[email protected]
851+
with:
852+
flags: unittests #optional
853+
- name: prepare codeclimate coverage file
854+
run: |
855+
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-0.7.0-linux-amd64 > ./cc-test-reporter
856+
chmod +x ./cc-test-reporter && ./cc-test-reporter --version
857+
./cc-test-reporter format-coverage -t coverage.py -o codeclimate.${{ github.job }}_coverage.json coverage.xml
858+
- name: upload codeclimate coverage
859+
uses: actions/upload-artifact@v2
860+
with:
861+
name: codeclimate-${{ github.job }}-coverage
862+
path: codeclimate.${{ github.job }}_coverage.json
863+
807864
unit-test-settings-library:
808865
timeout-minutes: 14 # if this timeout gets too small, then split the tests
809866
name: "[unit] settings-library"

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ pylint: ## Runs python linter framework's wide
382382
-not -path "*sandbox*" \
383383
-not -path "*-sdk/python*" \
384384
-not -path "*generated_code*" \
385+
-not -path "*build*" \
385386
-not -path "*datcore.py" \
386387
-not -path "*web/server*"))"
387388
# See exit codes and command line https://pylint.readthedocs.io/en/latest/user_guide/run.html#exit-codes

ci/github/unit-testing/service-library.bash

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,20 @@ install() {
1111
pip list -v
1212
}
1313

14+
install_aiohttp() {
15+
bash ci/helpers/ensure_python_pip.bash
16+
pushd packages/service-library; pip3 install -r requirements/ci[aiohttp].txt; popd;
17+
pip list -v
18+
}
19+
1420
test() {
21+
pytest --cov=servicelib --durations=10 --cov-append \
22+
--color=yes --cov-report=term-missing --cov-report=xml --cov-config=.coveragerc \
23+
-v -m "not travis" --ignore=packages/service-library/tests/aiohttp \
24+
packages/service-library/tests
25+
}
26+
27+
test_aiohttp() {
1528
pytest --cov=servicelib --durations=10 --cov-append \
1629
--color=yes --cov-report=term-missing --cov-report=xml --cov-config=.coveragerc \
1730
-v -m "not travis" packages/service-library/tests

ci/helpers/requirements.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
celery==4.4.7
55
docker==4.3.1
66
pyjwt==1.7.1
7+
aiohttp==3.7.4.post0

ci/helpers/requirements.txt

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,39 @@
11
#
2-
# This file is autogenerated by pip-compile
2+
# This file is autogenerated by pip-compile with python 3.8
33
# To update, run:
44
#
5-
# pip-compile
5+
# pip-compile requirements.in
66
#
7+
aiohttp==3.7.4.post0
8+
# via -r requirements.in
79
amqp==2.6.1
810
# via kombu
11+
async-timeout==3.0.1
12+
# via aiohttp
13+
attrs==21.2.0
14+
# via aiohttp
915
billiard==3.6.3.0
1016
# via celery
1117
celery==4.4.7
1218
# via -r requirements.in
1319
certifi==2020.6.20
1420
# via requests
1521
chardet==3.0.4
16-
# via requests
22+
# via
23+
# aiohttp
24+
# requests
1725
docker==4.3.1
1826
# via -r requirements.in
1927
idna==2.10
20-
# via requests
21-
importlib-metadata==2.0.0
22-
# via kombu
28+
# via
29+
# requests
30+
# yarl
2331
kombu==4.6.11
2432
# via celery
33+
multidict==5.1.0
34+
# via
35+
# aiohttp
36+
# yarl
2537
pyjwt==1.7.1
2638
# via -r requirements.in
2739
pytz==2020.1
@@ -32,6 +44,8 @@ six==1.15.0
3244
# via
3345
# docker
3446
# websocket-client
47+
typing-extensions==3.10.0.2
48+
# via aiohttp
3549
urllib3==1.25.10
3650
# via requests
3751
vine==1.3.0
@@ -40,5 +54,5 @@ vine==1.3.0
4054
# celery
4155
websocket-client==0.57.0
4256
# via docker
43-
zipp==3.2.0
44-
# via importlib-metadata
57+
yarl==1.6.3
58+
# via aiohttp

docs/no-upstream-push.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ your local repository.
1919
$ git remote add upstream [email protected]:GITUSER/osparc-simcore.git
2020

2121
\path-to\osparc-simcore (master -> origin)
22-
$ git remote set-url upstream --push "You shall not push but use PR instead"
22+
$ git remote set-url upstream --push "You_shall_not_push_but_use_PR_instead"
2323

2424
\path-to\osparc-simcore (master -> origin)
2525
$ git remote -vv

packages/pytest-simcore/src/pytest_simcore/helpers/utils_assert.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from aiohttp import ClientResponse
88
from aiohttp.web import HTTPError, HTTPException, HTTPInternalServerError, HTTPNoContent
9-
from servicelib.rest_responses import unwrap_envelope
9+
from servicelib.aiohttp.rest_responses import unwrap_envelope
1010

1111

1212
async def assert_status(

packages/pytest-simcore/src/pytest_simcore/helpers/utils_tokens.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from sqlalchemy import JSON, String, cast
99
from sqlalchemy.sql import and_ # , or_, not_
1010

11-
from servicelib.aiopg_utils import DSN
11+
from servicelib.common_aiopg_utils import DSN
1212
from simcore_service_webserver.db_models import metadata, tokens, users
1313
from simcore_service_webserver.login.utils import get_random_string
1414

packages/service-library/Makefile

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,42 @@
33
#
44
include ../../scripts/common.Makefile
55

6-
7-
.PHONY: install-dev install-prod install-ci
8-
install-dev install-prod install-ci: _check_venv_active ## install app in development/production or CI mode
6+
help: ## overwrites and calls common help function
7+
$(MAKE) -f ../../scripts/common.Makefile $@
8+
@echo '🚨 BEWARE there are issues with brakets in names `make test[aiohttp]` will raise errors:'
9+
@echo '✅` `make "test[aiohttp]"` works as intended'
10+
@echo '👓 Please note: when INSTALLING, DEVELOPING and TESTING '
11+
@echo 'servicelib support for aiohttp extras is not included:'
12+
@echo '- `make install-dev`: without aiohttp extras'
13+
@echo '- `make "install-dev[aiohttp]"`: with aiohttp extras'
14+
15+
.PHONY: install-dev install-dev[aiohttp] install-ci install-ci[aiohttp]
16+
install-dev install-dev[aiohttp] install-ci install-ci[aiohttp]: _check_venv_active ## install app in development/production or CI mode
917
# installing in $(subst install-,,$@) mode
1018
pip-sync requirements/$(subst install-,,$@).txt
1119

1220

13-
.PHONY: tests
14-
tests: ## runs unit tests
15-
# running unit tests
21+
.PHONY: test-dev
22+
test-dev: ## runs unit tests in without aiohtto extras
23+
# running test-dev
24+
@pytest -vv --exitfirst --failed-first --durations=10 --pdb --ignore=tests/aiohttp $(CURDIR)/tests
25+
26+
.PHONY: test-dev[aiohttp]
27+
test-dev[aiohttp]: ## runs unit tests and aiohtto extras
28+
# running test-dev[aiohttp]
1629
@pytest -vv --exitfirst --failed-first --durations=10 --pdb $(CURDIR)/tests
30+
31+
.PHONY: tests
32+
tests: ## runs unit tests in without aiohtto extras
33+
# running tests
34+
@pytest -vv --color=yes --exitfirst --failed-first --durations=10 \
35+
--cov-config=../../.coveragerc --cov=servicelib --cov-report=term-missing \
36+
--pdb --ignore=tests/aiohttp $(CURDIR)/tests
37+
38+
.PHONY: tests[aiohttp]
39+
tests[aiohttp]: ## runs unit tests and aiohtto extras
40+
# running tests[aiohttp]
41+
@pytest -vv --color=yes --exitfirst --failed-first --durations=10 \
42+
--cov-config=../../.coveragerc --cov=servicelib --cov-report=term-missing \
43+
--pdb $(CURDIR)/tests
44+

packages/service-library/requirements/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
include ../../../requirements/base.Makefile
55

66
# Add here any extra explicit dependency: e.g. _migration.txt: _base.txt
7+
_aiohttp.in: _base.txt

0 commit comments

Comments
 (0)