Test Spring Boot RC Version #7
Workflow file for this run
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: Test Spring Boot RC Version | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| force_update: | |
| description: 'Force the update flow for testing even when no RC is detected' | |
| required: false | |
| type: boolean | |
| default: false | |
| dry_run: | |
| description: 'Run update steps but skip push/create PR/comment side effects' | |
| required: false | |
| type: boolean | |
| default: true | |
| spring_boot_version: | |
| description: 'Optional override Spring Boot version when force_update is true' | |
| required: false | |
| type: string | |
| spring_cloud_version: | |
| description: 'Optional override Spring Cloud version when force_update is true' | |
| required: false | |
| type: string | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| issues: write | |
| jobs: | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Generate Version File | |
| run: | | |
| python ./sdk/spring/scripts/generate_spring_versions_and_pr_description.py | |
| - name: Generate Spring Cloud Azure Support File | |
| run: | | |
| python ./sdk/spring/scripts/generate_spring_cloud_azure_support_file.py --include-rc | |
| - name: Confirm Whether to Update | |
| run: | | |
| FORCE_UPDATE="${{ github.event.inputs.force_update }}" | |
| MANUAL_BOOT="${{ github.event.inputs.spring_boot_version }}" | |
| MANUAL_CLOUD="${{ github.event.inputs.spring_cloud_version }}" | |
| if [[ "${FORCE_UPDATE}" == 'true' ]]; then | |
| echo "Force update enabled for workflow testing." | |
| if [[ -n "${MANUAL_BOOT}" && -n "${MANUAL_CLOUD}" ]]; then | |
| TARGET_BOOT="${MANUAL_BOOT}" | |
| TARGET_CLOUD="${MANUAL_CLOUD}" | |
| elif [[ -f 'spring-versions.txt' ]]; then | |
| mapfile -t versions < spring-versions.txt | |
| TARGET_BOOT="${versions[0]}" | |
| TARGET_CLOUD="${versions[1]}" | |
| else | |
| echo "force_update=true requires spring-versions.txt or both manual version inputs." | |
| exit 1 | |
| fi | |
| PR_NOTES="" | |
| if [[ -f 'pr-descriptions.txt' ]]; then | |
| PR_NOTES="$(<pr-descriptions.txt)" | |
| fi | |
| { | |
| echo "need_update_version=true" | |
| printf 'update_branch=update-spring-dependencies-%s-%s\n' "$(date +%Y%m%d)" "${GITHUB_RUN_ID}" | |
| printf 'spring_boot_version=%s\n' "${TARGET_BOOT}" | |
| printf 'spring_cloud_version=%s\n' "${TARGET_CLOUD}" | |
| printf 'pr_descriptions=%s\n' "${PR_NOTES}" | |
| printf 'PR_TITLE=Test Spring Boot RC version %s and Spring Cloud %s\n' "${TARGET_BOOT}" "${TARGET_CLOUD}" | |
| } >> "$GITHUB_ENV" | |
| elif [[ ! -f 'spring-versions.txt' ]]; then | |
| echo "No new Spring Boot version, no updates!" | |
| elif grep -q -- "-RC" spring-versions.txt; then | |
| echo "Has RC version, create PR to test!" | |
| mapfile -t versions < spring-versions.txt | |
| { | |
| echo "need_update_version=true" | |
| printf 'update_branch=update-spring-dependencies-%s-%s\n' "$(date +%Y%m%d)" "${GITHUB_RUN_ID}" | |
| printf 'spring_boot_version=%s\n' "${versions[0]}" | |
| printf 'spring_cloud_version=%s\n' "${versions[1]}" | |
| printf 'pr_descriptions=%s\n' "$(<pr-descriptions.txt)" | |
| printf 'PR_TITLE=Test Spring Boot RC version %s and Spring Cloud %s\n' "${versions[0]}" "${versions[1]}" | |
| } >> "$GITHUB_ENV" | |
| else | |
| echo "No RC version, cancel update!" | |
| fi | |
| - name: Generate spring_boot_managed_external_dependencies.txt | |
| if: ${{ env.need_update_version == 'true' }} | |
| run: | | |
| echo "Updating Spring Boot Dependencies Version: ${{ env.spring_boot_version }}" | |
| echo "Updating Spring Cloud Dependencies Version: ${{ env.spring_cloud_version }}" | |
| git fetch origin main | |
| git checkout -B "${{ env.update_branch }}" origin/main | |
| pip install termcolor | |
| python ./sdk/spring/scripts/get_spring_boot_managed_external_dependencies.py -b "${{ env.spring_boot_version }}" -c "${{ env.spring_cloud_version }}" | |
| - name: Update external_dependencies.txt | |
| if: ${{ env.need_update_version == 'true' }} | |
| run: | | |
| pip install termcolor | |
| pip install in_place | |
| python ./sdk/spring/scripts/sync_external_dependencies.py -b "${{ env.spring_boot_version }}" -sbmvn 4 | |
| - name: Update Versions | |
| if: ${{ env.need_update_version == 'true' }} | |
| run: | | |
| python ./eng/versioning/update_versions.py --sr | |
| - name: Update ChangeLog | |
| if: ${{ env.need_update_version == 'true' }} | |
| run: | | |
| python ./sdk/spring/scripts/update_changelog.py -b "${{ env.spring_boot_version }}" -c "${{ env.spring_cloud_version }}" | |
| - name: Push Commit | |
| if: ${{ env.need_update_version == 'true' && github.event.inputs.dry_run != 'true' }} | |
| run: | | |
| git config --global user.email github-actions@github.com | |
| git config --global user.name github-actions | |
| git add -A | |
| git commit -m "Upgrade external dependencies to align with Spring Boot ${{ env.spring_boot_version }}" | |
| python - <<'PY' | |
| import json | |
| from pathlib import Path | |
| spring_boot_version = "${{ env.spring_boot_version }}" | |
| spring_cloud_version = "${{ env.spring_cloud_version }}" | |
| placeholder = "NONE_SUPPORTED_SPRING_CLOUD_VERSION" | |
| matrix_path = Path("./sdk/spring/pipeline/spring-cloud-azure-supported-spring.json") | |
| with matrix_path.open("r", encoding="utf-8") as f: | |
| entries = json.load(f) | |
| updated = False | |
| for entry in entries: | |
| if ( | |
| entry.get("spring-boot-version") == spring_boot_version | |
| and entry.get("spring-cloud-version") == placeholder | |
| ): | |
| entry["spring-cloud-version"] = spring_cloud_version | |
| updated = True | |
| break | |
| if not updated: | |
| raise SystemExit( | |
| "Did not find RC support-matrix entry for " | |
| f"spring-boot-version={spring_boot_version} with placeholder cloud version" | |
| ) | |
| with matrix_path.open("w", encoding="utf-8") as f: | |
| json.dump(entries, f, indent=2) | |
| f.write("\n") | |
| PY | |
| git add ./sdk/spring/pipeline/spring-cloud-azure-supported-spring.json | |
| git commit -m "Upgrade spring-cloud-azure-supported-spring" | |
| git push origin "HEAD:${{ env.update_branch }}" | |
| - name: Create Pull Request | |
| id: create_pr | |
| if: ${{ env.need_update_version == 'true' && github.event.inputs.dry_run != 'true' }} | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const body = `Test Spring Boot RC version [${process.env.spring_boot_version}](https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-dependencies/${process.env.spring_boot_version}/spring-boot-dependencies-${process.env.spring_boot_version}.pom) and Spring Cloud version [${process.env.spring_cloud_version}](https://repo1.maven.org/maven2/org/springframework/cloud/spring-cloud-dependencies/${process.env.spring_cloud_version}/spring-cloud-dependencies-${process.env.spring_cloud_version}.pom).\n${process.env.pr_descriptions}\n\nThis PR is created by GitHub Actions: https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${process.env.GITHUB_RUN_ID}`; | |
| const pr = await github.rest.pulls.create({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| title: process.env.PR_TITLE, | |
| head: process.env.update_branch, | |
| base: 'main', | |
| body, | |
| draft: true | |
| }); | |
| core.setOutput('pull_request_number', String(pr.data.number)); | |
| - name: Comment on Pull Request | |
| if: ${{ env.need_update_version == 'true' && github.event.inputs.dry_run != 'true' }} | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const prNumber = Number('${{ steps.create_pr.outputs.pull_request_number }}'); | |
| if (!prNumber) { | |
| console.log('No pull request was created, nothing to comment on.'); | |
| return; | |
| } | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: prNumber, | |
| body: '/azp run java - spring - tests' | |
| }); | |
| - name: Dry Run Summary | |
| if: ${{ env.need_update_version == 'true' && github.event.inputs.dry_run == 'true' }} | |
| run: | | |
| echo "Dry run mode: update steps executed, push/PR/comment were intentionally skipped." |