Skip to content

Commit 4fcdc09

Browse files
committed
Migrate Spring update workflows to azure-sdk-for-java
1 parent ce81a71 commit 4fcdc09

5 files changed

Lines changed: 794 additions & 0 deletions
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: Test Spring Boot RC Version
2+
on:
3+
workflow_dispatch:
4+
5+
permissions:
6+
contents: write
7+
pull-requests: write
8+
issues: write
9+
10+
jobs:
11+
build:
12+
name: Build
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
- name: Generate Version File
19+
run: |
20+
python ./sdk/spring/scripts/generate_spring_versions_and_pr_description.py
21+
- name: Generate Spring Cloud Azure Support File
22+
run: |
23+
python ./sdk/spring/scripts/generate_spring_cloud_azure_support_file.py --include-rc
24+
- name: Confirm Whether to Update
25+
run: |
26+
if [[ ! -f 'spring-versions.txt' ]]; then
27+
echo "No new Spring Boot version, no updates!"
28+
elif grep -q -- "-RC" spring-versions.txt; then
29+
echo "Has RC version, create PR to test!"
30+
mapfile -t versions < spring-versions.txt
31+
{
32+
echo "need_update_version=true"
33+
echo "update_branch=update-spring-dependencies-$(date +%Y%m%d)-${GITHUB_RUN_ID}"
34+
echo "spring_boot_version=${versions[0]}"
35+
echo "spring_cloud_version=${versions[1]}"
36+
echo "pr_descriptions=$(<pr-descriptions.txt)"
37+
echo "PR_TITLE=Test Spring Boot RC version ${versions[0]} and Spring Cloud ${versions[1]}"
38+
} >> $GITHUB_ENV
39+
else
40+
echo "No RC version, cancel update!"
41+
fi
42+
- name: Generate spring_boot_managed_external_dependencies.txt
43+
if: ${{ env.need_update_version == 'true' }}
44+
run: |
45+
echo Updating Spring Boot Dependencies Version: ${{ env.spring_boot_version }}
46+
echo Updating Spring Cloud Dependencies Version: ${{ env.spring_cloud_version }}
47+
git checkout -b "${{ env.update_branch }}"
48+
pip install termcolor
49+
python ./sdk/spring/scripts/get_spring_boot_managed_external_dependencies.py -b ${{ env.spring_boot_version }} -c ${{ env.spring_cloud_version }}
50+
- name: Update external_dependencies.txt
51+
if: ${{ env.need_update_version == 'true' }}
52+
run: |
53+
pip install termcolor
54+
pip install in_place
55+
python ./sdk/spring/scripts/sync_external_dependencies.py -b ${{ env.spring_boot_version }} -sbmvn 4
56+
- name: Update Versions
57+
if: ${{ env.need_update_version == 'true' }}
58+
run: |
59+
python ./eng/versioning/update_versions.py --sr
60+
- name: Update ChangeLog
61+
if: ${{ env.need_update_version == 'true' }}
62+
run: |
63+
python ./sdk/spring/scripts/update_changelog.py -b ${{ env.spring_boot_version }} -c ${{ env.spring_cloud_version }}
64+
- name: Push Commit
65+
if: ${{ env.need_update_version == 'true' }}
66+
run: |
67+
git config --global user.email github-actions@github.com
68+
git config --global user.name github-actions
69+
git add -A
70+
git commit -m "Upgrade external dependencies to align with Spring Boot ${{ env.spring_boot_version }}"
71+
sed -i "s/NONE_SUPPORTED_SPRING_CLOUD_VERSION/${spring_cloud_version}/g" ./sdk/spring/pipeline/spring-cloud-azure-supported-spring.json
72+
git add ./sdk/spring/pipeline/spring-cloud-azure-supported-spring.json
73+
git commit -m "Upgrade spring-cloud-azure-supported-spring"
74+
git push origin "HEAD:${{ env.update_branch }}"
75+
- name: Create Pull Request
76+
id: create_pr
77+
if: ${{ env.need_update_version == 'true' }}
78+
uses: actions/github-script@v7
79+
with:
80+
script: |
81+
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}`;
82+
const pr = await github.rest.pulls.create({
83+
owner: context.repo.owner,
84+
repo: context.repo.repo,
85+
title: process.env.PR_TITLE,
86+
head: process.env.update_branch,
87+
base: 'main',
88+
body,
89+
draft: true
90+
});
91+
core.setOutput('pull_request_number', String(pr.data.number));
92+
- name: Comment on Pull Request
93+
if: ${{ env.need_update_version == 'true' }}
94+
uses: actions/github-script@v7
95+
with:
96+
script: |
97+
const prNumber = Number('${{ steps.create_pr.outputs.pull_request_number }}');
98+
if (!prNumber) {
99+
console.log('No pull request was created, nothing to comment on.');
100+
return;
101+
}
102+
await github.rest.issues.createComment({
103+
owner: context.repo.owner,
104+
repo: context.repo.repo,
105+
issue_number: prNumber,
106+
body: '/azp run java - spring - tests'
107+
});
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
name: Update Spring Cloud Azure Support File
2+
on:
3+
schedule:
4+
- cron: '0 0 * * *'
5+
workflow_dispatch:
6+
7+
env:
8+
PR_TITLE: "Update Spring Boot and Spring Cloud versions for the Spring compatibility tests"
9+
10+
permissions:
11+
contents: write
12+
pull-requests: write
13+
issues: write
14+
15+
jobs:
16+
check-open-pr:
17+
name: Check Open Pull Request
18+
runs-on: ubuntu-latest
19+
outputs:
20+
has_open_pr: ${{ steps.check.outputs.has_open_pr }}
21+
steps:
22+
- uses: actions/checkout@v4
23+
- name: Check for Existing Open Pull Request
24+
id: check
25+
uses: actions/github-script@v7
26+
with:
27+
script: |
28+
const prTitle = process.env.PR_TITLE;
29+
const { data: pullRequests } = await github.rest.pulls.list({
30+
owner: context.repo.owner,
31+
repo: context.repo.repo,
32+
state: 'open'
33+
});
34+
35+
const openPRs = pullRequests.filter(pr => pr.title === prTitle);
36+
core.setOutput('has_open_pr', openPRs.length > 0 ? 'true' : 'false');
37+
38+
update:
39+
name: Update Support File and Create PR
40+
needs: check-open-pr
41+
if: ${{ needs.check-open-pr.outputs.has_open_pr == 'false' }}
42+
runs-on: ubuntu-latest
43+
steps:
44+
- uses: actions/checkout@v4
45+
with:
46+
fetch-depth: 0
47+
- name: Generate Spring Cloud Azure Support File
48+
run: |
49+
python ./sdk/spring/scripts/generate_spring_cloud_azure_support_file.py
50+
- name: Set Branch Name with Timestamp
51+
run: |
52+
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
53+
GITHUB_ACTION_URL="https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}"
54+
55+
echo "BRANCH_NAME=update-spring-cloud-azure-support-file-${TIMESTAMP}" >> $GITHUB_ENV
56+
57+
echo "COMMIT_MESSAGE<<EOF" >> $GITHUB_ENV
58+
echo "${PR_TITLE}." >> $GITHUB_ENV
59+
echo "This commit is created by GitHub Action: ${GITHUB_ACTION_URL}" >> $GITHUB_ENV
60+
echo "EOF" >> $GITHUB_ENV
61+
62+
echo "PULL_REQUEST_BODY<<EOF" >> $GITHUB_ENV
63+
echo "${PR_TITLE}." >> $GITHUB_ENV
64+
echo "This commit is created by GitHub Action: ${GITHUB_ACTION_URL}" >> $GITHUB_ENV
65+
echo "EOF" >> $GITHUB_ENV
66+
- name: Make Decision Based on Git Diff
67+
run: |
68+
git checkout -b "${{ env.BRANCH_NAME }}"
69+
if [[ -n "$(git status -s)" ]]; then
70+
echo "NEED_UPDATE_FILE=true" >> $GITHUB_ENV
71+
else
72+
echo "No file changes, no commits."
73+
fi
74+
- name: Update Spring Cloud Azure Timeline
75+
if: ${{ env.NEED_UPDATE_FILE == 'true' }}
76+
run: |
77+
TODAY=$(date +%Y-%m-%d)
78+
TIMELINE_FILE=docs/spring/Spring-Cloud-Azure-Timeline.md
79+
SUPPORT_FILE=sdk/spring/pipeline/spring-cloud-azure-supported-spring.json
80+
81+
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])')
82+
NEW_4X=$(jq -Sc '[.[] | select(."spring-boot-version" | startswith("4."))] | sort_by([."spring-boot-version", ."spring-cloud-version", .supportStatus, .current])' "${SUPPORT_FILE}")
83+
84+
if [[ "${OLD_4X}" == "${NEW_4X}" ]]; then
85+
echo "No Spring Boot 4.x changes detected, skip timeline update."
86+
exit 0
87+
fi
88+
89+
SUPPORTED_LINES=$(jq -r '
90+
.[]
91+
| select(.supportStatus == "SUPPORTED")
92+
| select(.["spring-boot-version"] | startswith("4."))
93+
| " - spring-boot-dependencies:\(.["spring-boot-version"]) and spring-cloud-dependencies:\(.["spring-cloud-version"])."
94+
' "${SUPPORT_FILE}")
95+
96+
if [[ -z "${SUPPORTED_LINES}" ]]; then
97+
echo "No supported Spring Boot 4.x entries found, skip timeline update."
98+
exit 0
99+
fi
100+
101+
NEW_ENTRY=$(printf ' - **%s**: In "java - spring - compatibility - tests" pipeline, run unit tests:\n%s' "$TODAY" "$SUPPORTED_LINES")
102+
awk -v entry="$NEW_ENTRY" '
103+
{ print }
104+
/^## Timeline$/ && !inserted { print entry; inserted=1 }
105+
' "$TIMELINE_FILE" > "$TIMELINE_FILE.tmp"
106+
mv "$TIMELINE_FILE.tmp" "$TIMELINE_FILE"
107+
- name: Push Commit
108+
if: ${{ env.NEED_UPDATE_FILE == 'true' }}
109+
run: |
110+
git config --global user.email github-actions@github.com
111+
git config --global user.name github-actions
112+
git add sdk/spring/pipeline/spring-cloud-azure-supported-spring.json
113+
git add docs/spring/Spring-Cloud-Azure-Timeline.md
114+
git commit -m "${{ env.COMMIT_MESSAGE }}"
115+
git push origin "${{ env.BRANCH_NAME }}"
116+
- name: Create Pull Request
117+
id: create_pr
118+
if: ${{ env.NEED_UPDATE_FILE == 'true' }}
119+
uses: actions/github-script@v7
120+
with:
121+
script: |
122+
const pr = await github.rest.pulls.create({
123+
owner: context.repo.owner,
124+
repo: context.repo.repo,
125+
title: process.env.PR_TITLE,
126+
head: process.env.BRANCH_NAME,
127+
base: 'main',
128+
body: process.env.PULL_REQUEST_BODY
129+
});
130+
core.setOutput('pull_request_number', String(pr.data.number));
131+
- name: Comment on Pull Request
132+
if: ${{ env.NEED_UPDATE_FILE == 'true' }}
133+
uses: actions/github-script@v7
134+
with:
135+
script: |
136+
const prNumber = Number('${{ steps.create_pr.outputs.pull_request_number }}');
137+
if (!prNumber) {
138+
console.log('No pull request was created, nothing to comment on.');
139+
return;
140+
}
141+
142+
await github.rest.issues.createComment({
143+
owner: context.repo.owner,
144+
repo: context.repo.repo,
145+
issue_number: prNumber,
146+
body: '/azp run java - spring - tests'
147+
});
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
name: Update Spring Dependencies
2+
on:
3+
schedule:
4+
- cron: '0 0 * * *'
5+
workflow_dispatch:
6+
7+
env:
8+
PR_TITLE_PREFIX: 'External dependencies upgrade - Spring Boot'
9+
10+
permissions:
11+
contents: write
12+
pull-requests: write
13+
issues: write
14+
15+
jobs:
16+
check:
17+
name: Check for Open Spring Boot Upgrade PRs
18+
runs-on: ubuntu-latest
19+
outputs:
20+
skip_pipeline: ${{ steps.check_prs.outputs.skip_pipeline }}
21+
steps:
22+
- uses: actions/checkout@v4
23+
- name: Check for Open Spring Boot Upgrade PRs
24+
id: check_prs
25+
uses: actions/github-script@v7
26+
with:
27+
script: |
28+
const prTitlePrefix = process.env.PR_TITLE_PREFIX;
29+
const { data: pullRequests } = await github.rest.pulls.list({
30+
owner: context.repo.owner,
31+
repo: context.repo.repo,
32+
state: 'open',
33+
per_page: 100
34+
});
35+
36+
const openPRs = pullRequests.filter(pr => pr.title.startsWith(prTitlePrefix));
37+
core.setOutput('skip_pipeline', openPRs.length > 0 ? 'true' : 'false');
38+
39+
update:
40+
name: Update Dependencies and Create PR
41+
runs-on: ubuntu-latest
42+
needs: check
43+
if: ${{ needs.check.outputs.skip_pipeline != 'true' }}
44+
steps:
45+
- uses: actions/checkout@v4
46+
with:
47+
fetch-depth: 0
48+
- name: Generate Version File
49+
run: |
50+
python ./sdk/spring/scripts/generate_spring_versions_and_pr_description.py
51+
- name: Confirm Whether to Update
52+
run: |
53+
if [[ ! -f 'spring-versions.txt' ]]; then
54+
echo "No new Spring Boot version, no updates."
55+
elif grep -q -- '-' spring-versions.txt; then
56+
echo "Has non-GA version, cancel update!"
57+
else
58+
echo "need_update_version=true" >> $GITHUB_ENV
59+
echo "update_branch=update-spring-dependencies-$(date +%Y%m%d)-${GITHUB_RUN_ID}" >> $GITHUB_ENV
60+
echo "spring_boot_version=$(sed -n '1p' spring-versions.txt)" >> $GITHUB_ENV
61+
echo "spring_cloud_version=$(sed -n '2p' spring-versions.txt)" >> $GITHUB_ENV
62+
echo "last_spring_boot_version=$(sed -n '3p' spring-versions.txt)" >> $GITHUB_ENV
63+
echo "last_spring_cloud_version=$(sed -n '4p' spring-versions.txt)" >> $GITHUB_ENV
64+
echo "pr_descriptions=$(cat pr-descriptions.txt)" >> $GITHUB_ENV
65+
echo "PR_TITLE=${PR_TITLE_PREFIX} $(sed -n '1p' spring-versions.txt) and Spring Cloud $(sed -n '2p' spring-versions.txt)" >> $GITHUB_ENV
66+
fi
67+
- name: Generate spring_boot_managed_external_dependencies.txt
68+
if: ${{ env.need_update_version == 'true' }}
69+
run: |
70+
echo Updating Spring Boot Dependencies Version: ${{ env.spring_boot_version }}
71+
echo Updating Spring Cloud Dependencies Version: ${{ env.spring_cloud_version }}
72+
git checkout -b "${{ env.update_branch }}"
73+
pip install termcolor
74+
python ./sdk/spring/scripts/get_spring_boot_managed_external_dependencies.py -b ${{ env.spring_boot_version }} -c ${{ env.spring_cloud_version }}
75+
- name: Update external_dependencies.txt
76+
if: ${{ env.need_update_version == 'true' }}
77+
run: |
78+
pip install termcolor
79+
pip install in_place
80+
python ./sdk/spring/scripts/sync_external_dependencies.py -b ${{ env.spring_boot_version }} -sbmvn 4
81+
- name: Update Versions
82+
if: ${{ env.need_update_version == 'true' }}
83+
run: |
84+
python ./eng/versioning/update_versions.py --sr
85+
- name: Update ChangeLog
86+
if: ${{ env.need_update_version == 'true' }}
87+
run: |
88+
python ./sdk/spring/scripts/update_changelog.py -b ${{ env.spring_boot_version }} -c ${{ env.spring_cloud_version }}
89+
- name: Push Commit
90+
if: ${{ env.need_update_version == 'true' }}
91+
run: |
92+
git config --global user.email github-actions@github.com
93+
git config --global user.name github-actions
94+
git rm ./sdk/spring/scripts/spring_boot_${{ env.last_spring_boot_version }}_managed_external_dependencies.txt || true
95+
git add -A
96+
git commit -m "Upgrade external dependencies to align with Spring Boot ${{ env.spring_boot_version }}"
97+
git push origin "HEAD:${{ env.update_branch }}"
98+
- name: Create Pull Request
99+
id: create_pr
100+
if: ${{ env.need_update_version == 'true' }}
101+
uses: actions/github-script@v7
102+
with:
103+
script: |
104+
const body = `Updates external dependencies to align with Spring Boot 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) from [${process.env.last_spring_boot_version}](https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-dependencies/${process.env.last_spring_boot_version}/spring-boot-dependencies-${process.env.last_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) from [${process.env.last_spring_cloud_version}](https://repo1.maven.org/maven2/org/springframework/cloud/spring-cloud-dependencies/${process.env.last_spring_cloud_version}/spring-cloud-dependencies-${process.env.last_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}`;
105+
const pr = await github.rest.pulls.create({
106+
owner: context.repo.owner,
107+
repo: context.repo.repo,
108+
title: process.env.PR_TITLE,
109+
head: process.env.update_branch,
110+
base: 'main',
111+
body,
112+
draft: false
113+
});
114+
core.setOutput('pull_request_number', String(pr.data.number));
115+
- name: Comment on Pull Request
116+
if: ${{ env.need_update_version == 'true' }}
117+
uses: actions/github-script@v7
118+
with:
119+
script: |
120+
const prNumber = Number('${{ steps.create_pr.outputs.pull_request_number }}');
121+
if (!prNumber) {
122+
console.log('No pull request was created, nothing to comment on.');
123+
return;
124+
}
125+
await github.rest.issues.createComment({
126+
owner: context.repo.owner,
127+
repo: context.repo.repo,
128+
issue_number: prNumber,
129+
body: '/azp run java - spring - tests'
130+
});

0 commit comments

Comments
 (0)