diff --git a/.github/workflows/dependency-test.yaml b/.github/workflows/dependency-test.yaml new file mode 100644 index 00000000..a170bca2 --- /dev/null +++ b/.github/workflows/dependency-test.yaml @@ -0,0 +1,128 @@ +name: Test SAP Cloud SDK Versions + +on: + workflow_dispatch: + schedule: + - cron: 0 22 * * * + push: + branches: + - "workflow/compatibility-version" + +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: "Setup java" + uses: actions/setup-java@v4 + with: + distribution: "temurin" + java-version: ${{ env.JAVA_VERSION }} + cache: 'maven' + + - 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 -Dspotless.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 diff --git a/pom.xml b/pom.xml index b6d7adc8..9f3bba66 100644 --- a/pom.xml +++ b/pom.xml @@ -60,14 +60,17 @@ 3.9.2 3.26.3 2.0.16 - 2.43.0 10.20.1 2.1.3 3.5.2 6.1.14 3.0.2 5.14.2 + + 2.43.0 + false + false false false false @@ -213,6 +216,7 @@ 3.5.0 true + ${enforcer.skip} @@ -394,6 +398,7 @@ spotless-maven-plugin ${spotless.version} + ${spotless.skip}