|
| 1 | +# Uses: https://github.com/marketplace/actions/prettier-java-action |
| 2 | +# Auto formats code using Prettier |
| 3 | +# Uses: https://github.com/marketplace/actions/run-java-checkstyle |
| 4 | +# Submits review annotations based on checkstyle errors |
| 5 | + |
| 6 | +name: Java Style |
| 7 | + |
| 8 | +on: pull_request |
| 9 | + |
| 10 | +jobs: |
| 11 | + prettify: |
| 12 | + name: Prettify Java |
| 13 | + runs-on: ubuntu-latest |
| 14 | + |
| 15 | + steps: |
| 16 | + - name: Check out Git repository |
| 17 | + uses: actions/checkout@v2 |
| 18 | + with: |
| 19 | + fetch-depth: 0 |
| 20 | + |
| 21 | + - name: Prettify the Java code |
| 22 | + uses: lwerner-lshigh/[email protected] |
| 23 | + with: |
| 24 | + ### Prettier Options ### |
| 25 | + # --no-semi overrides prettier printing semicolons |
| 26 | + # at the ends of all statements |
| 27 | + # --tab-width 4 sets the tab width to 4 spaces |
| 28 | + # --write *.java formats all .java files |
| 29 | + prettier_options: '--no-semi --tab-width 4 --write **/*.java' |
| 30 | + branch: ${{ github.head_ref }} |
| 31 | + commit_message: 'Bot: Prettified Java code!' |
| 32 | + env: |
| 33 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 34 | + |
| 35 | + checkstyle: |
| 36 | + name: Java Checkstyle |
| 37 | + runs-on: ubuntu-latest |
| 38 | + needs: prettify |
| 39 | + |
| 40 | + steps: |
| 41 | + - name: Check out Git repository |
| 42 | + uses: actions/checkout@v2 |
| 43 | + |
| 44 | + - name: Setup Java JDK |
| 45 | + |
| 46 | + with: |
| 47 | + java-version: '12.x' |
| 48 | + |
| 49 | + - name: Run checkstyle with reviewdog |
| 50 | + uses: nikitasavinov/checkstyle-action@master |
| 51 | + with: |
| 52 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 53 | + # submit review comments based on reviewdog findings |
| 54 | + reporter: github-pr-review |
| 55 | + # report on anything that is in an added/modified file |
| 56 | + filter_mode: file |
| 57 | + fail_on_error: true |
| 58 | + checkstyle_config: google_checks_mod.xml |
| 59 | + workdir: src/com/code4tomorrow # working dir relative to root dir |
0 commit comments