Skip to content

feat(CI): Added GitHub Actions to check for code style violations #5

feat(CI): Added GitHub Actions to check for code style violations

feat(CI): Added GitHub Actions to check for code style violations #5

Workflow file for this run

name: Check for formatting
on:
push:
pull_request:
jobs:
check-format:
name: Check if code needs formatting
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Maven
uses: actions/setup-java@v4
with:
java-version: 21
distribution: zulu
- name: Check if code aligns with code style
id: check
run: mvn spotless:check
continue-on-error: true
- name: Generate Summary for successful run
if: ${{ steps.check.outcome }} == 'success'
run: |
echo ":ballot_box_with_check: No formatting issues found." >> $GITHUB_STEP_SUMMARY
- name: Generate Summary for failed run
if: ${{ steps.check.outcome }} != 'success'
run: |
echo ":negative_squared_cross_mark: Formatting issues found!" >> $GITHUB_STEP_SUMMARY
echo "```" >> $GITHUB_STEP_SUMMARY
gh run view ${{ github.run_id }} --log | grep "ERROR" | sed 's/Check if code needs formatting Check if code aligns with code style [0-9A-Z:.-]\+//' | sed 's/\[ERROR] //' >> $GITHUB_STEP_SUMMARY
echo "```" >> $GITHUB_STEP_SUMMARY