-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5f86299
commit 88fda5b
Showing
12 changed files
with
384 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict' | ||
|
||
module.exports = { | ||
extends: [ | ||
'@strv/commitlint-config', | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
## :memo: Changelog | ||
|
||
- [x] the first change | ||
- [x] the second change | ||
|
||
## :link: Links | ||
|
||
- [JIRA issue](link into issue) | ||
|
||
## :white_check_mark: Checklist | ||
|
||
- [ ] Lint and tests pass locally with my changes | ||
- [ ] I've added tests that prove my feature works or that my fix is effective | ||
- [ ] I've added necessary documentation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Lint commit messages | ||
|
||
on: [pull_request] | ||
|
||
jobs: | ||
commitlint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: Set up Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '16' | ||
- name: Install dependencies in project | ||
run: npm install | ||
# Run the commitlint action, considering its own dependencies and yours as well 🚀 | ||
# `github.workspace` is the path to your repository. | ||
- name: Run commitlint | ||
uses: wagoid/commitlint-github-action@v5 | ||
env: | ||
NODE_PATH: ${{ github.workspace }}/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
cover/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
.pybuilder/ | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
# For a library or package, you might want to ignore these files since the code is | ||
# intended to run in multiple environments; otherwise, check them in: | ||
# .python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
# having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
# install all needed dependencies. | ||
#Pipfile.lock | ||
|
||
# poetry | ||
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. | ||
# This is especially recommended for binary packages to ensure reproducibility, and is more | ||
# commonly ignored for libraries. | ||
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control | ||
#poetry.lock | ||
|
||
# pdm | ||
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. | ||
#pdm.lock | ||
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it | ||
# in version control. | ||
# https://pdm.fming.dev/#use-with-ide | ||
.pdm.toml | ||
|
||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm | ||
__pypackages__/ | ||
|
||
# Celery stuff | ||
celerybeat-schedule | ||
celerybeat.pid | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# pytype static type analyzer | ||
.pytype/ | ||
|
||
# Cython debug symbols | ||
cython_debug/ | ||
|
||
# PyCharm | ||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can | ||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore | ||
# and can be added to the global gitignore or merged into this file. For a more nuclear | ||
# option (not recommended) you can uncomment the following to ignore the entire idea folder. | ||
#.idea/ | ||
|
||
# MacOS | ||
# The .DS_Store file is used to store Finder information about folders. | ||
# It is suggested to ignore these files by git. | ||
*.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
FROM python:3.8.12-buster as python-base | ||
MAINTAINER STRV DS Department | ||
|
||
RUN apt-get --allow-releaseinfo-change update && apt-get install -y unixodbc-dev | ||
|
||
FROM python-base as venv-image | ||
|
||
RUN apt-get install -y build-essential g++ tk python-tk python3-tk tk-dev | ||
|
||
COPY requirements.txt . | ||
|
||
ENV VIRTUAL_ENV=/opt/venv | ||
RUN python3 -m venv $VIRTUAL_ENV | ||
ENV PATH="$VIRTUAL_ENV/bin:$PATH" | ||
|
||
RUN python3 -m pip install --upgrade pip | ||
RUN pip install -r requirements.txt | ||
|
||
FROM python-base AS app-image | ||
|
||
COPY --from=venv-image /opt/venv /opt/venv | ||
ENV PATH="/opt/venv/bin:$PATH" | ||
|
||
WORKDIR /usr/src/app | ||
|
||
RUN chown -R nobody /usr/src/app/ | ||
RUN usermod --home /tmp nobody | ||
|
||
USER nobody | ||
|
||
ENV PYTHONPATH=/usr/src/app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
__version__ = "0.0.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
from osman.example.fibonacci import fibonacci |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
def fibonacci(n: int) -> int: | ||
"""Return nth number from Fibonacci sequence.""" | ||
if not isinstance(n, int): | ||
raise TypeError(f"Type '{type(n)}' is not supported for 'n' argument") | ||
|
||
if n < 0: | ||
raise ValueError("Only positive integers are allowed for 'n'") | ||
|
||
if n == 0: | ||
return 0 | ||
|
||
if n in [1, 2]: | ||
return 1 | ||
|
||
return fibonacci(n - 1) + fibonacci(n - 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "strv-ds-opensearch-manager", | ||
"version": "1.0.0", | ||
"description": "STRV OpenSearch manager repository.", | ||
"author": "STRV DS Department <[email protected]>", | ||
"contributors": [ | ||
"Jaroslav Bezdek <[email protected]>" | ||
], | ||
"license": "ISC", | ||
"engines": { | ||
"node": "^16" | ||
}, | ||
"scripts": {}, | ||
"devDependencies": { | ||
"@commitlint/cli": "17.1.2", | ||
"@strv/commitlint-config": "2.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
attrs==22.1.0 | ||
certifi==2022.6.15.2 | ||
charset-normalizer==2.1.1 | ||
idna==3.4 | ||
iniconfig==1.1.1 | ||
opensearch-py==2.0.0 | ||
packaging==21.3 | ||
parameterized==0.8.1 | ||
pluggy==1.0.0 | ||
py==1.11.0 | ||
pyparsing==3.0.9 | ||
pytest==7.1.3 | ||
requests==2.28.1 | ||
tomli==2.0.1 | ||
urllib3==1.26.12 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
import re | ||
import io | ||
from setuptools import find_packages, setup | ||
|
||
with io.open("osman/__init__.py", encoding="utf_8_sig") as version_file: | ||
__version__ = ( | ||
re | ||
.search( | ||
r"""__version__\s*=\s*[\'"]([^\'"]*)[\'"]""", | ||
version_file.read() | ||
) | ||
.group(1) | ||
) | ||
|
||
with open("README.md", mode="r", encoding="utf-8") as fh: | ||
long_description = fh.read() | ||
|
||
setup( | ||
name="osman", | ||
version=__version__, | ||
author="STRV DS Department", | ||
author_email="[email protected]", | ||
description="STRV OpenSearch manager.", | ||
long_description_content_type="text/markdown", | ||
long_description=long_description, | ||
packages=find_packages( | ||
exclude=[ | ||
"tests", | ||
"scripts", | ||
".github", | ||
] | ||
), | ||
install_requires=[ | ||
"opensearch-py>=2.0.0", | ||
"parameterized>=0.8.1", | ||
"pytest>=7.1.3", | ||
], | ||
python_requires=">=3.8", | ||
include_package_data=True | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
import pytest | ||
from parameterized import parameterized | ||
from osman.example import fibonacci | ||
|
||
|
||
@parameterized.expand( | ||
[ | ||
('Fibonacci test for n = 0', 0, 0), | ||
('Fibonacci test for n = 1', 1, 1), | ||
('Fibonacci test for n = 2', 2, 1), | ||
('Fibonacci test for n = 10', 10, 55), | ||
] | ||
) | ||
def test_fibonacci_with_allowed_argument(_, n, expected): | ||
result = fibonacci(n) | ||
assert result == expected | ||
|
||
|
||
@parameterized.expand( | ||
[ | ||
('Fibonacci test for n = -1', -1), | ||
] | ||
) | ||
def test_fibonacci_with_wrong_argument(_, n): | ||
with pytest.raises(ValueError): | ||
_ = fibonacci(n) | ||
|
||
|
||
@parameterized.expand( | ||
[ | ||
('Fibonacci test for n as None', None), | ||
('Fibonacci test for n as str', '1'), | ||
('Fibonacci test for n as float', 1.5), | ||
] | ||
) | ||
def test_fibonacci_with_missing_argument(_, n): | ||
with pytest.raises(TypeError): | ||
_ = fibonacci(n) |