@@ -32,7 +32,7 @@ concurrency:
3232 cancel-in-progress : ${{ !contains(github.ref, 'maint/') && github.ref != 'main' }}
3333
3434env :
35- SHARED_MVN_ARGS : ' --show-version --no-transfer-progress '
35+ SHARED_MVN_ARGS : ' --show-version'
3636
3737permissions :
3838 contents : read
9595 cd icu4j;
9696 mvn spotless:check || (echo "Style checker failed. Formatting changes can be applied by 'mvn spotless:apply'" && exit 1)
9797
98+ # Runs an error-prone test that fails the build if any issues are found.
99+ formatter :
100+ name : Error-prone check
101+ needs : icu4j-mvn-init-cache
102+ runs-on : ubuntu-latest
103+ steps :
104+ - name : Checkout and setup
105+ uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
106+ with :
107+ fetch-depth : 0
108+ - name : Restore read-only cache of local Maven repository
109+ uses : actions/cache/restore@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
110+ id : cache
111+ with :
112+ path : ~/.m2/repository
113+ key : ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
114+ restore-keys : |
115+ ${{ runner.os }}-maven-
116+ lookup-only : true
117+ - uses : actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
118+ with :
119+ distribution : ' temurin'
120+ java-version : ' 21'
121+ - name : Run error-prone
122+ run : |
123+ mvn -version
124+ # ICU_STATUS will be used to indicate whether the errorprone process succeeds or fails.
125+ # Failure means errors need to be fixed.
126+ echo "ICU_STATUS=1" >> "$GITHUB_ENV"
127+ mvn ${SHARED_MVN_ARGS} clean test -DskipTests -DskipITs -P errorprone -l /tmp/errorprone.log
128+ # We only get here if Maven does not fail
129+ echo "ICU_STATUS=0" >> "$GITHUB_ENV"
130+ continue-on-error : true
131+ - name : Generate errorprone report and output it to summary
132+ run : |
133+ if [ $ICU_STATUS -ne 0 ]; then
134+ grep '^\[ERROR\] ' /tmp/errorprone.log
135+ # We need to build this sub-project. If maven fails in a previous sub-project the
136+ # whole build stops and we never get to build the report tool, so we can't run it.
137+ mvn install -f icu4j/tools/build/ -q
138+ mvn exec:java -f icu4j/tools/build/ -P errorprone_report -DlogFile=/tmp/errorprone.log
139+ # Output messages and the error-prone report as workflow job summary
140+ echo '**Run this command locally and fix all errors:**' >> $GITHUB_STEP_SUMMARY
141+ echo '```' >> $GITHUB_STEP_SUMMARY
142+ echo '`mvn clean test -DskipTests -DskipITs -P errorprone`' >> $GITHUB_STEP_SUMMARY
143+ echo '```' >> $GITHUB_STEP_SUMMARY
144+ echo '**Error-prone errors:**' >> $GITHUB_STEP_SUMMARY
145+ grep -v -E ' WARNING | ICU_PRI' ./icu4j/target/errorprone.md >> $GITHUB_STEP_SUMMARY
146+ # User friendly messages to standard output
147+ echo 'View the Summary page of this Workflow instance to view the rendered Markdown of this report.'
148+ echo 'Run this command locally and fix all errors:'
149+ echo ' mvn clean test -DskipTests -DskipITs -P errorprone'
150+ exit 1
151+ fi
152+
98153 # ICU4J build and unit test using Maven
99154 # https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven
100155 icu4j-mvn-build-and-test :
0 commit comments