Skip to content

Commit

Permalink
Add github actions for code format/style check.
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernard31 committed Jul 13, 2022
1 parent 5c8e55f commit 33a1c7c
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 1 deletion.
36 changes: 36 additions & 0 deletions .github/actions/checkstyle/action.yml
Original file line number Diff line number Diff line change
@@ -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
40 changes: 40 additions & 0 deletions .github/actions/formatter/action.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .github/actions/javadoc/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ Contributors:
<maven.javadoc.skip>true</maven.javadoc.skip>
<animal.sniffer.skip>true</animal.sniffer.skip>
<revapi.skip>true</revapi.skip>
<formatter.skip>true</formatter.skip>
<checkstyle.skip>true</checkstyle.skip>
</properties>
</profile>
</profiles>
Expand Down

0 comments on commit 33a1c7c

Please sign in to comment.