Skip to content

Commit

Permalink
Alpha -> Dev (#90)
Browse files Browse the repository at this point in the history
* Dev -> Alpha (#89)

* temporary removed branch constraint

* make unit_tests.yml directly callable from deploy_containers.yml

* added passing secrets when performing workflow call

* reformat README.md

* clean up

* Fixed issue with missing import

* Split requirements to install per service

* Fixed path issue

* Fixed issue with building base image

* troubleshooting path issue

* enable websockets for klat observer

* Added bump version to the main deployment workflow

* Incremented Version

* incrementing supported versions of imported workflows

* Incremented Version
  • Loading branch information
NeonKirill authored Apr 15, 2024
1 parent 42fd083 commit f49166d
Show file tree
Hide file tree
Showing 20 changed files with 199 additions and 90 deletions.
20 changes: 14 additions & 6 deletions .github/workflows/deploy_containers.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
name: Deploy Images to GHCR

on:
workflow_run:
workflows: ["Run Unit Tests"]
branches: [alpha, dev, master]
types: [completed]
push:
branches:
- alpha
- dev
- master
workflow_dispatch:
inputs:
version:
Expand All @@ -18,11 +19,18 @@ permissions:
packages: write

jobs:
run-tests:
uses: ./.github/workflows/unit_tests.yml
secrets:
PYKLATCHAT_TESTING_CREDENTIALS_V2: ${{ secrets.PYKLATCHAT_TESTING_CREDENTIALS_V2 }}
SERVER_ENV: ${{ secrets.SERVER_ENV }}
bump-version:
uses: ./.github/workflows/publish_version_change.yml
publish-images:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
needs: [run-tests, bump-version]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Install Node JS
run: |
sudo apt-get update && sudo apt-get install nodejs && sudo apt-get install npm
Expand Down
39 changes: 0 additions & 39 deletions .github/workflows/publish_test_build.yml

This file was deleted.

28 changes: 28 additions & 0 deletions .github/workflows/publish_version_change.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This workflow will generate a distribution and upload it to PyPI

name: Publish Version Change
on:
workflow_call:

jobs:
build_and_publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }}
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install Build Tools
run: |
python -m pip install build wheel
- name: Increment Version
run: |
VER=$(python setup.py --version)
python version_bump.py -b ${{ github.ref_name }}
- name: Push Version Change
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Incremented Version
23 changes: 17 additions & 6 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
name: Run Unit Tests
on:
push:
pull_request:
types: [opened, synchronize, reopened, edited, ready_for_review]
workflow_dispatch:
workflow_call:
secrets:
PYKLATCHAT_TESTING_CREDENTIALS_V2:
description: 'testing data'
required: true
SERVER_ENV:
description: 'running environment'
required: true

jobs:
unit_tests:
Expand All @@ -14,7 +23,9 @@ jobs:
PYKLATCHAT_TESTING_CREDENTIALS: ${{ secrets.PYKLATCHAT_TESTING_CREDENTIALS_V2 }}
KLAT_ENV: ${{ secrets.SERVER_ENV }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: echo Testing Creds
run: echo $PYKLATCHAT_TESTING_CREDENTIALS
- name: Set up python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
Expand All @@ -33,24 +44,24 @@ jobs:
run: |
pytest tests/test_db_utils.py --doctest-modules --junitxml=tests/db-utils-test-results.xml
- name: Upload DB Utils test results
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: db-utils-test-results
path: tests/db-utils-test-results.xml
- name: Test SIO
run: |
pytest chat_server/tests/test_sio.py --doctest-modules --junitxml=tests/sio-test-results.xml
- name: Upload SIO test results
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: sio-test-results
path: tests/sio-test-results.xml
build_tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v1
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install Build Tools
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,46 +11,46 @@ An actual description of proposed solution can be found [under this link](https:
Any configuration properties should be grouped by runtime environment which is set via environment variable "<b>KLAT_ENV</b>"


### Database
## Database

For database configuration location is managed via environment variable "<b>DATABASE_CONFIG</b>".

Note: database configuration can be merged inside other configurations (e.g. chat server configuration file)
the only strong requirement is a key header "<b>DATABASE_CONFIG</b>"

#### Example of configuration
### Example of configuration

Example of configuration can be found in "example_db_config.json"


### Chat Server
## Chat Server

Chat server configuration location is managed via environment variable "<b>CHATSERVER_CONFIG</b>".

#### Example of configuration
### Example of configuration

Example of configuration can be found in "chat_server/example_server_config.json"

#### Launching
### Launching

Chat Server can be launched as python module from root directory: ```python -m chat_server```

### Chat Client
## Chat Client

Chat client configuration location is managed via environment variable "<b>CHATCLIENT_CONFIG</b>"

#### Client-side configuration
### Client-side configuration

Client side configuration is used to determine Javascript configs, it should be named "runtime_config.json" and placed to "chat_client/static/js"

Example can be found in "chat_client/static/js/example_runtime_config.json"


#### Server-side configuration
### Server-side configuration

Example of configuration can be found in "chat_client/example_client_config.json"

#### Launching
### Launching

Chat Client can be launched as python module from root directory: ```python -m chat_client```

2 changes: 1 addition & 1 deletion chat_client/blueprints/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
from starlette.requests import Request

from chat_client.client_config import client_config
from chat_client.client_utils.template_utils import callback_template
from utils.http_utils import respond
from utils.template_utils import callback_template

router = APIRouter(
prefix="/components",
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion chat_server/sio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@
stt,
tts,
translation,
user_message as languages_blueprint,
user_message,
prompt,
)
2 changes: 1 addition & 1 deletion dockerfiles/Dockerfile.base
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ RUN apt-get update \
&& apt install build-essential -y \
&& pip install --upgrade pip \
&& pip install wheel \
&& pip install --no-cache-dir -r ./requirements.txt
&& pip install --no-cache-dir -r ./base.txt
2 changes: 2 additions & 0 deletions dockerfiles/Dockerfile.client
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ ENV KLAT_ENV PROD
ENV CHATCLIENT_CONFIG /app/config/config.json
ENV PYTHONPATH="/app:/app/chat_client/"

RUN pip install --no-cache-dir -r /app/chat_client/client.txt

CMD python -m chat_client
1 change: 1 addition & 0 deletions dockerfiles/Dockerfile.observer
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ ENV KLAT_ENV PROD
ENV KLATCHAT_OBSERVER_CONFIG /app/config/config.json
ENV PYTHONPATH="/app:/app/klatchat_observer/"

RUN pip install --no-cache-dir -r /app/klatchat_observer/observer.txt

CMD python -m klatchat_observer
2 changes: 2 additions & 0 deletions dockerfiles/Dockerfile.server
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ ENV CHATSERVER_CONFIG /app/config/config.json
ENV DATABASE_CONFIG /app/config/config.json
ENV PYTHONPATH="/app:/app/chat_server/"

RUN pip install --no-cache-dir -r /app/chat_server/server.txt

CMD python -m chat_server
8 changes: 8 additions & 0 deletions requirements/base.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cachetools==5.3.1
ovos_config==0.0.10
ovos_utils==0.0.35
pre-commit==3.4.0
pydantic==2.4.2
python-socketio==5.9.0
requests==2.31.0
starlette==0.27.0
6 changes: 6 additions & 0 deletions requirements/services/client.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fastapi==0.103.2
httpx==0.25.0 # required by FastAPI
Jinja2==3.1.2
ovos_config==0.0.10
ovos_utils==0.0.35
uvicorn==0.23.2
3 changes: 3 additions & 0 deletions requirements/services/observer.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
neon-mq-connector~=0.7
websocket-client==1.6.3
websockets==11.0.3
13 changes: 13 additions & 0 deletions requirements/services/server.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
aiofiles==23.2.1
bidict==0.22.1
fastapi==0.103.2
fastapi-socketio==0.0.10
httpx==0.25.0 # required by FastAPI
kubernetes==28.1.0
neon-sftp~=0.1
PyJWT==2.8.0
pymongo==4.5.0
python-multipart==0.0.6
uvicorn==0.23.2
websocket-client==1.6.3
websockets==11.0.3
2 changes: 1 addition & 1 deletion scripts/build_base_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ echo "Build version = $VERSION";

cd ..

cp requirements/requirements.txt base
cp requirements/base.txt base

cd base

Expand Down
9 changes: 6 additions & 3 deletions scripts/build_pyklatchat_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ cp config.py services/klatchat_observer
cp config.json services/klatchat_observer
cp version.py services/klatchat_observer
cp -R utils services/klatchat_observer
cp requirements/requirements.txt services/klatchat_observer
cp requirements/base.txt services/klatchat_observer
cp requirements/services/observer.txt services/klatchat_observer
cd services/klatchat_observer

# replacing base image version
Expand All @@ -54,7 +55,8 @@ sed -i "1 s|.*|FROM ghcr.io/neongeckocom/pyklatchat_base:${VERSION}|" ../../dock
docker build -f ../../dockerfiles/Dockerfile.observer -t ghcr.io/neongeckocom/klatchat_observer:$VERSION .
cd ../../
echo "Building Chat Client"
cp requirements/requirements.txt chat_client
cp requirements/base.txt chat_client
cp requirements/services/client.txt chat_client
cp -R utils chat_client
cp config.py chat_client
cp version.py chat_client
Expand All @@ -67,7 +69,8 @@ sed -i "1 s|.*|FROM ghcr.io/neongeckocom/pyklatchat_base:${VERSION}|" ../dockerf
docker build -f ../dockerfiles/Dockerfile.client -t ghcr.io/neongeckocom/chat_client:$VERSION .
cd ..
echo "Building Chat Server"
cp requirements/requirements.txt chat_server
cp requirements/base.txt chat_server
cp requirements/services/server.txt chat_server
cp config.py chat_server
cp version.py chat_server
cp -R utils chat_server
Expand Down
2 changes: 1 addition & 1 deletion version.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

__version__ = "0.4.5a12"
__version__ = "0.4.5a13"
Loading

0 comments on commit f49166d

Please sign in to comment.