Skip to content

Commit c0cc3b5

Browse files
authored
Is1884/service integration library (#1963)
- Creating a service integration library in osparc to simplify submission and integration of services in the platform. This library includes now most the functionality currently in the cookiecutter-osparc-service regarding: * tooling ( e.g. inject metadata in images, ) * testing fixtures/assert helpers * versioning * Taks tools from https://github.com/ITISFoundation/cookiecutter-osparc-service * reqs * renames as service-integration * Adds requirements and installsy with pip-sync * Updates template settings with new lib * Created a CL and moved all tools as CLI subcommands * Fixes click options and func arguments mapping * Fixes in tooling and updated doc * Adding submodule as a pytest-plugin with fixtures and assert helpers * Removes unused models-library regex and add full-coverage tests on remaining * Adds model-lib dependency * Adds dumping-version * Updates test reqs * Removed __main__ by cli and introduced meta submodule * Adds association for CWL files in settings.py * Fixes fixture * Add tests script * Adds extra tests on metadata * Fixing coverage and loads * Removed faulty pytest config fiel * Added tests on meta * Fixing metadata script * Splits tests and passes * adds unit-tests in actions and added owners * updates doc * Adds new CLI command to retrieve current versions in metadata * excludes pytest plugins fromcodeclimate * Removes space created by version bump * Fixes regex to capture reqs w extras e.g. foo[all] in ALL setup.py * Upgrades reqs and adds docs * Changes based on review @GitHK * Saving yaml keeps order
1 parent 341a1e5 commit c0cc3b5

Some content is hidden

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

59 files changed

+2107
-147
lines changed

.codeclimate.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,5 @@ exclude_patterns:
7878
- "**/migrations/"
7979
- "**/*.js"
8080
- "**/pytest-simcore/"
81+
- "**/pytest_plugin/"
8182
- "**/sandbox/"

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Makefile @pcrespov, @sanderegg
1515
/packages/pytest-simcore/ @pcrespov, @sanderegg
1616
/packages/models-library/ @sanderegg, @pcrespov
1717
/packages/service-library/ @pcrespov
18+
/packages/service-integration/ @pcrespov, @sanderegg, @KZzizzle
1819
/requirements/ @pcrespov
1920
/scripts/demo/ @odeimaiz, @pcrespov
2021
/scripts/json-schema-to-openapi-schema @sanderegg

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

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,56 @@ jobs:
440440
name: unit_postgresdb_coverage
441441
path: codeclimate.unit_postgresdb_coverage.json
442442

443+
unit-test-service-integration:
444+
name: "[unit] service-integration"
445+
runs-on: ${{ matrix.os }}
446+
strategy:
447+
matrix:
448+
python: [3.6]
449+
os: [ubuntu-20.04]
450+
fail-fast: false
451+
steps:
452+
- uses: actions/checkout@v2
453+
- name: setup docker
454+
run: |
455+
sudo ./ci/github/helpers/setup_docker_compose.bash
456+
./ci/github/helpers/setup_docker_experimental.bash
457+
./ci/github/helpers/setup_docker_buildx.bash
458+
echo "DOCKER_BUILDX=1" >> $GITHUB_ENV
459+
- name: setup python environment
460+
uses: actions/setup-python@v2
461+
with:
462+
python-version: ${{ matrix.python }}
463+
- name: show system version
464+
run: ./ci/helpers/show_system_versions.bash
465+
- uses: actions/cache@v2
466+
name: getting cached data
467+
with:
468+
path: ~/.cache/pip
469+
key: ${{ runner.os }}-pip-service-integration-${{ hashFiles('packages/service-integration/requirements/ci.txt') }}
470+
restore-keys: |
471+
${{ runner.os }}-pip-service-integration-
472+
${{ runner.os }}-pip-
473+
${{ runner.os }}-
474+
- name: install
475+
run: ./ci/github/unit-testing/service-integration.bash install
476+
- name: test
477+
run: ./ci/github/unit-testing/service-integration.bash test
478+
- uses: codecov/codecov-action@v1
479+
with:
480+
flags: unittests #optional
481+
- name: prepare codeclimate coverage file
482+
run: |
483+
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
484+
chmod +x ./cc-test-reporter
485+
./cc-test-reporter format-coverage -t coverage.py -o codeclimate.unit_service_integration_coverage.json coverage.xml
486+
- name: upload codeclimate coverage
487+
uses: actions/upload-artifact@v2
488+
with:
489+
name: unit_service_integration_coverage
490+
path: codeclimate.unit_service_integration_coverage.json
491+
492+
443493
unit-test-service-library:
444494
name: "[unit] service-library"
445495
runs-on: ${{ matrix.os }}
@@ -1306,6 +1356,7 @@ jobs:
13061356
unit-test-director,
13071357
unit-test-director-v2,
13081358
unit-test-sidecar,
1359+
unit-test-service-integration,
13091360
unit-test-service-library,
13101361
unit-test-models-library,
13111362
unit-test-simcore-sdk,
@@ -1338,6 +1389,9 @@ jobs:
13381389
- uses: actions/download-artifact@v1
13391390
with:
13401391
name: unit_sidecar_coverage
1392+
- uses: actions/download-artifact@v1
1393+
with:
1394+
name: unit_service_integration_coverage
13411395
- uses: actions/download-artifact@v1
13421396
with:
13431397
name: unit_servicelib_coverage
@@ -1383,6 +1437,7 @@ jobs:
13831437
unit_director_coverage/*.json \
13841438
unit_director_v2_coverage/*.json \
13851439
unit_sidecar_coverage/*.json \
1440+
unit_service_integration_coverage/*.json \
13861441
unit_servicelib_coverage/*.json \
13871442
unit_modelslib_coverage/*.json \
13881443
unit_simcoresdk_coverage/*.json \
@@ -1418,6 +1473,7 @@ jobs:
14181473
unit-test-sidecar,
14191474
unit-test-frontend,
14201475
unit-test-python-linting,
1476+
unit-test-service-integration,
14211477
unit-test-service-library,
14221478
unit-test-models-library,
14231479
unit-test-simcore-sdk,
@@ -1430,7 +1486,7 @@ jobs:
14301486
integration-test-director-v2,
14311487
integration-test-sidecar,
14321488
integration-test-simcore-sdk,
1433-
system-test-swarm-deploy,
1489+
system-test-swarm-deploy,
14341490
]
14351491
runs-on: ubuntu-latest
14361492
steps:

.vscode/settings.template.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"Dockerfile*": "dockerfile",
1111
"**/requirements/*.txt": "pip-requirements",
1212
"**/requirements/*.in": "pip-requirements",
13-
"*Makefile": "makefile"
13+
"*Makefile": "makefile",
14+
"*.cwl": "yaml"
1415
},
1516
"files.eol": "\n",
1617
"files.exclude": {
@@ -27,15 +28,18 @@
2728
"./packages/postgres-database/src",
2829
"./packages/pytest-simcore/src",
2930
"./packages/s3wrapper/src",
31+
"./packages/service-integration/src",
3032
"./packages/service-library/src",
3133
"./packages/simcore-sdk/src",
3234
"./services/api-server/src",
35+
"./services/api-server/tests/unit",
3336
"./services/catalog/src",
3437
"./services/director/src",
3538
"./services/director-v2/src",
3639
"./services/sidecar/src",
3740
"./services/storage/src",
38-
"./services/web/server/src"
41+
"./services/web/server/src",
42+
"./services/web/server/tests/unit/with_dbs/slow"
3943
],
4044
"python.linting.pylintEnabled": true,
4145
"python.linting.enabled": true,
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
3+
set -euo pipefail
4+
IFS=$'\n\t'
5+
6+
install() {
7+
bash ci/helpers/ensure_python_pip.bash
8+
pushd packages/service-integration
9+
pip3 install -r requirements/ci.txt
10+
popd
11+
pip list -v
12+
}
13+
14+
test() {
15+
pytest --cov=service_integration --durations=10 --cov-append \
16+
--color=yes --cov-report=term-missing --cov-report=xml --cov-config=.coveragerc \
17+
-v -m "not travis" packages/service-integration/tests
18+
}
19+
20+
# Check if the function exists (bash specific)
21+
if declare -f "$1" >/dev/null; then
22+
# call arguments verbatim
23+
"$@"
24+
else
25+
# Show a helpful error
26+
echo "'$1' is not a known function name" >&2
27+
exit 1
28+
fi

packages/models-library/setup.cfg

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,3 @@ universal = 1
1717
[aliases]
1818
# Define setup.py command aliases here
1919
test = pytest
20-
21-
[tool:pytest]
22-
collect_ignore = ['setup.py']

packages/models-library/setup.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88

99

1010
def read_reqs(reqs_path: Path):
11-
return re.findall(r"(^[^#-][\w]+[-~>=<.\w]+)", reqs_path.read_text(), re.MULTILINE)
11+
return re.findall(
12+
r"(^[^#\n-][\w\[,\]]+[-~>=<.\w]*)", reqs_path.read_text(), re.MULTILINE
13+
)
1214

1315

1416
install_requirements = read_reqs(
Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
""" Regular expressions patterns to build pydantic contrained strings
22
33
- Variants of the patterns with 'Named Groups' captured are suffixed with NG_RE
4+
5+
SEE tests_basic_regex.py for examples
46
"""
57
# TODO: for every pattern we should have a formatter function
68
# NOTE: some sites to manualy check ideas
@@ -9,49 +11,11 @@
911
#
1012

1113
# Universally unique Identifier. Pattern taken from https://stackoverflow.com/questions/136505/searching-for-uuids-in-text-with-regex
14+
1215
UUID_RE = r"\b[0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12}\b"
1316

1417
# Formatted timestamps with date and time
1518
DATE_RE = r"\d{4}-(12|11|10|0?[1-9])-(31|30|[0-2]?\d)T(2[0-3]|1\d|0?[0-9])(:(\d|[0-5]\d)){2}(\.\d{3})?Z"
1619

1720

18-
## VERSIONS --------------------------------------------------------------------------------------------------
19-
2021
VERSION_RE = r"^(0|[1-9]\d*)(\.(0|[1-9]\d*)){2}(-(0|[1-9]\d*|\d*[-a-zA-Z][-\da-zA-Z]*)(\.(0|[1-9]\d*|\d*[-a-zA-Z][-\da-zA-Z]*))*)?(\+[-\da-zA-Z]+(\.[-\da-zA-Z-]+)*)?$"
21-
22-
# Semantic version regex (https://semver.org/)
23-
SEMANTIC_VERSION_RE = r"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"
24-
SEMANTIC_VERSION_NG_RE = r"^(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"
25-
26-
# PEP 440 -- Version Identification and Dependency Specification (https://www.python.org/dev/peps/pep-0440)
27-
PEP404_VERSION_RE = r"^([1-9][0-9]*!)?(0|[1-9][0-9]*)(\.(0|[1-9][0-9]*))*((a|b|rc)(0|[1-9][0-9]*))?(\.post(0|[1-9][0-9]*))?(\.dev(0|[1-9][0-9]*))?$"
28-
PEP440_VERSION_NG_RE = r"""
29-
v?
30-
(?:
31-
(?:(?P<epoch>[0-9]+)!)? # epoch
32-
(?P<release>[0-9]+(?:\.[0-9]+)*) # release segment
33-
(?P<pre> # pre-release
34-
[-_\.]?
35-
(?P<pre_l>(a|b|c|rc|alpha|beta|pre|preview))
36-
[-_\.]?
37-
(?P<pre_n>[0-9]+)?
38-
)?
39-
(?P<post> # post release
40-
(?:-(?P<post_n1>[0-9]+))
41-
|
42-
(?:
43-
[-_\.]?
44-
(?P<post_l>post|rev|r)
45-
[-_\.]?
46-
(?P<post_n2>[0-9]+)?
47-
)
48-
)?
49-
(?P<dev> # dev release
50-
[-_\.]?
51-
(?P<dev_l>dev)
52-
[-_\.]?
53-
(?P<dev_n>[0-9]+)?
54-
)?
55-
)
56-
(?:\+(?P<local>[a-z0-9]+(?:[-_\.][a-z0-9]+)*))? # local version
57-
""".strip()

0 commit comments

Comments
 (0)