Skip to content

Commit 0df564e

Browse files
authored
Merge pull request #108 from precog/task/202510-update-deps
Update dependencies to latest versions
2 parents ee0e891 + ccb9fb4 commit 0df564e

File tree

8 files changed

+223
-134
lines changed

8 files changed

+223
-134
lines changed

.github/workflows/ci.yml

Lines changed: 187 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -24,31 +24,115 @@ env:
2424
jobs:
2525
build:
2626
name: Build and Test
27-
if: '!(github.event_name == ''pull_request'' && github.event.pull_request.draft) && !(github.event_name == ''push'' && (github.ref == ''refs/heads/main'' || github.ref == ''refs/heads/master'') && !startsWith(github.event.head_commit.message, ''Version release''))'
27+
if: '!(github.event_name == ''pull_request'' && github.event.pull_request.draft)'
2828
strategy:
2929
matrix:
3030
os: [ubuntu-latest]
31-
scala: [2.13.11]
31+
scala: [2.13.16]
3232
java: [temurin@17]
3333
runs-on: ${{ matrix.os }}
3434
steps:
3535
- name: Checkout current branch (full)
36-
uses: actions/checkout@v3
36+
uses: actions/checkout@v4
3737
with:
3838
fetch-depth: 0
3939

4040
- name: Setup Java (temurin@17)
4141
if: matrix.java == 'temurin@17'
42-
uses: actions/setup-java@v3
42+
uses: actions/setup-java@v4
4343
with:
4444
distribution: temurin
4545
java-version: 17
4646
cache: sbt
4747

48+
- name: Setup sbt
49+
uses: sbt/setup-sbt@v1
50+
4851
- name: Common sbt setup
4952
if: env.ENCRYPTION_PASSWORD != null
5053
run: $SBT '++ ${{ matrix.scala }}' transferCommonResources
5154

55+
- name: Fetch base
56+
if: github.event_name == 'pull_request'
57+
run: git fetch origin ${{github.event.pull_request.base.ref}}
58+
59+
- name: Get current version
60+
id: current_version
61+
if: github.event_name == 'pull_request'
62+
run: echo 'CURRENT_VERSION='$(cat version.sbt | grep version | awk '{ gsub(/"/, "", $5); print $5 }') >> $GITHUB_OUTPUT
63+
64+
- name: Get version on target
65+
id: target_version
66+
if: github.event_name == 'pull_request'
67+
run: 'echo ''TARGET_VERSION=''$(git show origin/${{github.event.pull_request.base.ref}}:version.sbt | grep version | awk ''{ gsub(/"/, "", $5); print $5 }'') >> $GITHUB_OUTPUT'
68+
69+
- name: Compare versions
70+
id: compare_versions
71+
if: github.event_name == 'pull_request'
72+
uses: actions/github-script@v6
73+
with:
74+
script: |
75+
const versionToBump = '${{steps.target_version.outputs.TARGET_VERSION}}'
76+
const parsedVersion = versionToBump.split(".")
77+
var major = Number(parsedVersion[0])
78+
var minor = Number(parsedVersion[1])
79+
var patch = Number(parsedVersion[2])
80+
81+
const prResponse = await github.rest.pulls.get({
82+
owner: context.repo.owner,
83+
repo: context.repo.repo,
84+
pull_number: ${{github.event.pull_request.number}}
85+
})
86+
87+
const pr = prResponse.data
88+
89+
if (pr === undefined || prResponse.status !== 200) {
90+
throw new Error("Could not fetch PR with number " + ${{github.event.pull_request.number}} + ": " + prResponse.status)
91+
}
92+
93+
for (const label of pr.labels) {
94+
if (label.name === 'version: revision') {
95+
patch = patch + 1
96+
break
97+
} else if (label.name === 'version: feature') {
98+
patch = 0
99+
minor = minor + 1
100+
break
101+
} else if (label.name === 'version: breaking') {
102+
major = major + 1
103+
minor = 0
104+
patch = 0
105+
break
106+
} else if (label.name === 'version: release') {
107+
major = major + 1
108+
minor = 0
109+
patch = 0
110+
break
111+
}
112+
}
113+
114+
const bumpedVersion = major + '.' + minor + '.' + patch
115+
const currentVersion = '${{steps.current_version.outputs.CURRENT_VERSION}}'
116+
117+
if (bumpedVersion === versionToBump) {
118+
throw new Error("Could not detect the version label on PR " + pr.number)
119+
}
120+
121+
if (bumpedVersion !== currentVersion) {
122+
console.log("Detected that bump is required to: " + bumpedVersion)
123+
return {
124+
nextVersion: bumpedVersion
125+
}
126+
} else {
127+
console.log("No bump is required")
128+
return { nextVersion: "" }
129+
}
130+
131+
132+
- name: Ensure version does not need bumping
133+
if: github.event_name == 'pull_request'
134+
run: '[ "${{fromJson(steps.compare_versions.outputs.result).nextVersion}}" = "" ]'
135+
52136
- name: Check that workflows are up to date
53137
run: $SBT '++ ${{ matrix.scala }}' githubWorkflowCheck
54138

@@ -58,41 +142,44 @@ jobs:
58142
run: tar cf targets.tar target core/target project/target
59143

60144
- name: Upload target directories
61-
uses: actions/upload-artifact@v3
145+
uses: actions/upload-artifact@v4
62146
with:
63147
name: target-${{ matrix.os }}-${{ matrix.scala }}-${{ matrix.java }}
64148
path: targets.tar
65149

66150
publish:
67151
name: Publish Artifacts
68152
needs: [build]
69-
if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/backport/v') || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') && (startsWith(github.event.head_commit.message, 'Version release'))
153+
if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/backport/v') || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
70154
strategy:
71155
matrix:
72156
os: [ubuntu-latest]
73-
scala: [2.13.11]
157+
scala: [2.13.16]
74158
java: [temurin@17]
75159
runs-on: ${{ matrix.os }}
76160
steps:
77161
- name: Checkout current branch (full)
78-
uses: actions/checkout@v3
162+
uses: actions/checkout@v4
79163
with:
80164
fetch-depth: 0
81165

82166
- name: Setup Java (temurin@17)
83167
if: matrix.java == 'temurin@17'
84-
uses: actions/setup-java@v3
168+
uses: actions/setup-java@v4
85169
with:
86170
distribution: temurin
87171
java-version: 17
88172
cache: sbt
89173

90-
- name: Download target directories (2.13.11)
91-
uses: actions/download-artifact@v3
174+
- name: Setup sbt
175+
uses: sbt/setup-sbt@v1
176+
177+
- name: Download target directories (2.13.16)
178+
uses: actions/download-artifact@v4
92179
with:
93-
name: target-${{ matrix.os }}-2.13.11-${{ matrix.java }}
180+
name: target-${{ matrix.os }}-2.13.16-${{ matrix.java }}
94181

95-
- name: Inflate target directories (2.13.11)
182+
- name: Inflate target directories (2.13.16)
96183
run: |
97184
tar xf targets.tar
98185
rm targets.tar
@@ -107,93 +194,59 @@ jobs:
107194

108195
- run: $SBT dependencyUpdates
109196

110-
auto-merge:
111-
name: Auto Merge
112-
needs: [build]
113-
if: 'github.event_name == ''pull_request'' && contains(github.head_ref, ''version-bump'') && contains(github.event.pull_request.labels.*.name, ''version: revision'')'
197+
bump_version:
198+
name: Bump Version
199+
needs: [check-labels]
200+
if: github.event_name == 'pull_request' && !github.event.pull_request.draft && (github.event.pull_request.base.ref == 'main' || startsWith(github.event.pull_request.base.ref, 'backport/v') || github.event.pull_request.base.ref == 'main' || github.event.pull_request.base.ref == 'master')
114201
strategy:
115202
matrix:
116203
os: [ubuntu-latest]
117204
scala: [2.13.10]
118-
java: [temurin@8]
119-
runs-on: ${{ matrix.os }}
120-
steps:
121-
- name: Merge
122-
id: merge
123-
uses: actions/github-script@v6
124-
with:
125-
script: |
126-
github.rest.pulls.merge({
127-
owner: context.repo.owner,
128-
repo: context.repo.repo,
129-
pull_number: ${{ github.event.pull_request.number }},
130-
});
131-
github-token: ${{ secrets.PRECOG_GITHUB_TOKEN }}
132-
133-
check-labels:
134-
name: Check Labels
135-
if: github.event_name == 'pull_request' && !github.event.pull_request.draft
136-
strategy:
137-
matrix:
138-
os: [ubuntu-latest]
139-
scala: [2.13.10]
140-
java: [temurin@8]
141-
runs-on: ${{ matrix.os }}
142-
steps:
143-
- name: Check PR labels
144-
uses: docker://agilepathway/pull-request-label-checker:v1.4.30
145-
with:
146-
one_of: 'version: breaking,version: feature,version: revision,version: release'
147-
none_of: ':stop_sign:'
148-
repo_token: ${{ env.GITHUB_TOKEN }}
149-
150-
next-version:
151-
name: Next version
152-
if: github.event_name == 'push' && !startsWith(github.event.head_commit.message, 'Version release')
153-
strategy:
154-
matrix:
155-
os: [ubuntu-latest]
156-
scala: [2.13.10]
157-
java: [temurin@8]
205+
java: [zulu@8]
158206
runs-on: ${{ matrix.os }}
159207
steps:
160208
- name: Checkout current branch (fast)
161209
uses: actions/checkout@v3
162210
with:
163211
token: ${{ secrets.PRECOG_GITHUB_TOKEN }}
164212

213+
- name: Fetch base
214+
if: github.event_name == 'pull_request'
215+
run: git fetch origin ${{github.event.pull_request.base.ref}}
216+
165217
- name: Get current version
166218
id: current_version
167-
run: echo "CURRENT_VERSION=$(cat version.sbt | awk '{ gsub(/"/, "", $5); print $5 }')" >> $GITHUB_OUTPUT
219+
if: github.event_name == 'pull_request'
220+
run: echo 'CURRENT_VERSION='$(cat version.sbt | grep version | awk '{ gsub(/"/, "", $5); print $5 }') >> $GITHUB_OUTPUT
168221

169-
- name: Compute next version
170-
id: compute_next_version
222+
- name: Get version on target
223+
id: target_version
224+
if: github.event_name == 'pull_request'
225+
run: 'echo ''TARGET_VERSION=''$(git show origin/${{github.event.pull_request.base.ref}}:version.sbt | grep version | awk ''{ gsub(/"/, "", $5); print $5 }'') >> $GITHUB_OUTPUT'
226+
227+
- name: Compare versions
228+
id: compare_versions
229+
if: github.event_name == 'pull_request'
171230
uses: actions/github-script@v6
172231
with:
173232
script: |
174-
const currentVersion = '${{steps.current_version.outputs.CURRENT_VERSION}}'
175-
const parsedVersion = currentVersion.split(".")
233+
const versionToBump = '${{steps.target_version.outputs.TARGET_VERSION}}'
234+
const parsedVersion = versionToBump.split(".")
176235
var major = Number(parsedVersion[0])
177236
var minor = Number(parsedVersion[1])
178237
var patch = Number(parsedVersion[2])
179238
180-
const prResponse = await github.rest.repos.listPullRequestsAssociatedWithCommit({
239+
const prResponse = await github.rest.pulls.get({
181240
owner: context.repo.owner,
182241
repo: context.repo.repo,
183-
commit_sha: context.sha
242+
pull_number: ${{github.event.pull_request.number}}
184243
})
185244
186-
const prs = prResponse.data
245+
const pr = prResponse.data
187246
188-
if (prs === undefined) {
189-
throw new Error("Could not fetch PRs for commit: status " + prs.status)
190-
} else if (prs.length > 1) {
191-
throw new Error("Cannot determine version increment required as there is more than one PR associated with the commit: " + context.sha)
192-
} else if (prs.length === 0) {
193-
throw new Error("Cannot determine version increment required as there are no PRs associated with the commit: " + context.sha)
194-
}
195-
196-
const pr = prs[0]
247+
if (pr === undefined || prResponse.status !== 200) {
248+
throw new Error("Could not fetch PR with number " + ${{github.event.pull_request.number}} + ": " + prResponse.status)
249+
}
197250
198251
for (const label of pr.labels) {
199252
if (label.name === 'version: revision') {
@@ -216,35 +269,76 @@ jobs:
216269
}
217270
}
218271
219-
const nextVersion = major + '.' + minor + '.' + patch
272+
const bumpedVersion = major + '.' + minor + '.' + patch
273+
const currentVersion = '${{steps.current_version.outputs.CURRENT_VERSION}}'
220274
221-
if (nextVersion === currentVersion) {
222-
throw new Error("Could not detect the version label on PR " + pr.number + " (obtained via association to commit " + context.sha + ")")
275+
if (bumpedVersion === versionToBump) {
276+
throw new Error("Could not detect the version label on PR " + pr.number)
223277
}
224278
225-
console.log("Setting the next version to " + nextVersion)
226-
227-
var body = ""
228-
if (pr.body === undefined || pr.body === null || pr.body === "") {
229-
body = ""
279+
if (bumpedVersion !== currentVersion) {
280+
console.log("Detected that bump is required to: " + bumpedVersion)
281+
return {
282+
nextVersion: bumpedVersion
283+
}
230284
} else {
231-
body = "\n" + pr.body.replaceAll("\r\n", "\n")
232-
}
233-
234-
// set outputs for
235-
const result = {
236-
nextVersion: nextVersion,
237-
commitMessage: "Version release: " + nextVersion + "\n\n" + pr.title + body
285+
console.log("No bump is required")
286+
return { nextVersion: "" }
238287
}
239-
return result
240288
289+
241290
- name: Modify version
242291
id: modify_version
243-
run: 'echo ''ThisBuild / version := "${{fromJson(steps.compute_next_version.outputs.result).nextVersion}}"'' > version.sbt'
292+
if: fromJson(steps.compare_versions.outputs.result).nextVersion != ''
293+
run: |
294+
printf '// Last bumped by PR ${{github.event.pull_request.number}}
295+
ThisBuild / version := "${{fromJson(steps.compare_versions.outputs.result).nextVersion}}"
296+
' > version.sbt
244297
245298
- name: Commit changes
246-
uses: stefanzweifel/git-auto-commit-action@v4
299+
if: fromJson(steps.compare_versions.outputs.result).nextVersion != ''
300+
uses: stefanzweifel/git-auto-commit-action@v5
247301
with:
248-
commit_message: ${{fromJson(steps.compute_next_version.outputs.result).commitMessage}}
302+
commit_message: 'Version bump: ${{fromJson(steps.compare_versions.outputs.result).nextVersion}}'
249303
commit_user_name: precog-bot
250304
commit_user_email: bot@precog.com
305+
306+
auto-merge:
307+
name: Auto Merge
308+
needs: [build, bump_version]
309+
if: 'github.event_name == ''pull_request'' && contains(github.head_ref, ''version-bump'') && contains(github.event.pull_request.labels.*.name, ''version: revision'') && github.event.pull_request.user.login == ''precog-bot'''
310+
strategy:
311+
matrix:
312+
os: [ubuntu-latest]
313+
scala: [2.13.10]
314+
java: [zulu@8]
315+
runs-on: ${{ matrix.os }}
316+
steps:
317+
- name: Merge
318+
id: merge
319+
uses: actions/github-script@v6
320+
with:
321+
script: |
322+
github.rest.pulls.merge({
323+
owner: context.repo.owner,
324+
repo: context.repo.repo,
325+
pull_number: ${{ github.event.pull_request.number }},
326+
});
327+
github-token: ${{ secrets.PRECOG_GITHUB_TOKEN }}
328+
329+
check-labels:
330+
name: Check Labels
331+
if: github.event_name == 'pull_request' && !github.event.pull_request.draft
332+
strategy:
333+
matrix:
334+
os: [ubuntu-latest]
335+
scala: [2.13.10]
336+
java: [zulu@8]
337+
runs-on: ${{ matrix.os }}
338+
steps:
339+
- name: Check PR labels
340+
uses: docker://agilepathway/pull-request-label-checker:v1.4.30
341+
with:
342+
one_of: 'version: breaking,version: feature,version: revision,version: release'
343+
none_of: ':stop_sign:'
344+
repo_token: ${{ env.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)