Initial sync of downstream development work into StackHPC fork #1
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
name: Run Integration Tests | |
concurrency: | |
group: Run-Integration-Tests-${{ github.head_ref }} | |
cancel-in-progress: true | |
on: | |
merge_group: | |
pull_request: | |
branches: [ main ] | |
env: | |
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
jobs: | |
integration-tests: | |
runs-on: | |
group: 'arm64-image-builders' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_TOKEN }} | |
- name: Build Web Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./web | |
file: ./web/Dockerfile | |
platforms: linux/arm64 | |
pull: true | |
push: true | |
load: true | |
tags: danswer/danswer-web-server:it | |
cache-from: type=registry,ref=danswer/danswer-web-server:it | |
cache-to: | | |
type=registry,ref=danswer/danswer-web-server:it,mode=max | |
type=inline | |
- name: Build Backend Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./backend | |
file: ./backend/Dockerfile | |
platforms: linux/arm64 | |
pull: true | |
push: true | |
load: true | |
tags: danswer/danswer-backend:it | |
cache-from: type=registry,ref=danswer/danswer-backend:it | |
cache-to: | | |
type=registry,ref=danswer/danswer-backend:it,mode=max | |
type=inline | |
- name: Build Model Server Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./backend | |
file: ./backend/Dockerfile.model_server | |
platforms: linux/arm64 | |
pull: true | |
push: true | |
load: true | |
tags: danswer/danswer-model-server:it | |
cache-from: type=registry,ref=danswer/danswer-model-server:it | |
cache-to: | | |
type=registry,ref=danswer/danswer-model-server:it,mode=max | |
type=inline | |
- name: Build integration test Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./backend | |
file: ./backend/tests/integration/Dockerfile | |
platforms: linux/arm64 | |
pull: true | |
push: true | |
load: true | |
tags: danswer/integration-test-runner:it | |
cache-from: type=registry,ref=danswer/integration-test-runner:it | |
cache-to: | | |
type=registry,ref=danswer/integration-test-runner:it,mode=max | |
type=inline | |
- name: Start Docker containers | |
run: | | |
cd deployment/docker_compose | |
ENABLE_PAID_ENTERPRISE_EDITION_FEATURES=true \ | |
IMAGE_TAG=it \ | |
docker compose -f docker-compose.dev.yml -p danswer-stack up -d --build | |
id: start_docker | |
- name: Wait for service to be ready | |
run: | | |
echo "Starting wait-for-service script..." | |
start_time=$(date +%s) | |
timeout=300 # 5 minutes in seconds | |
while true; do | |
current_time=$(date +%s) | |
elapsed_time=$((current_time - start_time)) | |
if [ $elapsed_time -ge $timeout ]; then | |
echo "Timeout reached. Service did not become ready in 5 minutes." | |
exit 1 | |
fi | |
# Use curl with error handling to ignore specific exit code 56 | |
response=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8080/health || echo "curl_error") | |
if [ "$response" = "200" ]; then | |
echo "Service is ready!" | |
break | |
elif [ "$response" = "curl_error" ]; then | |
echo "Curl encountered an error, possibly exit code 56. Continuing to retry..." | |
else | |
echo "Service not ready yet (HTTP status $response). Retrying in 5 seconds..." | |
fi | |
sleep 5 | |
done | |
echo "Finished waiting for service." | |
- name: Run integration tests | |
run: | | |
echo "Running integration tests..." | |
docker run --rm --network danswer-stack_default \ | |
-e POSTGRES_HOST=relational_db \ | |
-e POSTGRES_USER=postgres \ | |
-e POSTGRES_PASSWORD=password \ | |
-e POSTGRES_DB=postgres \ | |
-e VESPA_HOST=index \ | |
-e API_SERVER_HOST=api_server \ | |
-e OPENAI_API_KEY=${OPENAI_API_KEY} \ | |
danswer/integration-test-runner:it | |
continue-on-error: true | |
id: run_tests | |
- name: Check test results | |
run: | | |
if [ ${{ steps.run_tests.outcome }} == 'failure' ]; then | |
echo "Integration tests failed. Exiting with error." | |
exit 1 | |
else | |
echo "All integration tests passed successfully." | |
fi | |
- name: Save Docker logs | |
if: success() || failure() | |
run: | | |
cd deployment/docker_compose | |
docker compose -f docker-compose.dev.yml -p danswer-stack logs > docker-compose.log | |
mv docker-compose.log ${{ github.workspace }}/docker-compose.log | |
- name: Upload logs | |
if: success() || failure() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: docker-logs | |
path: ${{ github.workspace }}/docker-compose.log | |
- name: Stop Docker containers | |
run: | | |
cd deployment/docker_compose | |
docker compose -f docker-compose.dev.yml -p danswer-stack down -v |