generated from SAP/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 7
80 lines (70 loc) · 2.5 KB
/
e2e-test.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: "End-to-end Tests"
on:
workflow_dispatch:
schedule:
- cron: 15 2 * * MON-FRI
env:
MVN_MULTI_THREADED_ARGS: --batch-mode --no-transfer-progress --fail-at-end --show-version --threads 1C
JAVA_VERSION: 17
jobs:
end-to-end-tests:
strategy:
fail-fast: false
matrix:
environment: [ canary, production ]
exclude:
- environment: production
# secret-name: AI_CORE_PRODUCTION
include:
- environment: canary
secret-name: AI_CORE_CANARY
runs-on: ubuntu-latest
steps:
- name: "Checkout repository"
uses: actions/checkout@v4
- name: "Setup java"
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: ${{ env.JAVA_VERSION }}
cache: 'maven'
- name: "Build SDK"
run: |
MVN_ARGS="${{ env.MVN_MULTI_THREADED_ARGS }} clean install -DskipTests -DskipFormatting"
mvn $MVN_ARGS
- name: "Run tests"
run: |
MVN_ARGS="${{ env.MVN_MULTI_THREADED_ARGS }} surefire:test -pl :spring-app -DskipTests=false"
mvn $MVN_ARGS "-Daicore.landscape=${{ matrix.environment }}"
env:
# See "End-to-end test application instructions" on the README.md to update the secret
AICORE_SERVICE_KEY: ${{ secrets[matrix.secret-name] }}
- name: "Start Application Locally"
run: |
cd sample-code/spring-app
mvn spring-boot:run &
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
env:
# See "End-to-end test application instructions" on the README.md to update the secret
AICORE_SERVICE_KEY: ${{ secrets[matrix.secret-name] }}
- name: "Health Check"
# print response body with headers to stdout. q:body only O:print -:stdout S:headers
run: wget -qO- -S localhost:8080
- name: "Slack Notification"
if: failure()
uses: slackapi/[email protected]
with:
webhook: ${{ secrets.SLACK_WEBHOOK }}
webhook-type: incoming-webhook
payload: |
{
"text": "⚠️ End-to-end tests failed! 😬 Please inspect & fix by clicking <https://github.com/SAP/ai-sdk-java/actions/runs/${{ github.run_id }}|here>"
}