-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Migrate Spring update workflows to azure-sdk-for-java #49686
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rujche
wants to merge
21
commits into
main
Choose a base branch
from
rujche/main/move-some-github-actions-to-current-repo
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
4fcdc09
Migrate Spring update workflows to azure-sdk-for-java
rujche cd0a5a2
Enable PR path-based triggers for migrated workflows
rujche 4debc5f
Address PR review feedback for Spring workflow migration
rujche 8cdc57f
Fix Spring version source detection in generator
rujche 3ad4064
Fix shellcheck quoting in Spring workflows
rujche b28564b
Harden workflow triggers and version comparison
rujche 7a63afb
Run Spring update workflows from main ref
rujche d6b71fb
Fix Copilot review issues in Spring update automation
rujche 12d7d9e
Add Spring Initializr terms to cspell dictionary
rujche b82f8ad
Fix RC workflow checkout for branch dispatch
rujche e392b76
Fix update workflows for branch dispatch scripts
rujche f81f713
Add force-update test mode for RC workflow
rujche 52e0000
Harden PR body construction in Spring workflows
rujche 7854810
Remove RC workflow test inputs and adjust current spring baseline
rujche 4658b08
Revert temporary spring support matrix baseline
rujche 28cb2bf
Support configurable base branch in Spring workflows
rujche d3fca62
Run support-file generation after base checkout
rujche e25768d
Harden Spring workflow env handling and BOM selection
rujche 0237316
Preserve support matrix JSON spacing style
rujche f76c171
Fix RC target selection and support file robustness
rujche 2889881
Tighten workflow permissions and document legacy support
rujche File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,159 @@ | ||
| name: Test Spring Boot RC Version | ||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| base_branch: | ||
| description: 'Base branch for update branch and PR target. Defaults to trigger branch.' | ||
| required: false | ||
| type: string | ||
|
|
||
| env: | ||
| BASE_BRANCH: ${{ github.event.inputs.base_branch || github.ref_name }} | ||
|
|
||
| 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 --prefer-prerelease | ||
| - name: Generate Spring Cloud Azure Support File | ||
| run: | | ||
| python ./sdk/spring/scripts/generate_spring_cloud_azure_support_file.py --include-rc | ||
|
Comment on lines
+29
to
+31
|
||
| - name: Confirm Whether to Update | ||
| run: | | ||
| if [[ ! -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_TITLE=Test Spring Boot RC version %s and Spring Cloud %s\n' "${versions[0]}" "${versions[1]}" | ||
| echo 'pr_descriptions<<EOF' | ||
| cat pr-descriptions.txt | ||
| echo 'EOF' | ||
| } >> "$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 "${{ env.BASE_BRANCH }}" | ||
| git checkout -B "${{ env.update_branch }}" "origin/${{ env.BASE_BRANCH }}" | ||
| 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' }} | ||
| 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: | ||
| print( | ||
| "No RC support-matrix placeholder entry found; " | ||
| "skipping support-file patch as a no-op." | ||
| ) | ||
| raise SystemExit(0) | ||
|
|
||
| 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 | ||
| if [[ -n "$(git diff --cached -- ./sdk/spring/pipeline/spring-cloud-azure-supported-spring.json)" ]]; then | ||
| git commit -m "Upgrade spring-cloud-azure-supported-spring" | ||
| else | ||
| echo "No support matrix changes detected, skip commit." | ||
| fi | ||
| git push origin "HEAD:${{ env.update_branch }}" | ||
| - name: Create Pull Request | ||
| id: create_pr | ||
| if: ${{ env.need_update_version == '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).`, | ||
| process.env.pr_descriptions || '', | ||
| '', | ||
| `This PR is created by GitHub Actions: https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${process.env.GITHUB_RUN_ID}` | ||
| ].join('\n'); | ||
| 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: process.env.BASE_BRANCH, | ||
| body, | ||
| draft: true | ||
| }); | ||
| core.setOutput('pull_request_number', String(pr.data.number)); | ||
| - name: Comment on Pull Request | ||
| if: ${{ env.need_update_version == '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' | ||
| }); | ||
157 changes: 157 additions & 0 deletions
157
.github/workflows/update-spring-cloud-azure-support-file.yml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,157 @@ | ||
| name: Update Spring Cloud Azure Support File | ||
| on: | ||
| schedule: | ||
| - cron: '0 0 * * *' | ||
| workflow_dispatch: | ||
| inputs: | ||
| base_branch: | ||
| description: 'Base branch for update branch and PR target. Defaults to trigger branch.' | ||
| required: false | ||
| type: string | ||
|
|
||
| env: | ||
| BASE_BRANCH: ${{ github.event.inputs.base_branch || github.ref_name }} | ||
| PR_TITLE: "Update Spring Boot and Spring Cloud versions for the Spring compatibility tests" | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: read | ||
| issues: read | ||
|
|
||
|
rujche marked this conversation as resolved.
|
||
| jobs: | ||
| check-open-pr: | ||
| name: Check Open Pull Request | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| has_open_pr: ${{ steps.check.outputs.has_open_pr }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Check for Existing Open Pull Request | ||
| id: check | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const prTitle = process.env.PR_TITLE; | ||
| const pullRequests = await github.paginate(github.rest.pulls.list, { | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| state: 'open', | ||
| per_page: 100 | ||
| }); | ||
|
|
||
| const openPRs = pullRequests.filter(pr => pr.title === prTitle); | ||
| core.setOutput('has_open_pr', openPRs.length > 0 ? 'true' : 'false'); | ||
|
|
||
| update: | ||
| name: Update Support File and Create PR | ||
| needs: check-open-pr | ||
| if: ${{ needs.check-open-pr.outputs.has_open_pr == 'false' }} | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
| issues: write | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| - name: Set Branch Name with Timestamp | ||
| run: | | ||
| TIMESTAMP=$(date +%Y%m%d-%H%M%S) | ||
| GITHUB_ACTION_URL="https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}" | ||
|
|
||
| { | ||
| echo "BRANCH_NAME=update-spring-cloud-azure-support-file-${TIMESTAMP}" | ||
| echo "COMMIT_MESSAGE<<EOF" | ||
| echo "${PR_TITLE}." | ||
| echo "This commit is created by GitHub Action: ${GITHUB_ACTION_URL}" | ||
| echo "EOF" | ||
| echo "PULL_REQUEST_BODY<<EOF" | ||
| echo "${PR_TITLE}." | ||
| echo "This commit is created by GitHub Action: ${GITHUB_ACTION_URL}" | ||
| echo "EOF" | ||
| } >> "$GITHUB_ENV" | ||
| - name: Make Decision Based on Git Diff | ||
| run: | | ||
| git fetch origin "${{ env.BASE_BRANCH }}" | ||
| git checkout -B "${{ env.BRANCH_NAME }}" "origin/${{ env.BASE_BRANCH }}" | ||
| python ./sdk/spring/scripts/generate_spring_cloud_azure_support_file.py | ||
| if [[ -n "$(git status -s)" ]]; then | ||
| echo "NEED_UPDATE_FILE=true" >> "$GITHUB_ENV" | ||
| else | ||
| echo "No file changes, no commits." | ||
| fi | ||
| - name: Update Spring Cloud Azure Timeline | ||
| if: ${{ env.NEED_UPDATE_FILE == 'true' }} | ||
| run: | | ||
| TODAY=$(date +%Y-%m-%d) | ||
| TIMELINE_FILE=docs/spring/Spring-Cloud-Azure-Timeline.md | ||
| SUPPORT_FILE=sdk/spring/pipeline/spring-cloud-azure-supported-spring.json | ||
|
|
||
| OLD_4X=$(git show "HEAD:${SUPPORT_FILE}" | jq -Sc '[.[] | select(."spring-boot-version" | startswith("4."))] | sort_by([."spring-boot-version", ."spring-cloud-version", .supportStatus, .current])') | ||
| NEW_4X=$(jq -Sc '[.[] | select(."spring-boot-version" | startswith("4."))] | sort_by([."spring-boot-version", ."spring-cloud-version", .supportStatus, .current])' "${SUPPORT_FILE}") | ||
|
|
||
| if [[ "${OLD_4X}" == "${NEW_4X}" ]]; then | ||
| echo "No Spring Boot 4.x changes detected, skip timeline update." | ||
| exit 0 | ||
| fi | ||
|
|
||
| SUPPORTED_LINES=$(jq -r ' | ||
| .[] | ||
| | select(.supportStatus == "SUPPORTED") | ||
| | select(.["spring-boot-version"] | startswith("4.")) | ||
| | " - spring-boot-dependencies:\(.["spring-boot-version"]) and spring-cloud-dependencies:\(.["spring-cloud-version"])." | ||
| ' "${SUPPORT_FILE}") | ||
|
|
||
| if [[ -z "${SUPPORTED_LINES}" ]]; then | ||
| echo "No supported Spring Boot 4.x entries found, skip timeline update." | ||
| exit 0 | ||
| fi | ||
|
|
||
| NEW_ENTRY=$(printf ' - **%s**: In "java - spring - compatibility - tests" pipeline, run unit tests:\n%s' "$TODAY" "$SUPPORTED_LINES") | ||
| awk -v entry="$NEW_ENTRY" ' | ||
| { print } | ||
| /^## Timeline$/ && !inserted { print entry; inserted=1 } | ||
| ' "$TIMELINE_FILE" > "$TIMELINE_FILE.tmp" | ||
| mv "$TIMELINE_FILE.tmp" "$TIMELINE_FILE" | ||
| - name: Push Commit | ||
| if: ${{ env.NEED_UPDATE_FILE == 'true' }} | ||
| run: | | ||
| git config --global user.email github-actions@github.com | ||
| git config --global user.name github-actions | ||
| git add sdk/spring/pipeline/spring-cloud-azure-supported-spring.json | ||
| git add docs/spring/Spring-Cloud-Azure-Timeline.md | ||
| git commit -m "$COMMIT_MESSAGE" | ||
| git push origin "${{ env.BRANCH_NAME }}" | ||
| - name: Create Pull Request | ||
| id: create_pr | ||
| if: ${{ env.NEED_UPDATE_FILE == 'true' }} | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const pr = await github.rest.pulls.create({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| title: process.env.PR_TITLE, | ||
| head: process.env.BRANCH_NAME, | ||
| base: process.env.BASE_BRANCH, | ||
| body: process.env.PULL_REQUEST_BODY | ||
| }); | ||
| core.setOutput('pull_request_number', String(pr.data.number)); | ||
| - name: Comment on Pull Request | ||
| if: ${{ env.NEED_UPDATE_FILE == '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' | ||
| }); | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.