Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an editor config, a mvn goal and a ci action to check code conventions #507

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# EditorConfig: maintain consistent coding styles for multiple
# developers working on the same project across various editors and
# IDEs, see https://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true

# Set default charset and 4 space indentation for all xml, xslt, xpl,
# xprocspec and xspec files
[*.{xml,xpl,xsl,xprocspec,xspec}]
charset = utf-8
indent_style = space
indent_size = 4



17 changes: 17 additions & 0 deletions .github/workflows/check-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Check code conventions

on: [push]

jobs:
check-code-conventions:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '11'
- name: Build with Maven
run: mvn --batch-mode editorconfig:check
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ The nordic migrator can be built with Maven,
either directly (with for instance `mvn clean package`),
or indirectly with Docker (with for instance `docker build .`).

To check the code conventions use a special Maven plugin: `mvn
editorconfig:check`. The conventions are defined in `.editorconfig`
which is picked up by most editors, see https://editorconfig.org/. You
can also fix the conventions in all files with `mvn
editorconfig:format`.

Releasing
---------

Expand Down
22 changes: 22 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,28 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.ec4j.maven</groupId>
<artifactId>editorconfig-maven-plugin</artifactId>
<version>0.1.1</version>
<executions>
<execution>
<id>check</id>
<phase>verify</phase>
josteinaj marked this conversation as resolved.
Show resolved Hide resolved
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<excludes>
<!-- You can exclude further files from processing: -->
<exclude>src/test/**/*.epub</exclude>
<exclude>**/*.otf</exclude>
<exclude>documentation/*.odg</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>

Expand Down