-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added automatic tests and replaced pip with poetry
- Loading branch information
Jithin sasikumar
authored and
Jithin sasikumar
committed
Aug 28, 2022
1 parent
8d06542
commit 80e83bb
Showing
23 changed files
with
3,987 additions
and
951 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 |
---|---|---|
|
@@ -16,28 +16,23 @@ jobs: | |
uses: actions/checkout@v2 | ||
|
||
- name: Build, Push and Release the KWS app as Docker container to Heroku. | ||
uses: gonuit/[email protected] # GitHub action name (leave it as it is). | ||
uses: gonuit/[email protected] | ||
with: | ||
email: ${{ secrets.HEROKU_EMAIL }} | ||
|
||
heroku_api_key: ${{ secrets.HEROKU_API_KEY }} | ||
|
||
heroku_app_name: ${{ secrets.HEROKU_APP_NAME }} | ||
|
||
# (Optional, default: "./") | ||
# Dockerfile directory | ||
dockerfile_directory: ./ | ||
|
||
# (Optional, default: "Dockerfile") | ||
# Dockerfile name | ||
dockerfile_name: Dockerfile | ||
|
||
# (Optional, default: "") | ||
# Additional options of docker build command. | ||
docker_options: "--no-cache" | ||
|
||
# (Optional, default: "web") | ||
# Select the process type for which you want the docker container to be uploaded. | ||
# By default, this argument is set to "web". | ||
# For more information look at https://devcenter.heroku.com/articles/process-model | ||
process_type: web |
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 @@ | ||
name: Tests | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.8 | ||
|
||
- name: cache poetry install | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.local | ||
key: poetry-1.1.15-0 | ||
|
||
- uses: snok/install-poetry@v1 | ||
with: | ||
version: 1.1.15 | ||
virtualenvs-create: true | ||
virtualenvs-in-project: true | ||
|
||
- name: cache deps | ||
id: cache-deps | ||
uses: actions/cache@v2 | ||
with: | ||
path: .venv | ||
key: pydeps-${{ hashFiles('**/poetry.lock') }} | ||
|
||
- run: poetry install --no-interaction --no-root | ||
if: steps.cache-deps.outputs.cache-hit != 'true' | ||
|
||
- run: poetry install --no-interaction | ||
- run: sudo apt-get install -y libsndfile1 | ||
|
||
- name: Run tests | ||
run: poetry run pytest |
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 |
---|---|---|
@@ -1 +1,129 @@ | ||
__pycache__/ | ||
# 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/ | ||
pip-wheel-metadata/ | ||
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/ | ||
|
||
# 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 | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
.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 | ||
|
||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow | ||
__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/ |
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 |
---|---|---|
@@ -1,19 +1,49 @@ | ||
FROM python:3.8 | ||
|
||
RUN : \ | ||
&& apt-get update \ | ||
&& DEBIAN_FRONTEND=noninteractive apt-get install -y \ | ||
--no-install-recommends \ | ||
libsndfile1 \ | ||
libsndfile1-dev \ | ||
&& : | ||
|
||
COPY . /app | ||
|
||
WORKDIR /app | ||
|
||
RUN pip install -r requirements.txt | ||
|
||
EXPOSE $PORT | ||
|
||
CMD gunicorn --workers=4 --bind 0.0.0.0:$PORT app:app | ||
# Build base image | ||
FROM python:3.8-slim as python-base | ||
|
||
ENV PYTHONUNBUFFERED = 1 \ | ||
PYTHONDONTWRITEBYTECODE = 1 \ | ||
PIP_NO_CACHE_DIR = off \ | ||
PIP_DISABLE_PIP_VERSION_CHECK = on \ | ||
PIP_DEFAULT_TIMEOUT = 100 \ | ||
POETRY_VERSION = 1.1.15 \ | ||
POETRY_HOME = "/opt/poetry" \ | ||
POETRY_VIRTUALENVS_IN_PROJECT = true \ | ||
POETRY_NO_INTERACTION = 1 \ | ||
PYSETUP_PATH = "/opt/pysetup" \ | ||
VENV_PATH = "/opt/pysetup/.venv" | ||
|
||
ENV PATH = "$POETRY_HOME/bin:$VENV_PATH/bin:$PATH" | ||
|
||
|
||
# Build dev image | ||
FROM python-base as dev-base | ||
|
||
RUN : \ | ||
&& apt-get update \ | ||
&& DEBIAN_FRONTEND=noninteractive apt-get install -y \ | ||
--no-install-recommends \ | ||
curl \ | ||
build-essential \ | ||
libsndfile1 \ | ||
libsndfile1-dev | ||
|
||
RUN curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python | ||
|
||
ENV PATH="${PATH}:/root/.poetry/bin" | ||
|
||
COPY poetry.lock pyproject.toml ./ | ||
|
||
RUN poetry install | ||
|
||
|
||
#Build production image | ||
FROM python-base as production | ||
|
||
COPY --from=dev-base $PYSETUP_PATH $PYSETUP_PATH | ||
|
||
COPY . /app | ||
|
||
EXPOSE $PORT | ||
|
||
CMD gunicorn --workers=4 --bind 0.0.0.0:$PORT app:app |
Oops, something went wrong.