Implement notifications #7240
This file contains hidden or 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 Playwright Tests | |
concurrency: | |
group: Run-Playwright-Tests-${{ github.workflow }}-${{ github.head_ref || github.event.workflow_run.head_branch || github.run_id }} | |
cancel-in-progress: true | |
on: push | |
env: | |
# AWS ECR Configuration | |
AWS_REGION: ${{ secrets.AWS_REGION || 'us-west-2' }} | |
ECR_REGISTRY: ${{ secrets.ECR_REGISTRY }} | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID_ECR }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_ECR }} | |
BUILDX_NO_DEFAULT_ATTESTATIONS: 1 | |
# Test Environment Variables | |
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} | |
GEN_AI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
EXA_API_KEY: ${{ secrets.EXA_API_KEY }} | |
# for federated slack tests | |
SLACK_CLIENT_ID: ${{ secrets.SLACK_CLIENT_ID }} | |
SLACK_CLIENT_SECRET: ${{ secrets.SLACK_CLIENT_SECRET }} | |
MOCK_LLM_RESPONSE: true | |
jobs: | |
build-web-image: | |
runs-on: blacksmith-8vcpu-ubuntu-2404-arm | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-access-key-id: ${{ env.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ env.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ env.AWS_REGION }} | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v2 | |
- name: Set up Docker Buildx | |
uses: useblacksmith/setup-docker-builder@v1 | |
- name: Build and push Web Docker image | |
uses: useblacksmith/build-push-action@v2 | |
with: | |
context: ./web | |
file: ./web/Dockerfile | |
platforms: linux/arm64 | |
tags: ${{ env.ECR_REGISTRY }}/integration-test-onyx-web-server:playwright-test-${{ github.run_id }} | |
provenance: false | |
sbom: false | |
push: true | |
build-backend-image: | |
runs-on: blacksmith-8vcpu-ubuntu-2404-arm | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-access-key-id: ${{ env.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ env.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ env.AWS_REGION }} | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v2 | |
- name: Set up Docker Buildx | |
uses: useblacksmith/setup-docker-builder@v1 | |
- name: Build and push Backend Docker image | |
uses: useblacksmith/build-push-action@v2 | |
with: | |
context: ./backend | |
file: ./backend/Dockerfile | |
platforms: linux/arm64 | |
tags: ${{ env.ECR_REGISTRY }}/integration-test-onyx-backend:playwright-test-${{ github.run_id }} | |
provenance: false | |
sbom: false | |
push: true | |
build-model-server-image: | |
runs-on: blacksmith-8vcpu-ubuntu-2404-arm | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-access-key-id: ${{ env.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ env.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ env.AWS_REGION }} | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v2 | |
- name: Set up Docker Buildx | |
uses: useblacksmith/setup-docker-builder@v1 | |
- name: Build and push Model Server Docker image | |
uses: useblacksmith/build-push-action@v2 | |
with: | |
context: ./backend | |
file: ./backend/Dockerfile.model_server | |
platforms: linux/arm64 | |
tags: ${{ env.ECR_REGISTRY }}/integration-test-onyx-model-server:playwright-test-${{ github.run_id }} | |
provenance: false | |
sbom: false | |
push: true | |
playwright-tests: | |
needs: [build-web-image, build-backend-image, build-model-server-image] | |
name: Playwright Tests | |
runs-on: blacksmith-8vcpu-ubuntu-2404-arm | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-access-key-id: ${{ env.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ env.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ env.AWS_REGION }} | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v2 | |
# needed for pulling Vespa, Redis, Postgres, and Minio images | |
# otherwise, we hit the "Unauthenticated users" limit | |
# https://docs.docker.com/docker-hub/usage/ | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_TOKEN }} | |
- name: Pull Docker images | |
run: | | |
# Pull all images from ECR in parallel | |
echo "Pulling Docker images in parallel..." | |
(docker pull ${{ env.ECR_REGISTRY }}/integration-test-onyx-web-server:playwright-test-${{ github.run_id }}) & | |
(docker pull ${{ env.ECR_REGISTRY }}/integration-test-onyx-backend:playwright-test-${{ github.run_id }}) & | |
(docker pull ${{ env.ECR_REGISTRY }}/integration-test-onyx-model-server:playwright-test-${{ github.run_id }}) & | |
# Wait for all background jobs to complete | |
wait | |
echo "All Docker images pulled successfully" | |
# Re-tag with expected names for docker-compose | |
docker tag ${{ env.ECR_REGISTRY }}/integration-test-onyx-web-server:playwright-test-${{ github.run_id }} onyxdotapp/onyx-web-server:test | |
docker tag ${{ env.ECR_REGISTRY }}/integration-test-onyx-backend:playwright-test-${{ github.run_id }} onyxdotapp/onyx-backend:test | |
docker tag ${{ env.ECR_REGISTRY }}/integration-test-onyx-model-server:playwright-test-${{ github.run_id }} onyxdotapp/onyx-model-server:test | |
- name: Setup node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 22 | |
- name: Install node dependencies | |
working-directory: ./web | |
run: npm ci | |
- name: Install playwright browsers | |
working-directory: ./web | |
run: npx playwright install --with-deps | |
- name: Start Docker containers | |
run: | | |
cd deployment/docker_compose | |
ENABLE_PAID_ENTERPRISE_EDITION_FEATURES=true \ | |
AUTH_TYPE=basic \ | |
GEN_AI_API_KEY=${{ env.OPENAI_API_KEY }} \ | |
EXA_API_KEY=${{ env.EXA_API_KEY }} \ | |
REQUIRE_EMAIL_VERIFICATION=false \ | |
DISABLE_TELEMETRY=true \ | |
IMAGE_TAG=test \ | |
docker compose -f docker-compose.dev.yml -p danswer-stack up -d | |
id: start_docker | |
- name: Wait for service to be ready | |
run: | | |
echo "Starting wait-for-service script..." | |
docker logs -f danswer-stack-api_server-1 & | |
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 Playwright tests | |
working-directory: ./web | |
run: npx playwright test | |
- uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
# Chromatic automatically defaults to the test-results directory. | |
# Replace with the path to your custom directory and adjust the CHROMATIC_ARCHIVE_LOCATION environment variable accordingly. | |
name: test-results | |
path: ./web/test-results | |
retention-days: 30 | |
# save before stopping the containers so the logs can be captured | |
- 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@v4 | |
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 | |
# NOTE: Chromatic UI diff testing is currently disabled. | |
# We are using Playwright for local and CI testing without visual regression checks. | |
# Chromatic may be reintroduced in the future for UI diff testing if needed. | |
# chromatic-tests: | |
# name: Chromatic Tests | |
# needs: playwright-tests | |
# runs-on: | |
# [ | |
# runs-on, | |
# runner=32cpu-linux-x64, | |
# disk=large, | |
# "run-id=${{ github.run_id }}", | |
# ] | |
# steps: | |
# - name: Checkout code | |
# uses: actions/checkout@v4 | |
# with: | |
# fetch-depth: 0 | |
# - name: Setup node | |
# uses: actions/setup-node@v4 | |
# with: | |
# node-version: 22 | |
# - name: Install node dependencies | |
# working-directory: ./web | |
# run: npm ci | |
# - name: Download Playwright test results | |
# uses: actions/download-artifact@v4 | |
# with: | |
# name: test-results | |
# path: ./web/test-results | |
# - name: Run Chromatic | |
# uses: chromaui/action@latest | |
# with: | |
# playwright: true | |
# projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} | |
# workingDir: ./web | |
# env: | |
# CHROMATIC_ARCHIVE_LOCATION: ./test-results |