Skip to content

Commit

Permalink
Merge branch 'main' into nuclia_e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
drf7 authored Jan 3, 2025
2 parents ce00fbe + 9ccd52c commit d3ff586
Show file tree
Hide file tree
Showing 23 changed files with 319 additions and 159 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/run-e2e-ui-starter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: run-e2e-ui-starter
run-name: Checking UI Starter
on:
push:
branches:
- '**'
workflow_dispatch:
branches:
- main
schedule:
# Run at 00:25 and 12:25 on saturday and sunday
- cron: '25 0,12 * * 0,6'
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
jobs:
cypress-run:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
# Run ui-starter
- run: |
git clone https://github.com/nuclia/ui-starter.git
cd ./ui-starter
npm install
npm run missdev
npm run build
npm run preview &
# Install npm dependencies, cache them correctly and run all Cypress tests
- name: Cypress run
id: cypress
uses: cypress-io/github-action@v6
with:
install-command: yarn install
spec: cypress/e2e/5-ui-starter/ui-starter.cy.js
env:
CYPRESS_BASE_URL: https://stashify.cloud
CYPRESS_BEARER_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
CYPRESS_NUA_KEY: ${{ secrets.NUA_KEY }}
CYPRESS_USER_NAME: ${{ secrets.USER_NAME }}
CYPRESS_USER_PWD: ${{ secrets.USER_PWD }}
CYPRESS_RUNNING_ENV: stage
CYPRESS_UI_STARTER: true
# after the test run completes store reports and any screenshots
- name: Cypress reports
id: report
uses: actions/upload-artifact@v4
if: ${{ failure() && steps.cypress.conclusion == 'failure' }}
with:
name: cypress-reports
path: cypress/reports
if-no-files-found: ignore # 'warn' or 'error' are also available, defaults to `warn`
- name: Slack notification
id: slack
uses: slackapi/[email protected]
if: ${{ failure() && steps.cypress.conclusion == 'failure' && github.ref_name == 'main' }}
with:
payload: |
{
"text": "⚠️ UI Starter E2E failed\nTriggered by ${{ github.triggering_actor }} \nRun #${{ github.run_number }}: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\nCypress report: ${{ steps.report.outputs.artifact-url }}"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_HOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ cypress.env.*.json
/cypress/videos
/cypress/reports
/cypress/downloads
/ui-starter

# dependencies
node_modules
Expand Down
23 changes: 23 additions & 0 deletions cypress/e2e/5-ui-starter/ui-starter.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/// <reference types="cypress" />

import { UI_STARTER } from '../../support/common';

describe('UI Starter', () => {
it('should build UI Starter', () => {
if (!UI_STARTER) {
cy.log('Not the UI Starter environment');
cy.on('fail', (err, runnable) => {
cy.log(err.message);
return false;
});
cy.request({ url: 'http://localhost:4173', failOnStatusCode: false }).should('be.false');
} else {
cy.visit('http://localhost:4173');
cy.get('.nuclia-widget .sw-search-input').should('exist');
cy.get('.sw-textarea textarea').click();
cy.get('.sw-textarea textarea').type(`Gold price evolution in 2023\n`, { force: true });
cy.get('.sw-initial-answer').should('exist');
cy.get('h3.result-title').should('exist');
}
});
});
2 changes: 2 additions & 0 deletions cypress/support/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ export const user = {
password: `${Cypress.env('USER_PWD')}`,
};

export const UI_STARTER = !!Cypress.env('UI_STARTER');

export function getAuthHeader(synchronous = true) {
const headers = { Authorization: `Bearer ${Cypress.env('BEARER_TOKEN')}` };
if (synchronous) {
Expand Down
Binary file removed nua/e2e/assets/financial-new-kb.arrow
Binary file not shown.
Binary file added nua/e2e/assets/financial-news-kb.arrow
Binary file not shown.
Binary file modified nua/e2e/assets/legal-text-kb.arrow
Binary file not shown.
31 changes: 12 additions & 19 deletions nua/e2e/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

import nuclia
import pytest
from nuclia.config import reset_config_file, set_config_file
from nuclia.sdk.auth import NucliaAuth
from nuclia.lib.nua import AsyncNuaClient
from dataclasses import dataclass
from typing import AsyncGenerator

logger = logging.getLogger("e2e")

Expand All @@ -22,17 +23,17 @@ class Tokens:
PROD_ACCOUNT_ID = "5cec111b-ea23-4b0c-a82a-d1a666dd1fd2"

TOKENS: dict[str, Tokens] = {
"europe-1.stashify.cloud": Tokens(
"https://europe-1.stashify.cloud": Tokens(
nua_key=os.environ.get("TEST_EUROPE1_STASHIFY_NUA"),
pat_key=os.environ.get("STAGE_PERMAMENT_ACCOUNT_OWNER_PAT_TOKEN"),
account_id=os.environ.get("TEST_EUROPE1_STASHIFY_ACCOUNT", STAGE_ACCOUNT_ID),
),
"europe-1.nuclia.cloud": Tokens(
"https://europe-1.nuclia.cloud": Tokens(
nua_key=os.environ.get("TEST_EUROPE1_NUCLIA_NUA"),
pat_key=os.environ.get("PROD_PERMAMENT_ACCOUNT_OWNER_PAT_TOKEN"),
account_id=PROD_ACCOUNT_ID,
),
"aws-us-east-2-1.nuclia.cloud": Tokens(
"https://aws-us-east-2-1.nuclia.cloud": Tokens(
nua_key=os.environ.get("TEST_AWS_US_EAST_2_1_NUCLIA_NUA"),
pat_key=os.environ.get("PROD_PERMAMENT_ACCOUNT_OWNER_PAT_TOKEN"),
account_id=PROD_ACCOUNT_ID,
Expand All @@ -43,12 +44,12 @@ class Tokens:
@pytest.fixture(
scope="function",
params=[
"europe-1.stashify.cloud",
"europe-1.nuclia.cloud",
"aws-us-east-2-1.nuclia.cloud",
"https://europe-1.stashify.cloud",
"https://europe-1.nuclia.cloud",
"https://aws-us-east-2-1.nuclia.cloud",
],
)
def nua_config(request):
async def nua_config(request) -> AsyncGenerator[AsyncNuaClient, None]:
if (
os.environ.get("TEST_ENV") == "stage" and "stashify.cloud" not in request.param # noqa
): # noqa
Expand All @@ -63,14 +64,6 @@ def nua_config(request):
assert token.pat_key
assert token.account_id

with tempfile.NamedTemporaryFile() as temp_file:
temp_file.write(b"{}")
temp_file.flush()
set_config_file(temp_file.name)
nuclia_auth = NucliaAuth()
client_id = nuclia_auth.nua(token.nua_key)
assert client_id
nuclia_auth._config.set_default_nua(client_id)

yield request.param
reset_config_file()
yield AsyncNuaClient(
region=request.param, account=token.account_id, token=token.nua_key
)
6 changes: 5 additions & 1 deletion nua/e2e/regional/models.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
ALL_LLMS = [ # Extracted from learning/libraries/learning_models/generative.py
"chatgpt-azure-4o",
"chatgpt-azure-4-turbo",
"chatgpt-azure-4o-mini",
"claude-3",
"claude-3-fast",
"claude-3-5-fast",
"claude-3-5-small",
"gemini-1-5-pro",
"gemini-1-5-pro-vision",
"gemini-1-5-flash",
"gemini-1-5-flash-vision",
"mistral",
"azure-mistral",
"chatgpt-vision",
"chatgpt4",
"chatgpt4o",
"chatgpt4o-mini",
Expand All @@ -31,12 +32,15 @@
LLM_WITH_JSON_OUTPUT_SUPPORT = [
"chatgpt-azure-4-turbo",
"chatgpt-azure-4o",
"chatgpt-azure-4o-mini",
"claude-3",
"claude-3-fast",
"claude-3-5-fast",
"claude-3-5-small",
"chatgpt4",
"chatgpt4o",
"chatgpt4o-mini",
"gemini-1-5-pro",
"gemini-1-5-flash",
"azure-mistral",
]
Loading

0 comments on commit d3ff586

Please sign in to comment.