Skip to content

Commit 5ace488

Browse files
authored
Added the neccessary CI workflows (#45)
1 parent 5c2a70e commit 5ace488

File tree

3 files changed

+285
-0
lines changed

3 files changed

+285
-0
lines changed

.github/linters/sun_checks.xml

Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE module PUBLIC
3+
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
4+
"https://checkstyle.org/dtds/configuration_1_3.dtd">
5+
6+
<!--
7+
8+
Checkstyle configuration that checks the sun coding conventions from:
9+
10+
- the Java Language Specification at
11+
https://docs.oracle.com/javase/specs/jls/se11/html/index.html
12+
13+
- the Sun Code Conventions at https://www.oracle.com/java/technologies/javase/codeconventions-contents.html
14+
15+
- the Javadoc guidelines at
16+
https://www.oracle.com/technical-resources/articles/java/javadoc-tool.html
17+
18+
- the JDK Api documentation https://docs.oracle.com/en/java/javase/11/
19+
20+
- some best practices
21+
22+
Checkstyle is very configurable. Be sure to read the documentation at
23+
https://checkstyle.org (or in your downloaded distribution).
24+
25+
Most Checks are configurable, be sure to consult the documentation.
26+
27+
To completely disable a check, just comment it out or delete it from the file.
28+
To suppress certain violations please review suppression filters.
29+
30+
Finally, it is worth reading the documentation.
31+
32+
-->
33+
34+
<module name="Checker">
35+
<!--
36+
If you set the basedir property below, then all reported file
37+
names will be relative to the specified directory. See
38+
https://checkstyle.org/config.html#Checker
39+
40+
<property name="basedir" value="${basedir}"/>
41+
-->
42+
<property name="severity" value="error"/>
43+
44+
<property name="fileExtensions" value="java, properties, xml"/>
45+
46+
<!-- Excludes all 'module-info.java' files -->
47+
<!-- See https://checkstyle.org/config_filefilters.html -->
48+
<module name="BeforeExecutionExclusionFileFilter">
49+
<property name="fileNamePattern" value="module\-info\.java$"/>
50+
</module>
51+
52+
<!-- https://checkstyle.org/config_filters.html#SuppressionFilter -->
53+
<module name="SuppressionFilter">
54+
<property name="file" value="${org.checkstyle.sun.suppressionfilter.config}" default="checkstyle-suppressions.xml" />
55+
<property name="optional" value="true"/>
56+
</module>
57+
58+
59+
<!-- Checks that a package-info.java file exists for each package. -->
60+
<!-- See https://checkstyle.org/config_javadoc.html#JavadocPackage -->
61+
<module name="JavadocPackage"/>
62+
63+
<!-- Checks whether files end with a new line. -->
64+
<!-- See https://checkstyle.org/config_misc.html#NewlineAtEndOfFile -->
65+
<module name="NewlineAtEndOfFile"/>
66+
67+
<!-- Checks that property files contain the same keys. -->
68+
<!-- See https://checkstyle.org/config_misc.html#Translation -->
69+
<module name="Translation"/>
70+
71+
<!-- Checks for Size Violations. -->
72+
<!-- See https://checkstyle.org/config_sizes.html -->
73+
<module name="FileLength"/>
74+
<module name="LineLength">
75+
<property name="fileExtensions" value="java"/>
76+
<property name="max" value="120"/>
77+
</module>
78+
79+
<!-- Checks for whitespace -->
80+
<!-- See https://checkstyle.org/config_whitespace.html -->
81+
<module name="FileTabCharacter"/>
82+
83+
<!-- Miscellaneous other checks. -->
84+
<!-- See https://checkstyle.org/config_misc.html -->
85+
<module name="RegexpSingleline">
86+
<property name="format" value="\s+$"/>
87+
<property name="minimum" value="0"/>
88+
<property name="maximum" value="0"/>
89+
<property name="message" value="Line has trailing spaces."/>
90+
</module>
91+
92+
<!-- Checks for Headers -->
93+
<!-- See https://checkstyle.org/config_header.html -->
94+
<!-- <module name="Header"> -->
95+
<!-- <property name="headerFile" value="${checkstyle.header.file}"/> -->
96+
<!-- <property name="fileExtensions" value="java"/> -->
97+
<!-- </module> -->
98+
99+
<!-- Enables @SuppressWarnings Support -->
100+
<module name="SuppressWarningsFilter"/>
101+
<module name="TreeWalker">
102+
103+
<!-- Checks for Javadoc comments. -->
104+
<!-- See https://checkstyle.org/config_javadoc.html -->
105+
<module name="InvalidJavadocPosition"/>
106+
<module name="JavadocMethod"/>
107+
<module name="JavadocType"/>
108+
<module name="JavadocVariable">
109+
<property name="scope" value="public"/>
110+
</module>
111+
<module name="JavadocStyle"/>
112+
<module name="MissingJavadocMethod"/>
113+
<!-- Enables @SuppressWarnings Support -->
114+
<module name="SuppressWarningsHolder"/>
115+
116+
<!-- Checks for Naming Conventions. -->
117+
<!-- See https://checkstyle.org/config_naming.html -->
118+
<module name="ConstantName"/>
119+
<module name="LocalFinalVariableName"/>
120+
<module name="LocalVariableName"/>
121+
<module name="MemberName"/>
122+
<module name="MethodName"/>
123+
<module name="PackageName"/>
124+
<module name="ParameterName"/>
125+
<module name="StaticVariableName"/>
126+
<module name="TypeName"/>
127+
128+
<!-- Checks for imports -->
129+
<!-- See https://checkstyle.org/config_imports.html -->
130+
<module name="AvoidStarImport"/>
131+
<module name="IllegalImport"/>
132+
<!-- defaults to sun.* packages -->
133+
<module name="RedundantImport"/>
134+
<module name="UnusedImports">
135+
<property name="processJavadoc" value="false"/>
136+
</module>
137+
138+
<!-- Checks for Size Violations. -->
139+
<!-- See https://checkstyle.org/config_sizes.html -->
140+
<module name="MethodLength"/>
141+
<module name="ParameterNumber"/>
142+
143+
<!-- Checks for whitespace -->
144+
<!-- See https://checkstyle.org/config_whitespace.html -->
145+
<module name="EmptyForIteratorPad"/>
146+
<module name="GenericWhitespace"/>
147+
<module name="MethodParamPad"/>
148+
<module name="NoWhitespaceAfter"/>
149+
<module name="NoWhitespaceBefore"/>
150+
<module name="OperatorWrap"/>
151+
<module name="ParenPad"/>
152+
<module name="TypecastParenPad"/>
153+
<module name="WhitespaceAfter"/>
154+
<module name="WhitespaceAround"/>
155+
156+
<!-- Modifier Checks -->
157+
<!-- See https://checkstyle.org/config_modifiers.html -->
158+
<module name="ModifierOrder"/>
159+
<module name="RedundantModifier"/>
160+
161+
<!-- Checks for blocks. You know, those {}'s -->
162+
<!-- See https://checkstyle.org/config_blocks.html -->
163+
<module name="AvoidNestedBlocks"/>
164+
<module name="EmptyBlock"/>
165+
<module name="LeftCurly"/>
166+
<module name="NeedBraces"/>
167+
<module name="RightCurly"/>
168+
169+
<!-- Checks for common coding problems -->
170+
<!-- See https://checkstyle.org/config_coding.html -->
171+
<module name="EmptyStatement"/>
172+
<module name="EqualsHashCode"/>
173+
<!-- <module name="HiddenField">
174+
<property name="ignoreSetter" value="true"/>
175+
<property name="ignoreFormat" value="^runnable"/>
176+
</module> Disabled online due to constructors-->
177+
<module name="IllegalInstantiation"/>
178+
<module name="InnerAssignment"/>
179+
<!-- <module name="MagicNumber"/> Disabled only online-->
180+
<module name="MissingSwitchDefault"/>
181+
<module name="MultipleVariableDeclarations"/>
182+
<module name="SimplifyBooleanExpression"/>
183+
<module name="SimplifyBooleanReturn"/>
184+
185+
<!-- Checks for class design -->
186+
<!-- See https://checkstyle.org/config_design.html -->
187+
<module name="DesignForExtension"/>
188+
<module name="FinalClass"/>
189+
<module name="HideUtilityClassConstructor"/>
190+
<module name="InterfaceIsType"/>
191+
<module name="VisibilityModifier">
192+
<property name="protectedAllowed" value="true"/>
193+
<property name="packageAllowed" value="true"/>
194+
</module>
195+
196+
<!-- Miscellaneous other checks. -->
197+
<!-- See https://checkstyle.org/config_misc.html -->
198+
<module name="ArrayTypeStyle"/>
199+
<module name="TodoComment"/>
200+
<module name="UpperEll"/>
201+
202+
<!-- https://checkstyle.org/config_filters.html#SuppressionXpathFilter -->
203+
<module name="SuppressionXpathFilter">
204+
<property name="file" value="${org.checkstyle.sun.suppressionxpathfilter.config}" default="checkstyle-xpath-suppressions.xml" />
205+
<property name="optional" value="true"/>
206+
</module>
207+
<module name="SuppressionCommentFilter"/>
208+
209+
</module>
210+
211+
</module>

.github/workflows/lintChanges.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Lint Java Code
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
types:
8+
- opened
9+
- synchronize
10+
- unlabeled
11+
jobs:
12+
Lint_Java:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout Repository
16+
uses: actions/checkout@v2
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Lint_Java
21+
uses: github/super-linter@v3
22+
env:
23+
VALIDATE_ALL_CODEBASE: true # lint all files
24+
VALIDATE_JAVA: true # only lint Java files
25+
DEFAULT_BRANCH: master
26+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Enables better overview of runs

.github/workflows/tests.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# This workflow will build and test a Java project with Gradle
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
3+
4+
name: Tests
5+
6+
on:
7+
push:
8+
branches:
9+
- master
10+
pull_request:
11+
types:
12+
- opened
13+
- synchronize
14+
- unlabeled
15+
jobs:
16+
Java:
17+
strategy:
18+
matrix:
19+
java: ['8','11']
20+
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- name: Checkout Repository
25+
uses: actions/checkout@v2
26+
- name: Set up JDK
27+
uses: actions/setup-java@v2
28+
with:
29+
java-version: ${{ matrix.java }}
30+
distribution: 'adopt'
31+
- name: Grant execute permission for gradlew
32+
run: chmod +x gradlew
33+
- name: Build with Gradle
34+
run: ./gradlew assemble
35+
- name: Run Tests
36+
run: ./gradlew check
37+
38+
slack-on-failure:
39+
needs: [Java]
40+
if: failure() && github.ref == 'refs/heads/master'
41+
runs-on: ubuntu-latest
42+
43+
steps:
44+
- uses: 8398a7/action-slack@v3
45+
with:
46+
status: failure
47+
env:
48+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

0 commit comments

Comments
 (0)