Test: Update pr-java/functional-ci work flow
#5170
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Java CI | |
| on: | |
| pull_request: | |
| paths-ignore: | |
| - 'docs/**' | |
| - '.github/**' | |
| branches: | |
| - master | |
| release: | |
| types: | |
| - created | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| java: [ 21 ] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up JDK | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| cache: 'maven' | |
| cache-dependency-path: extra/pom.xml | |
| java-version: ${{ matrix.java }} | |
| - name: Build with Maven | |
| id: build | |
| run: | | |
| mvn -B package --file extra/pom.xml 2>&1 | tee build_output.txt | |
| result=${PIPESTATUS[0]} | |
| echo "exit_code=$result" >> "$GITHUB_OUTPUT" | |
| - name: Format build output for PR comment | |
| if: steps.build.outputs.exit_code != '0' | |
| run: | | |
| author="@${{ github.event.pull_request.user.login }}" | |
| audit_block=$(sed -n '/Starting audit\.\.\./,/Audit done\./p' build_output.txt) | |
| if echo "$audit_block" | grep -q '^\[ERROR\]'; then | |
| { | |
| echo "${author}, some Checkstyle issues were found" | |
| echo "**❌ Checkstyle Issues Detected**" | |
| echo "" | |
| echo '```' | |
| echo "$audit_block" | grep '^\[ERROR\]' | |
| echo '```' | |
| } > comment.txt | |
| else | |
| { | |
| echo "${author}, some Java test failures occurred" | |
| echo "❌ **Java CI Test Failures**" | |
| echo "" | |
| echo '```' | |
| sed -n '/\[ERROR\] Failures:/,/\[ERROR\] Tests run:/p' build_output.txt | |
| echo '```' | |
| } > comment.txt | |
| fi | |
| - name: Comment on PR with build failure output | |
| if: steps.build.outputs.exit_code != '0' | |
| uses: peter-evans/create-or-update-comment@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| issue-number: ${{ github.event.pull_request.number }} | |
| body-path: comment.txt | |
| - name: Fail if error is found in logs | |
| if: steps.build.outputs.exit_code != '0' | |
| run: exit 1 |