From 33a1c7c32bbc11ef6245b9aafd428f6ce8df21b1 Mon Sep 17 00:00:00 2001 From: Simon Bernard Date: Tue, 12 Jul 2022 16:41:59 +0200 Subject: [PATCH] Add github actions for code format/style check. --- .github/actions/checkstyle/action.yml | 36 ++++++++++++++++++++++++ .github/actions/formatter/action.yml | 40 +++++++++++++++++++++++++++ .github/actions/javadoc/action.yml | 2 +- .github/workflows/main.yml | 10 +++++++ pom.xml | 2 ++ 5 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 .github/actions/checkstyle/action.yml create mode 100644 .github/actions/formatter/action.yml diff --git a/.github/actions/checkstyle/action.yml b/.github/actions/checkstyle/action.yml new file mode 100644 index 0000000000..d5e6c99d52 --- /dev/null +++ b/.github/actions/checkstyle/action.yml @@ -0,0 +1,36 @@ +name: "CheckSyle Validation" +description: "Check some code style rules with Maven" + +runs: + using: "composite" + steps: + + - name: Check Code Style + id: checkstyle + shell: bash + run: mvn -B checkstyle:checkstyle + + - name: Add comment + if: failure() + uses: marocchino/sticky-pull-request-comment@v2 + with: + header: Checkstyle Validation Failed + message: | + :x: **Checkstyle Validation Failed !** [(more details)](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) + + Ensure your code build locally using: + ``` + mvn clean install + ``` + Or just validate checkstyle rules with : + ``` + mvn checkstyle:checkstyle + ``` + See also [How configure your IDE](https://github.com/eclipse/leshan/wiki/Code-&-design-guidelines#configure-your-ide). + + - name: Delete comment + if: success() + uses: marocchino/sticky-pull-request-comment@v2 + with: + header: Checkstyle Validation Failed + delete: true \ No newline at end of file diff --git a/.github/actions/formatter/action.yml b/.github/actions/formatter/action.yml new file mode 100644 index 0000000000..617b9e516d --- /dev/null +++ b/.github/actions/formatter/action.yml @@ -0,0 +1,40 @@ +name: "Check code Format" +description: "Check code is well formatted with Maven" + +runs: + using: "composite" + steps: + + - name: Check Code Format + id: formatter + shell: bash + run: mvn -B formatter:validate + + - name: Add comment + if: failure() + uses: marocchino/sticky-pull-request-comment@v2 + with: + header: Code Formatter Validation Failed + message: | + :x: **Code is not well-formatted !** [(more details)](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) + + Ensure your code build locally using: + ``` + mvn clean install + ``` + Or just validate code format with : + ``` + mvn formatter:validate + ``` + You can format the code with : + ``` + mvn formatter:format + ``` + See also [How configure your IDE](https://github.com/eclipse/leshan/wiki/Code-&-design-guidelines#configure-your-ide). + + - name: Delete comment + if: success() + uses: marocchino/sticky-pull-request-comment@v2 + with: + header: Code Formatter Validation Failed + delete: true \ No newline at end of file diff --git a/.github/actions/javadoc/action.yml b/.github/actions/javadoc/action.yml index ab8bbb130a..be015d9983 100644 --- a/.github/actions/javadoc/action.yml +++ b/.github/actions/javadoc/action.yml @@ -8,7 +8,7 @@ runs: - name: Generate Javadoc id: javadoc shell: bash - run: mvn -B javadoc:javadoc + run: mvn -B javadoc:javadoc-no-fork - name: Add comment if: failure() diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2342fdcb44..8298908f85 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -30,11 +30,21 @@ jobs: - name: Check No Merge Commit uses: ./.github/actions/no_merge + - name: Code Format Check + if: always() + id: formatter + uses: ./.github/actions/formatter + - name: Build if: always() id: build uses: ./.github/actions/build + - name: Code Style Check + if: always() + id: checkstyle + uses: ./.github/actions/checkstyle + - name: Check Android API Compliance if: ${{ always() && steps.build.conclusion == 'success' }} uses: ./.github/actions/android-check diff --git a/pom.xml b/pom.xml index 7b9e864230..e4ad32860c 100644 --- a/pom.xml +++ b/pom.xml @@ -131,6 +131,8 @@ Contributors: true true true + true + true