Skip to content

Commit 46a35ba

Browse files
authored
Merge pull request #9 from felipemelozx/feat/add-github-actions
feat: Add initial github action
2 parents e44934b + 5d1b3dc commit 46a35ba

File tree

3 files changed

+144
-1
lines changed

3 files changed

+144
-1
lines changed

.github/workflows/java-ci.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Java CI Pipeline
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
pull_request:
8+
branches:
9+
- develop
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v2
18+
19+
- name: Start PostgreSQL with Docker Compose
20+
run: docker compose -f ./docker-compose.yaml up -d
21+
22+
- name: Set up JDK 21
23+
uses: actions/setup-java@v2
24+
with:
25+
java-version: '21'
26+
distribution: 'temurin'
27+
28+
- name: Build with Maven
29+
run: mvn clean install -DskipTests
30+
31+
- name: Run tests
32+
run: mvn test -Dspring.profiles.active=test
33+
34+
#- name: Run Checkstyle
35+
# run: mvn checkstyle:check
36+
37+
- name: Build JAR file
38+
run: mvn package

pom.xml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,23 @@
8484
<groupId>org.springframework.boot</groupId>
8585
<artifactId>spring-boot-maven-plugin</artifactId>
8686
</plugin>
87+
<!--<plugin>
88+
<groupId>org.apache.maven.plugins</groupId>
89+
<artifactId>maven-checkstyle-plugin</artifactId>
90+
<version>3.1.0</version>
91+
<executions>
92+
<execution>
93+
<goals>
94+
<goal>check</goal>
95+
</goals>
96+
<configuration>
97+
<configLocation>checks.xml</configLocation>
98+
<encoding>UTF-8</encoding>
99+
<failOnViolation>true</failOnViolation>
100+
</configuration>
101+
</execution>
102+
</executions>
103+
</plugin>-->
87104
</plugins>
88105
</build>
89-
90106
</project>

src/main/resources/checks.xml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<checkstyle>
4+
5+
<!-- Define the global rules -->
6+
<module name="Checker">
7+
8+
<!-- Limits the length of code lines -->
9+
<module name="LineLength">
10+
<property name="max" value="120"/> <!-- Maximum of 120 characters per line -->
11+
</module>
12+
13+
<!-- Indentation: uses 2 spaces (or 4 spaces, depending on your preferences) -->
14+
<module name="Indentation">
15+
<property name="tabWidth" value="2"/>
16+
<property name="useTabCharacter" value="false"/>
17+
</module>
18+
19+
<!-- Checks class and method naming conventions -->
20+
<module name="TypeName">
21+
<property name="format" value="^[A-Z][a-zA-Z0-9]*$"/> <!-- CamelCase for classes -->
22+
</module>
23+
24+
<module name="MethodName">
25+
<property name="format" value="^[a-z][a-zA-Z0-9]*$"/> <!-- camelCase for methods -->
26+
</module>
27+
28+
<!-- Checks the use of curly braces for code blocks, even in a single line -->
29+
<module name="RightCurly">
30+
<property name="option" value="ALWAYS"/>
31+
</module>
32+
33+
<!-- Checks the use of spaces around operators -->
34+
<module name="WhitespaceAround">
35+
<property name="allow" value="a,=,[]"/>
36+
</module>
37+
38+
<!-- Requires a blank line between methods -->
39+
<module name="SeparatorWrap">
40+
<property name="requireEmptyLine" value="true"/>
41+
</module>
42+
43+
<!-- Checks if variables are named correctly -->
44+
<module name="LocalVariableName">
45+
<property name="format" value="^[a-z][a-zA-Z0-9]*$"/> <!-- camelCase for local variables -->
46+
</module>
47+
48+
<module name="ConstantName">
49+
<property name="format" value="^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"/> <!-- Upper case and separated by underscores -->
50+
</module>
51+
52+
<!-- Checks the use of access modifiers (public/private/protected) -->
53+
<module name="VisibilityModifier">
54+
<property name="public" value="false"/> <!-- Requires public members to be well justified -->
55+
</module>
56+
57+
<!-- Avoids methods with too many parameters -->
58+
<module name="MethodParamPad">
59+
<property name="max" value="7"/> <!-- Maximum of 7 parameters in a method -->
60+
</module>
61+
62+
<!-- Checks if spaces are used to align elements properly -->
63+
<module name="WhitespaceAround">
64+
<property name="checkParameters" value="true"/>
65+
</module>
66+
67+
<!-- Ensures that methods have Javadoc comments explaining their functionality -->
68+
<module name="JavadocMethod">
69+
<property name="requireJavadoc" value="true"/>
70+
<property name="scope" value="public"/>
71+
</module>
72+
73+
<!-- Checks if classes have Javadoc -->
74+
<module name="JavadocType">
75+
<property name="scope" value="public"/>
76+
</module>
77+
78+
<!-- Ensures that the code style adheres to Java conventions -->
79+
<module name="FileTabCharacter">
80+
<property name="useTabs" value="false"/> <!-- Use spaces instead of tabs -->
81+
</module>
82+
83+
<!-- Requires a space between the type and the variable name -->
84+
<module name="ParameterName">
85+
<property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
86+
</module>
87+
88+
</module>
89+
</checkstyle>

0 commit comments

Comments
 (0)