Skip to content

e2e tests

e2e tests #30

Workflow file for this run

name: e2e tests
on:
workflow_dispatch:
schedule:
- cron: 0 22 * * *
jobs:
e2e-tests:
strategy:
fail-fast: false
matrix:
environment: [staging, production]
# disabled, because currently staging is behind production
exclude:
- environment: staging
include:
- 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_SERVICE_KEY: ${{ secrets[matrix.secret-name] }}
run: |
echo "AICORE_SERVICE_KEY='$AICORE_SERVICE_KEY'" > sample-code/.env
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'
working-directory: ./sample-code
run: |
pnpm 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'
run: pnpm test:e2e
- 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