E2E Test #30
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: "E2E Test" | |
on: | |
push: | |
branches: | |
- chore/e2e-test | |
workflow_dispatch: | |
schedule: | |
- cron: 0 22 * * * | |
jobs: | |
e2e-test: | |
strategy: | |
fail-fast: false | |
matrix: | |
environment: [staging, production] | |
include: | |
- environment: staging | |
secret-name: AI_CORE_STAGING | |
- environment: production | |
secret-name: AI_CORE_PRODUCTION | |
name: "Build and Test" | |
runs-on: ubuntu-latest | |
env: | |
WGET_ARGS: "-qO- -S --content-on-error" | |
WGET_URL: "localhost:8080" | |
steps: | |
- name: "Checkout repository" | |
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 | |
- name: Create .env file | |
env: | |
aicore: ${{ secrets[matrix.secret-name] }} | |
working-directory: ./sample-code | |
run: | | |
echo "aicore='$aicore'" > .env | |
url=$(echo "$aicore" | jq -r '.serviceurls.AI_API_URL' | sed 's|^https://||') | |
echo "Using AI Core ${{ matrix.environment }} instance on $url" | |
- name: "Start App" | |
working-directory: ./sample-code | |
run: | | |
pnpm run local & | |
timeout=15 | |
while ! nc -z localhost 8080; do | |
sleep 1 | |
timeout=$((timeout - 1)) | |
if [ $timeout -le 0 ]; then | |
echo "Server did not start within 15 seconds." | |
exit 1 | |
fi | |
done | |
- name: "Health Check" | |
run: | | |
wget "$WGET_ARGS" "$WGET_URL/health" | |
- name: "OpenAI Chat Completion" | |
run: | | |
wget "$WGET_ARGS" "$WGET_URL/llm" | |
- name: "OpenAI Text Embedding" | |
run: | | |
wget "$WGET_ARGS" "$WGET_URL/embedding" | |
- name: "Slack Notification" | |
if: failure() | |
uses: slackapi/[email protected] | |
with: | |
payload: | | |
{ | |
"username": "GitHub E2E Test Runner", | |
"text": "⚠️ E2E Test Failed! 😬 Please inspect & fix by clicking <https://github.com/SAP/ai-sdk-js/actions/runs/${{ github.run_id }}|here>" | |
} | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} | |
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK |