-
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
Changes from 3 commits
4fcdc09
cd0a5a2
4debc5f
8cdc57f
3ad4064
b28564b
7a63afb
d6b71fb
12d7d9e
b82f8ad
e392b76
f81f713
52e0000
7854810
4658b08
28cb2bf
d3fca62
e25768d
0237316
f76c171
2889881
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| name: Test Spring Boot RC Version | ||
| on: | ||
| pull_request: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - '.github/workflows/test-spring-boot-rc-version.yml' | ||
| - 'sdk/spring/scripts/generate_spring_versions_and_pr_description.py' | ||
| - 'sdk/spring/scripts/generate_spring_cloud_azure_support_file.py' | ||
| - 'sdk/spring/scripts/**' | ||
| workflow_dispatch: | ||
|
|
||
| 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 | ||
|
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" | ||
| echo "update_branch=update-spring-dependencies-$(date +%Y%m%d)-${GITHUB_RUN_ID}" | ||
| echo "spring_boot_version=${versions[0]}" | ||
| echo "spring_cloud_version=${versions[1]}" | ||
| echo "pr_descriptions=$(<pr-descriptions.txt)" | ||
| echo "PR_TITLE=Test Spring Boot RC version ${versions[0]} and Spring Cloud ${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 checkout -b "${{ env.update_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 }}" | ||
| sed -i "s/NONE_SUPPORTED_SPRING_CLOUD_VERSION/${spring_cloud_version}/g" ./sdk/spring/pipeline/spring-cloud-azure-supported-spring.json | ||
| git add ./sdk/spring/pipeline/spring-cloud-azure-supported-spring.json | ||
|
rujche marked this conversation as resolved.
|
||
| git commit -m "Upgrade spring-cloud-azure-supported-spring" | ||
|
rujche marked this conversation as resolved.
Outdated
|
||
| 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).\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}`; | ||
|
rujche marked this conversation as resolved.
Outdated
|
||
| 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' }} | ||
| 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' | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,154 @@ | ||
| name: Update Spring Cloud Azure Support File | ||
| on: | ||
| schedule: | ||
| - cron: '0 0 * * *' | ||
| pull_request: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - '.github/workflows/update-spring-cloud-azure-support-file.yml' | ||
| - 'sdk/spring/scripts/generate_spring_cloud_azure_support_file.py' | ||
| workflow_dispatch: | ||
|
|
||
| env: | ||
| PR_TITLE: "Update Spring Boot and Spring Cloud versions for the Spring compatibility tests" | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
| issues: write | ||
|
|
||
|
rujche marked this conversation as resolved.
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 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| - name: Generate Spring Cloud Azure Support File | ||
| run: | | ||
| python ./sdk/spring/scripts/generate_spring_cloud_azure_support_file.py | ||
| - name: Set Branch Name with Timestamp | ||
| run: | | ||
|
Check failure on line 58 in .github/workflows/update-spring-cloud-azure-support-file.yml
|
||
| 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}" >> $GITHUB_ENV | ||
|
|
||
| echo "COMMIT_MESSAGE<<EOF" >> $GITHUB_ENV | ||
| echo "${PR_TITLE}." >> $GITHUB_ENV | ||
| echo "This commit is created by GitHub Action: ${GITHUB_ACTION_URL}" >> $GITHUB_ENV | ||
| echo "EOF" >> $GITHUB_ENV | ||
|
|
||
| echo "PULL_REQUEST_BODY<<EOF" >> $GITHUB_ENV | ||
| echo "${PR_TITLE}." >> $GITHUB_ENV | ||
| echo "This commit is created by GitHub Action: ${GITHUB_ACTION_URL}" >> $GITHUB_ENV | ||
| echo "EOF" >> $GITHUB_ENV | ||
| - name: Make Decision Based on Git Diff | ||
| run: | | ||
| git checkout -b "${{ env.BRANCH_NAME }}" | ||
| if [[ -n "$(git status -s)" ]]; then | ||
| echo "NEED_UPDATE_FILE=true" >> $GITHUB_ENV | ||
| else | ||
| echo "No file changes, no commits." | ||
| fi | ||
|
rujche marked this conversation as resolved.
|
||
| - 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 "${{ env.COMMIT_MESSAGE }}" | ||
|
Copilot marked this conversation as resolved.
Outdated
|
||
| 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: 'main', | ||
| 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' | ||
| }); | ||
Uh oh!
There was an error while loading. Please reload this page.