Skip to content

E2E Test

E2E Test #31

Workflow file for this run

name: "E2E Test"
on:
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
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] }}
run: |
echo "aicore='$aicore'" > sample-code/.env
echo "aicore='$aicore'" > tests/e2e-tests/.env
url=$(echo "$aicore" | jq -r '.serviceurls.AI_API_URL' | sed 's|^https://||')
echo "Using AI Core ${{ matrix.environment }} instance on $url"
- name: "Check Sample App Starts Up"
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
wget -qO- -S --content-on-error localhost:8080
- name: "Execute E2E Tests"
working-directory: ./tests/e2e-tests
run: |
pnpm run e2e-test
- 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