generated from SAP/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 5
126 lines (108 loc) · 4.03 KB
/
dependency-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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
name: Test SAP Cloud SDK Versions
on:
workflow_dispatch:
schedule:
- cron: 0 22 * * *
push:
branches:
- "workflow/compatibility-version"
pull_request:
branches:
- "main"
paths:
- ".github/workflows/dependency-test.yaml"
env:
MVN_MULTI_THREADED_ARGS: --batch-mode --no-transfer-progress --fail-at-end --show-version --threads 1C
JAVA_VERSION: 17
jobs:
fetch-dependency-versions:
runs-on: ubuntu-latest
outputs:
versions: ${{ steps.fetch-versions.outputs.VERSIONS }}
steps:
- name: Fetch versions from Maven Central
id: fetch-versions
run: |
# Specify the dependency coordinates
GROUP_ID="com.sap.cloud.sdk"
ARTIFACT_ID="sdk-bom"
# Fetch available versions from Maven Central API
response=$(curl -s "https://search.maven.org/solrsearch/select?q=g:%22${GROUP_ID}%22+AND+a:%22${ARTIFACT_ID}%22&rows=15&core=gav&wt=json")
# Extract and filter versions (e.g., to exclude snapshots or specific versions)
versions=$(echo "$response" | jq -r '.response.docs[].v' | grep -v -E 'SNAPSHOT|alpha|beta' | sort -V)
# Convert the versions to a JSON array
json_versions=$(echo "$versions" | jq -R . | jq -s . | tr -d '\n')
echo "JSON Versions: $json_versions"
# Output the versions as a string that can be used in the matrix
echo "VERSIONS=${json_versions}" >> $GITHUB_OUTPUT
setup-environment:
runs-on: ubuntu-latest
outputs:
cache-key: ${{ steps.cache-build.outputs.cache-key }}
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: "Cache build"
id: cache-build
uses: actions/cache@v3
with:
path: |
~/.m2/repository
target
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: "Build SDK"
run: |
MVN_ARGS="${{ env.MVN_MULTI_THREADED_ARGS }} clean install -DskipTests -DskipFormatting"
mvn $MVN_ARGS
test-dependency-versions:
needs: [ fetch-dependency-versions, setup-environment ]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
version: ${{ fromJson(needs.fetch-dependency-versions.outputs.versions) }}
continue-on-error: true
steps:
- name: "Checkout repository"
uses: actions/checkout@v4
- name: "Restore build cache"
uses: actions/cache@v3
with:
path: |
~/.m2/repository
target
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
- name: "Run tests with explicit version"
run: |
MVN_ARGS="${{ env.MVN_MULTI_THREADED_ARGS }} clean package -pl :spring-app -DskipTests=false -DskipFormatting -Dcloud-sdk.version=${{ matrix.version }} -Denforcer.skip=true"
mvn $MVN_ARGS
env:
# See "End-to-end test application instructions" on the README.md to update the secret
AICORE_SERVICE_KEY: ${{ secrets.AICORE_SERVICE_KEY }}
- 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.AICORE_SERVICE_KEY }}
- name: "Health Check"
# print response body with headers to stdout. q:body only O:print -:stdout S:headers
run: wget -qO- -S localhost:8080