mirror of
https://github.com/aimingmed/aimingmed-ai.git
synced 2026-02-08 16:37:29 +08:00
Merge pull request #64 from aimingmed/feature/backend-frontend-structure
Feature/backend frontend structure
This commit is contained in:
commit
e18baeff79
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
@ -71,6 +71,7 @@ jobs:
|
|||||||
projectName: aimingmed-ai
|
projectName: aimingmed-ai
|
||||||
image_repo: ghcr.io/$(echo $GITHUB_REPOSITORY | tr '[A-Z]' '[a-z]')
|
image_repo: ghcr.io/$(echo $GITHUB_REPOSITORY | tr '[A-Z]' '[a-z]')
|
||||||
testContainerName: tests-aimingmedai
|
testContainerName: tests-aimingmedai
|
||||||
|
# Todos: This part is not working the testEnvs is not being taken up corrrectly by Run Tests
|
||||||
# Pass test environment variables as JSON string
|
# Pass test environment variables as JSON string
|
||||||
testEnvs: >
|
testEnvs: >
|
||||||
'[
|
'[
|
||||||
@ -79,6 +80,7 @@ jobs:
|
|||||||
"ENVIRONMENT=dev",
|
"ENVIRONMENT=dev",
|
||||||
"TESTING=1",
|
"TESTING=1",
|
||||||
]'
|
]'
|
||||||
|
# Todos: This part is not working the testEnvs is not being taken up corrrectly by Run Tests
|
||||||
# Pass test directories as JSON string
|
# Pass test directories as JSON string
|
||||||
tests: >
|
tests: >
|
||||||
'[
|
'[
|
||||||
@ -90,6 +92,7 @@ jobs:
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"name": "backend-aimingmedai",
|
"name": "backend-aimingmedai",
|
||||||
|
"ports" : ["8004:80"],
|
||||||
"env": {
|
"env": {
|
||||||
"ENVIRONMENT": "dev",
|
"ENVIRONMENT": "dev",
|
||||||
"TESTING": "1",
|
"TESTING": "1",
|
||||||
@ -100,6 +103,7 @@ jobs:
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "frontend-aimingmedai",
|
"name": "frontend-aimingmedai",
|
||||||
|
"ports" : ["3004:80"],
|
||||||
"depends_on": ["backend-aimingmedai"],
|
"depends_on": ["backend-aimingmedai"],
|
||||||
"env": {
|
"env": {
|
||||||
"ENVIRONMENT": "dev",
|
"ENVIRONMENT": "dev",
|
||||||
|
|||||||
12
.github/workflows/template_test.yml
vendored
12
.github/workflows/template_test.yml
vendored
@ -97,6 +97,7 @@ jobs:
|
|||||||
foreach ($img in $images) {
|
foreach ($img in $images) {
|
||||||
$serviceName = $img.name
|
$serviceName = $img.name
|
||||||
$svc = @{}
|
$svc = @{}
|
||||||
|
$svc.container_name = $serviceName
|
||||||
$svc.image = "${{ steps.tags.outputs.image_repo_path }}/$($serviceName):${{ env.TAG }}" # Use run_id tag
|
$svc.image = "${{ steps.tags.outputs.image_repo_path }}/$($serviceName):${{ env.TAG }}" # Use run_id tag
|
||||||
|
|
||||||
if ($img.depends_on) {
|
if ($img.depends_on) {
|
||||||
@ -108,6 +109,9 @@ jobs:
|
|||||||
$svc.environment = @{}
|
$svc.environment = @{}
|
||||||
}
|
}
|
||||||
$svc.networks = @("test") # Assign service to the custom network
|
$svc.networks = @("test") # Assign service to the custom network
|
||||||
|
if ($img.ports) {
|
||||||
|
$svc.ports = $img.ports
|
||||||
|
}
|
||||||
|
|
||||||
$compose.services.$serviceName = $svc
|
$compose.services.$serviceName = $svc
|
||||||
}
|
}
|
||||||
@ -143,11 +147,17 @@ jobs:
|
|||||||
echo "Compose logs after wait:"
|
echo "Compose logs after wait:"
|
||||||
docker compose -f "${{ steps.create_compose.outputs.COMPOSE_FILE_PATH }}" logs
|
docker compose -f "${{ steps.create_compose.outputs.COMPOSE_FILE_PATH }}" logs
|
||||||
|
|
||||||
|
- name: Check Docker Services Health
|
||||||
|
run: |
|
||||||
|
echo "Checking health of Docker services..."
|
||||||
|
# Check if all services are healthy
|
||||||
|
docker compose -f "${{ steps.create_compose.outputs.COMPOSE_FILE_PATH }}" ps
|
||||||
|
|
||||||
- name: Run Tests
|
- name: Run Tests
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
TEST_DIRS='["tests/integration/backend"]'
|
TEST_DIRS='["tests/integration/backend"]'
|
||||||
TEST_ENVS_JSON='["FRONTEND_URL=http://frontend:80","BACKEND_URL=http://backend:80","ENVIRONMENT=dev","TESTING=1"]'
|
TEST_ENVS_JSON='["ENVIRONMENT=dev","TESTING=1"]'
|
||||||
RESULTS_PATH="${{ inputs.testResultsPath }}"
|
RESULTS_PATH="${{ inputs.testResultsPath }}"
|
||||||
STAGING_DIR="${{ runner.temp }}/test-results" # Use runner temp dir for results
|
STAGING_DIR="${{ runner.temp }}/test-results" # Use runner temp dir for results
|
||||||
mkdir -p "$STAGING_DIR"
|
mkdir -p "$STAGING_DIR"
|
||||||
|
|||||||
@ -13,8 +13,6 @@ ENV PYTHONDONTWRITEBYTECODE=1
|
|||||||
ENV PYTHONUNBUFFERED=1
|
ENV PYTHONUNBUFFERED=1
|
||||||
ENV ENVIRONMENT=dev
|
ENV ENVIRONMENT=dev
|
||||||
ENV TESTING=1
|
ENV TESTING=1
|
||||||
ENV DEEPSEEK_API_KEY=sk-XXXXXXXXXX
|
|
||||||
ENV TAVILY_API_KEY=tvly-dev-wXXXXXX
|
|
||||||
|
|
||||||
# install python dependencies
|
# install python dependencies
|
||||||
RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pipenv && rm -rf ~/.cache/pip
|
RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pipenv && rm -rf ~/.cache/pip
|
||||||
|
|||||||
@ -1,17 +1,12 @@
|
|||||||
import pytest
|
import pytest
|
||||||
import subprocess
|
|
||||||
import requests
|
|
||||||
import json
|
import json
|
||||||
import time
|
|
||||||
import os
|
|
||||||
import asyncio
|
|
||||||
import websockets
|
import websockets
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_chatbot_integration():
|
async def test_chatbot_integration():
|
||||||
# Send a request to the chatbot endpoint
|
# Send a request to the chatbot endpoint
|
||||||
url = "ws://backend-aimingmedai:80/ws"
|
url = "ws://localhost:8004/ws"
|
||||||
data = [{"content": "Hello"}]
|
data = [{"content": "Hello"}]
|
||||||
try:
|
try:
|
||||||
async with websockets.connect(url) as websocket:
|
async with websockets.connect(url) as websocket:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user