e2e tests #71
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 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: | |
- uses: sap/ai-sdk-js/.github/actions/setup@main | |
- 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: 'Cleanup Deployments' | |
run: pnpm e2e-tests cleanup-deployments | |
- 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 |