-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: Add smoke test #80
Changes from 27 commits
acba1f5
edffb80
2faa7df
963635a
261c7c0
40c1688
7d017f5
741fd31
081e37e
e2c3198
1048876
cf25ac4
69dce1e
fccf6ee
940a7fa
d515925
d27d149
bbd7a86
789c1db
d0b4f09
f1cc435
6e42668
257acf0
0f9b6cf
504fe86
6fbb46b
a5a7224
b4af5c3
02cb0b4
210aa93
133d2af
1765ac2
f8f86d5
d3c5ae4
e293fca
4b426d6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
name: "E2E Test" | ||
name: e2e tests | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: 0 22 * * * | ||
|
||
jobs: | ||
e2e-test: | ||
e2e-tests: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
|
@@ -16,10 +17,10 @@ jobs: | |
include: | ||
- environment: production | ||
secret-name: AI_CORE_PRODUCTION | ||
name: "Build and Test" | ||
name: 'Build and Test' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: "Checkout repository" | ||
- name: 'Checkout repository' | ||
uses: actions/checkout@v4 | ||
- uses: pnpm/action-setup@v3 | ||
with: | ||
|
@@ -37,7 +38,7 @@ jobs: | |
echo "AICORE_SERVICE_KEY='$AICORE_SERVICE_KEY'" > tests/e2e-tests/.env | ||
url=$(echo "$AICORE_SERVICE_KEY" | jq -r '.serviceurls.AI_API_URL' | sed 's|^https://||') | ||
echo "Using AI Core ${{ matrix.environment }} instance on $url" | ||
- name: "Check Sample App Starts Up" | ||
- name: 'Check Sample App Starts Up' | ||
working-directory: ./sample-code | ||
run: | | ||
pnpm local & | ||
|
@@ -51,9 +52,9 @@ jobs: | |
fi | ||
done | ||
wget -qO- -S --content-on-error localhost:8080 | ||
- name: "Execute E2E Tests" | ||
- name: 'Execute E2E Tests' | ||
run: pnpm test:e2e | ||
- name: "Slack Notification" | ||
- name: 'Slack Notification' | ||
if: failure() | ||
uses: slackapi/[email protected] | ||
with: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
name: 'Fosstars (Security)' | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: smoke test | ||
|
||
on: | ||
pull_request: ~ | ||
workflow_dispatch: | ||
schedule: | ||
- cron: 0 22 * * * | ||
|
||
jobs: | ||
smoke-tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: pnpm/action-setup@v3 | ||
with: | ||
version: ${{ vars.PNPM_VERSION }} | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ vars.DEFAULT_NODE_VERSION }} | ||
cache: 'pnpm' | ||
- run: pnpm i --frozen-lockfile | ||
- uses: vchrisb/setup-cf@v0 | ||
with: | ||
api: ${{ vars.CF_API_URL }} | ||
username: ${{ secrets.CF_USER }} | ||
password: ${{ secrets.CF_PASSWORD }} | ||
org: ${{ vars.CF_ORG }} | ||
space: ${{ vars.CF_SPACE }} | ||
- run: cf push | ||
working-directory: tests/smoke-tests | ||
- name: smoke test | ||
run: pnpm test:smoke |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,3 +55,4 @@ build/Release | |
# VS Code | ||
.vscode | ||
/pnpm-publish-summary.json | ||
/tests/smoke-tests/deployment |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module.exports = { | ||
hooks: { | ||
afterAllResolved: async lockfile => { | ||
// Object.keys(lockfile.packages) | ||
// .filter(pkg => pkg.startsWith('@sap-ai-sdk')) | ||
// .forEach(pkg => { | ||
// delete lockfile.packages[pkg]; | ||
// }); | ||
|
||
// Object.keys(lockfile.importers['tests/smoke-tests'].dependencies) | ||
// .filter(pkg => pkg.startsWith('@sap-ai-sdk')) | ||
// .forEach(pkg => { | ||
// delete lockfile.importers['tests/smoke-tests'].dependencies[pkg]; | ||
// }); | ||
|
||
return lockfile; | ||
} | ||
} | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { AiDeployment, DeploymentApi } from '@sap-ai-sdk/ai-core'; | ||
|
||
/** | ||
* Get all deployments. | ||
* @returns All deployments. | ||
*/ | ||
export async function getDeployments(): Promise<AiDeployment[]> { | ||
const { data } = await DeploymentApi.deploymentQuery( | ||
{}, | ||
{ 'AI-Resource-Group': 'default' } | ||
).execute(); | ||
|
||
return data; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { | ||
type CompletionPostResponse, | ||
OrchestrationClient | ||
} from '@sap-ai-sdk/gen-ai-hub'; | ||
|
||
/** | ||
* Ask GPT about the capital of France. | ||
* @returns The answer from the orchestration service in Gen AI Hub. | ||
*/ | ||
export function orchestrationCompletion(): Promise<CompletionPostResponse> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [q] We could consider calling this from the e2e test, similar to how we do it for OpenAI. That way we gain additional confidence this code actually works 😉 |
||
const orchestrationClient = new OrchestrationClient(); | ||
|
||
return orchestrationClient.chatCompletion( | ||
{ | ||
llmConfig: { | ||
model_name: 'gpt-4-32k', | ||
model_params: {} | ||
}, | ||
prompt: { | ||
template: [{ role: 'user', content: 'What is the capital of France?' }] | ||
} | ||
}, | ||
'db1d64d9f06be467' | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uhm, leftover?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, I want to keep this for the follow up, because this code will most likely be needed for it.