chore: [DevOps] Update to Spring 7 and Spring Boot 4 #2614
This file contains hidden or 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: "Continuous Integration" | |
| on: | |
| pull_request: | |
| branches: [ "*" ] | |
| push: | |
| branches: [ "main" ] | |
| workflow_dispatch: # triggered by the prepare-release workflow | |
| env: | |
| MVN_MULTI_THREADED_ARGS: --batch-mode --no-transfer-progress --fail-at-end --show-version --threads 1C | |
| MVN_SKIP_CI_PLUGINS: -DskipFormatting -Denforcer.skip -Djacoco.skip -Dmdep.analyze.skip | |
| JAVA_VERSION: 17 | |
| # keep the following two variables in sync with our 'cache-maven-dependencies.yaml' workflow | |
| MAVEN_CACHE_KEY: maven-dependencies | |
| MAVEN_CACHE_DIR: ~/.m2 | |
| jobs: | |
| continuous-integration: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: "Checkout repository" | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 1 | |
| ref: ${{ github.event.pull_request.head.ref }} | |
| repository: ${{ github.event.pull_request.head.repo.full_name }} | |
| - name: "Setup java" | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: "sapmachine" | |
| java-version: ${{ env.JAVA_VERSION }} | |
| cache: 'maven' | |
| - name: "Restore Dependencies" | |
| id: restore-dependencies | |
| uses: actions/cache/restore@v4 | |
| with: | |
| key: ${{ env.MAVEN_CACHE_KEY }} | |
| path: ${{ env.MAVEN_CACHE_DIR }} | |
| - name: "REUSE Compliance Check" | |
| uses: fsfe/reuse-action@v6 | |
| - name: "Format code" | |
| run: | | |
| MVN_ARGS="${{ env.MVN_MULTI_THREADED_ARGS }} spotless:apply" | |
| mvn $MVN_ARGS | |
| - name: "Commit formatting changes if necessary" | |
| run: | | |
| diff=`git diff` | |
| if [ ! -z "$diff" ]; then | |
| git config --global user.email "cloudsdk@sap.com" | |
| git config --global user.name "SAP Cloud SDK Bot" | |
| git commit -am "Formatting" | |
| git push | |
| fi | |
| - name: "Build SDK" | |
| run: | | |
| MVN_ARGS="${{ env.MVN_MULTI_THREADED_ARGS }} clean install -Dgenerate -DskipTests -DskipFormatting" | |
| mvn $MVN_ARGS | |
| - name: "Verify Local Changes" | |
| run: | | |
| CHANGED_FILES="$(git --no-pager diff --name-only)" | |
| if [[ ! -z "$CHANGED_FILES" ]]; then | |
| echo "There are local changes in the following files:" | |
| echo "$CHANGED_FILES" | |
| echo "Printing the git diff:" | |
| git --no-pager diff | |
| exit 1 | |
| fi | |
| - name: "Run Unit Tests" | |
| run: | | |
| MVN_ARGS="${{ env.MVN_MULTI_THREADED_ARGS }} org.jacoco:jacoco-maven-plugin:prepare-agent surefire:test org.jacoco:jacoco-maven-plugin:report org.jacoco:jacoco-maven-plugin:check@default-check" | |
| mvn $MVN_ARGS | |
| - name: "Slack Notification" | |
| if: ${{ github.ref == 'refs/heads/main' && failure() }} | |
| uses: slackapi/slack-github-action@v2.1.1 | |
| with: | |
| webhook: ${{ secrets.SLACK_WEBHOOK }} | |
| webhook-type: incoming-webhook | |
| payload: | | |
| { | |
| "text": "🚨 Main Build Failed! 😬 Please inspect & fix by clicking <https://github.com/SAP/ai-sdk-java/actions/runs/${{ github.run_id }}|here>" | |
| } |