Commit 696c0c88 authored by Viacheslav Sukhovieiev's avatar Viacheslav Sukhovieiev
Browse files

feat: ci implementation

parent 95c22494
Pipeline #22559 failed with stages
in 8 seconds
[flake8]
max-line-length = 120
ignore = D, VNE, E126, E123, E121, W504, W503
\ No newline at end of file
......@@ -81,6 +81,7 @@ htmlcov/
.tox/
.coverage
.coverage.*
cover-html
.cache
nosetests.xml
coverage.xml
......
include:
- project: 'prozorro-sale/ci-build-box'
file: '/template-ci.yml'
stages:
- lint
- build
- test
- publish
code-style-check:
extends: .lint-template
build-wheel:
extends: .build-wheel-template
test-unit-pytest:
stage: test
script:
- make test-unit-pytest
artifacts:
paths:
- .coverage
publish-wheel:
extends: .publish-wheel-template
publish-coverage-report:
extends: .publish-coverage-report-template
\ No newline at end of file
# Some simple testing tasks (sorry, UNIX only).
CI_COMMIT_REF_NAME ?= ''
cov:
@py.test --cov=aiohttp_swagger --cov-report=term --cov-report=html tests
ifeq ($(CI_COMMIT_REF_NAME), master)
EGG_INFO = egg_info --tag-date
else ifeq ($(shell echo ${CI_COMMIT_REF_NAME} | grep -o "^epic/"), epic/)
EGG_INFO = egg_info --tag-date --tag-build=DEV
else
EGG_INFO =
endif
clean:
@rm -rf `find . -name __pycache__`
......@@ -23,3 +29,24 @@ clean:
install:
@pip install -U pip
@pip install -Ur requirements-dev.txt
## Run pytest
test-unit-pytest:
@pip install -r requirements.txt -r requirements-dev.txt
@pytest -v \
-W ignore::DeprecationWarning \
--doctest-modules \
--cov=. \
-o testpaths="tests" \
## Build python package
build-wheel:
@python3 setup.py $(EGG_INFO) sdist bdist_wheel
## Publish python package
publish-wheel:
twine upload --skip-existing dist/*
## Publish coverage report
publish-coverage:
coverage report && coverage html -d cover-html
......@@ -96,9 +96,9 @@ async def setup_swagger(app: web.Application,
with open(join(STATIC_PATH, "index.html"), "r") as f:
app["SWAGGER_TEMPLATE_CONTENT"] = (
f.read()
.replace("##SWAGGER_CONFIG##", f"{api_base_url.rstrip('/')}{_swagger_def_url}")
.replace("##STATIC_PATH##", f"{api_base_url.rstrip('/')}{statics_path}")
.replace("##SWAGGER_VALIDATOR_URL##", swagger_validator_url)
.replace("##SWAGGER_CONFIG##", f"{api_base_url.rstrip('/')}{_swagger_def_url}")
.replace("##STATIC_PATH##", f"{api_base_url.rstrip('/')}{statics_path}")
.replace("##SWAGGER_VALIDATOR_URL##", swagger_validator_url)
)
......
......@@ -86,7 +86,8 @@ async def generate_doc_from_each_end_point(
contact: str = "",
template_path: str = None,
definitions: dict = None,
security_definitions: dict = None):
security_definitions: dict = None
):
# Clean description
_start_desc = 0
for i, word in enumerate(description):
......
......@@ -5,7 +5,7 @@ import pytest
import yaml
from aiohttp import web
from aiohttp_swagger import *
from aiohttp_swagger import setup_swagger, swagger_path
async def ping(request):
......@@ -218,6 +218,7 @@ async def test_swagger_info(aiohttp_client, loop, swagger_info):
await setup_swagger(app,
ui_version=3,
swagger_url="/api/v1/doc",
description=description,
swagger_info=swagger_info)
client = await aiohttp_client(app)
......
......@@ -241,6 +241,7 @@ async def test_swagger_info(aiohttp_client, loop, swagger_info):
description = "Test Custom Swagger"
await setup_swagger(app,
swagger_url="/api/v1/doc",
description=description,
swagger_info=swagger_info)
client = await aiohttp_client(app)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment