generated from SAP/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 4
61 lines (59 loc) · 2.03 KB
/
e2e-tests.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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