-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add prism example test action file
- Loading branch information
1 parent
abc05a1
commit d539f87
Showing
1 changed file
with
88 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,88 @@ | ||
name: Run Pytest Tests with Different Server Deployments | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- vec-474 | ||
pull_request: | ||
|
||
jobs: | ||
tests: | ||
name: Run Tests with Waitress and Docker Deployments | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
WORKING_DIR: prism-image-search | ||
|
||
strategy: | ||
matrix: | ||
deployment: [waitress, docker] # Define deployment strategies | ||
|
||
steps: | ||
# Checkout the repository | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
|
||
# Set up Python environment | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.10 | ||
|
||
# Install Python dependencies | ||
- name: Install Dependencies | ||
working-directory: ${{ env.WORKING_DIR }} | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
pip install -r tests/requirements.txt | ||
# Run the AVS server with Docker Compose | ||
- name: Start AVS Server | ||
working-directory: docker | ||
run: | | ||
docker-compose -f docker-compose.yml up -d | ||
# Wait for the AVS Docker Container to be Healthy | ||
- name: Wait for Docker Container to Be Healthy | ||
run: | | ||
CONTAINER_NAME="aerospike-vector-search" | ||
while [ "$(docker inspect -f '{{.State.Health.Status}}' $CONTAINER_NAME)" != "healthy" ]; do | ||
echo "Waiting for container $CONTAINER_NAME to be healthy..." | ||
sleep 1 | ||
done | ||
echo "Container $CONTAINER_NAME is healthy, continuing..." | ||
# Run the app server with waitress | ||
- name: Start Server with Waitress | ||
working-directory: ${{ env.WORKING_DIR }}/prism | ||
if: matrix.deployment == 'waitress' | ||
run: | | ||
nohup python -m waitress --host=127.0.0.1 --port=8080 --threads 32 prism:app & | ||
sleep 5 # Wait for the server to be ready | ||
# Build and run Docker container | ||
- name: Build and Start Server with Docker | ||
working-directory: ${{ env.WORKING_DIR }} | ||
if: matrix.deployment == 'docker' | ||
run: | | ||
docker build -t prism . -f Dockerfile-prism | ||
docker run -d -p 8080:8080 --name prism \ | ||
--network svc \ | ||
-e AVS_PORT=5000 \ | ||
-e AVS_HOST=aerospike-vector-search \ | ||
prism | ||
sleep 5 # Wait for the server to be ready | ||
# Run Pytest tests | ||
- name: Run Pytest | ||
run: | | ||
pytest tests/ -s | ||
# Cleanup Docker container (only for Docker deployment) | ||
- name: Cleanup Docker | ||
if: matrix.deployment == 'docker' | ||
run: | | ||
docker stop prism | ||
docker rm prism |