add: configure CI/CD workflows for build and formatting checks #1
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: Spotless Check | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| jobs: | |
| spotless: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v4 | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x gradlew | |
| - name: Run Spotless Apply | |
| run: ./gradlew spotlessApply | |
| - name: Check output | |
| run: git --no-pager diff --exit-code HEAD | |
| - name: Generate diff | |
| run: git diff HEAD > javaformat-fixes.patch | |
| if: ${{ failure() }} | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: javaformat fixes | |
| path: javaformat-fixes.patch | |
| if: ${{ failure() }} | |
| - name: Write to job summary | |
| run: | | |
| echo '```diff' >> $GITHUB_STEP_SUMMARY | |
| cat javaformat-fixes.patch >> $GITHUB_STEP_SUMMARY | |
| echo '' >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| if: ${{ failure() }} |