20
.gitea/workflows/ci.yml
Normal file
20
.gitea/workflows/ci.yml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
name: CI / Gradle
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ "main" ]
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Set up JDK 17
|
||||||
|
uses: actions/setup-java@v3
|
||||||
|
with:
|
||||||
|
java-version: '17'
|
||||||
|
distribution: 'temurin'
|
||||||
|
- name: Run Checkstyle
|
||||||
|
run: ./gradlew checkstyleMain
|
||||||
|
- name: Run tests with coverage
|
||||||
|
run: ./gradlew test jacocoTestReport
|
||||||
|
- name: Build project
|
||||||
|
run: ./gradlew build
|
||||||
7
.gitignore
vendored
Normal file
7
.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
.gradle/
|
||||||
|
gradle-8.10/
|
||||||
|
build/
|
||||||
|
.gradle/
|
||||||
|
gradle/
|
||||||
|
gradlew
|
||||||
|
gradlew.bat
|
||||||
43
build.gradle
Normal file
43
build.gradle
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
plugins {
|
||||||
|
id 'java'
|
||||||
|
id 'application'
|
||||||
|
id 'checkstyle'
|
||||||
|
id 'jacoco'
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.0'
|
||||||
|
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
|
||||||
|
}
|
||||||
|
|
||||||
|
application {
|
||||||
|
mainClass = 'com.example.App'
|
||||||
|
}
|
||||||
|
|
||||||
|
test {
|
||||||
|
useJUnitPlatform()
|
||||||
|
finalizedBy jacocoTestReport
|
||||||
|
}
|
||||||
|
|
||||||
|
jacocoTestReport {
|
||||||
|
dependsOn test
|
||||||
|
reports {
|
||||||
|
xml.required = true
|
||||||
|
html.required = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
checkstyle {
|
||||||
|
toolVersion = '10.12.0'
|
||||||
|
configFile = file('config/checkstyle/checkstyle.xml')
|
||||||
|
}
|
||||||
|
|
||||||
|
java {
|
||||||
|
toolchain {
|
||||||
|
languageVersion = JavaLanguageVersion.of(17)
|
||||||
|
}
|
||||||
|
}
|
||||||
10
config/checkstyle/checkstyle.xml
Normal file
10
config/checkstyle/checkstyle.xml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<!DOCTYPE module PUBLIC
|
||||||
|
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
|
||||||
|
"https://checkstyle.org/dtds/configuration_1_3.dtd">
|
||||||
|
<module name="Checker">
|
||||||
|
<module name="TreeWalker">
|
||||||
|
<module name="Indentation"/>
|
||||||
|
<module name="WhitespaceAfter"/>
|
||||||
|
</module>
|
||||||
|
</module>
|
||||||
1
settings.gradle
Normal file
1
settings.gradle
Normal file
@@ -0,0 +1 @@
|
|||||||
|
rootProject.name = 'my-app'
|
||||||
12
src/main/java/com/example/App.java
Normal file
12
src/main/java/com/example/App.java
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
package com.example;
|
||||||
|
|
||||||
|
public class App {
|
||||||
|
public static int add(int a, int b) { return a + b; }
|
||||||
|
public static int sub(int a, int b) { return a - b; }
|
||||||
|
public static int mul(int a, int b) { return a * b; }
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
System.out.println("CI ready");
|
||||||
|
System.out.println("2 + 3 = " + add(2, 3));
|
||||||
|
}
|
||||||
|
}
|
||||||
10
src/test/java/com/example/AppTest.java
Normal file
10
src/test/java/com/example/AppTest.java
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package com.example;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
class AppTest {
|
||||||
|
@Test void testAdd() { assertEquals(5, App.add(2, 3)); }
|
||||||
|
@Test void testSub() { assertEquals(1, App.sub(3, 2)); }
|
||||||
|
@Test void testMul() { assertEquals(6, App.mul(2, 3)); }
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user