Skip to content

Commit 86885c2

Browse files
committed
try some more ideas on spotless timing out
1 parent 0b6c41d commit 86885c2

4 files changed

Lines changed: 53 additions & 2 deletions

File tree

.github/workflows/beam_PreCommit_Spotless.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ jobs:
7777
github.event.comment.body == 'Run Spotless PreCommit'
7878
steps:
7979
- uses: actions/checkout@v6
80+
with:
81+
fetch-depth: 0
8082
- name: Setup repository
8183
uses: ./.github/actions/setup-action
8284
with:
@@ -91,7 +93,8 @@ jobs:
9193
uses: ./.github/actions/gradle-command-self-hosted-action
9294
with:
9395
gradle-command: spotlessCheck checkStyleMain checkStyleTest :buildSrc:spotlessCheck
94-
arguments: -PdisableSpotlessApply
96+
arguments: -PdisableSpotlessApply ${{ github.event_name == 'schedule' && '-PdisableSpotlessRatchet=true' || '' }}
97+
max-workers: 4
9598
- name: Upload test report
9699
uses: actions/upload-artifact@v7
97100
with:

buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,8 +507,40 @@ class BeamModulePlugin implements Plugin<Project> {
507507

508508
project.ext.mavenGroupId = 'org.apache.beam'
509509

510+
project.ext.getRatchetBranch = {
511+
->
512+
if (project.hasProperty('disableSpotlessRatchet') && project.disableSpotlessRatchet == 'true') {
513+
return null
514+
}
515+
try {
516+
def checkRef = { ref ->
517+
try {
518+
def res = project.exec {
519+
executable 'git'
520+
args 'rev-parse', '--verify', ref
521+
ignoreExitValue = true
522+
standardOutput = new ByteArrayOutputStream()
523+
errorOutput = new ByteArrayOutputStream()
524+
}
525+
return res.getExitValue() == 0
526+
} catch (Exception e) {
527+
return false
528+
}
529+
}
510530

511-
531+
if (checkRef('upstream/master')) {
532+
return 'upstream/master'
533+
} else if (checkRef('origin/master')) {
534+
return 'origin/master'
535+
} else if (checkRef('master')) {
536+
return 'master'
537+
} else {
538+
return null
539+
}
540+
} catch (Exception e) {
541+
return null
542+
}
543+
}
512544
// Default to dash-separated directories for artifact base name,
513545
// which will also be the default artifactId for maven publications
514546
project.apply plugin: 'base'
@@ -1465,6 +1497,10 @@ class BeamModulePlugin implements Plugin<Project> {
14651497
project.disableSpotlessCheck == 'true'
14661498
project.spotless {
14671499
enforceCheck !disableSpotlessCheck
1500+
def ratchetBranch = project.ext.getRatchetBranch()
1501+
if (ratchetBranch != null) {
1502+
ratchetFrom ratchetBranch
1503+
}
14681504
java {
14691505
licenseHeader javaLicenseHeader
14701506
googleJavaFormat('1.17.0')
@@ -2391,6 +2427,10 @@ class BeamModulePlugin implements Plugin<Project> {
23912427
project.disableSpotlessCheck == 'true'
23922428
project.spotless {
23932429
enforceCheck !disableSpotlessCheck
2430+
def ratchetBranch = project.ext.getRatchetBranch()
2431+
if (ratchetBranch != null) {
2432+
ratchetFrom ratchetBranch
2433+
}
23942434
def grEclipseConfig = project.project(":").file("buildSrc/greclipse.properties")
23952435
groovy {
23962436
greclipse().configFile(grEclipseConfig)

runners/flink/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ repositories {
2828
* We configure spotless here once in order to only check these java sources once.
2929
*/
3030
spotless {
31+
def ratchetBranch = project.rootProject.hasProperty('getRatchetBranch') ? project.rootProject.ext.getRatchetBranch() : null
32+
if (ratchetBranch != null) {
33+
ratchetFrom ratchetBranch
34+
}
3135
java {
3236
licenseHeader org.apache.beam.gradle.BeamModulePlugin.javaLicenseHeader
3337
googleJavaFormat('1.17.0')

runners/spark/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ repositories {
2828
* We configure spotless here once in order to only check these java sources once.
2929
*/
3030
spotless {
31+
def ratchetBranch = project.rootProject.hasProperty('getRatchetBranch') ? project.rootProject.ext.getRatchetBranch() : null
32+
if (ratchetBranch != null) {
33+
ratchetFrom ratchetBranch
34+
}
3135
java {
3236
licenseHeader org.apache.beam.gradle.BeamModulePlugin.javaLicenseHeader
3337
googleJavaFormat('1.17.0')

0 commit comments

Comments
 (0)