-
Notifications
You must be signed in to change notification settings - Fork 3
122 lines (104 loc) · 3.94 KB
/
test-prism-example.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
name: Run Prism Tests
on:
push:
branches:
- main
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 prism/requirements.txt
pip install -r tests/requirements.txt
# Install Docker Compose
- name: Install Docker Compose
run: |
curl -L "https://github.com/docker/compose/releases/download/$(curl -s https://api.github.com/repos/docker/compose/releases/latest | jq -r .tag_name)/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose --version
# Write feature keys to config files for use by AVS and Aerospike
- name: Write feature keys
working-directory: docker
env:
FEATURES_CONF : ${{secrets.FEATURES_CONF}}
run: |
echo "$FEATURES_CONF" > config/features.conf
# Run the AVS server with Docker Compose
- name: Start AVS Server
working-directory: docker
run: |
docker-compose -f docker-compose.yaml 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'
env:
# By default, the docker compose in /docker maps the AVS_PORT from 5000 to 5555 on localhost
AVS_PORT: 5555
run: |
nohup python -m waitress --host=127.0.0.1 --port=8080 --threads 32 prism:app &
sleep 30 # Wait for the server to be ready
# TODO come up with a better/faster way to wait for the server to be ready
# Build and run Docker container
- name: Build and Start app 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 30 # Wait for the server to be ready
# TODO come up with a better/faster way to wait for the server to be ready
# Verify Chrome and ChromeDriver Installation
- name: Verify Chrome and ChromeDriver
run: |
google-chrome --version
chromedriver --version
- name: Setup chrome driver
env:
DISPLAY: :99
run: |
# Start a virtual display for headless Chrome
Xvfb :99 -screen 0 1920x1080x24 &
# Run Pytest tests
- name: Run Pytest
working-directory: ${{ env.WORKING_DIR }}
run: |
python -m pytest tests/e2e -s
# Cleanup Docker container (only for Docker deployment)
- name: Cleanup Docker
if: matrix.deployment == 'docker'
run: |
docker stop prism
docker rm prism