From 8dc151af967723e74701bd2219b5d2c72daa82ff Mon Sep 17 00:00:00 2001 From: 21_RodinAN <21_RodinAN@iux.local> Date: Fri, 29 May 2026 09:58:51 +0300 Subject: [PATCH] plz --- .gitea/workflows/ci.yml | 20 ++++++++++++ .gitignore | 7 +++++ build.gradle | 43 ++++++++++++++++++++++++++ config/checkstyle/checkstyle.xml | 10 ++++++ settings.gradle | 1 + src/main/java/com/example/App.java | 12 +++++++ src/test/java/com/example/AppTest.java | 10 ++++++ 7 files changed, 103 insertions(+) create mode 100644 .gitea/workflows/ci.yml create mode 100644 .gitignore create mode 100644 build.gradle create mode 100644 config/checkstyle/checkstyle.xml create mode 100644 settings.gradle create mode 100644 src/main/java/com/example/App.java create mode 100644 src/test/java/com/example/AppTest.java diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml new file mode 100644 index 0000000..6a28c48 --- /dev/null +++ b/.gitea/workflows/ci.yml @@ -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 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..043e63a --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +.gradle/ +gradle-8.10/ +build/ +.gradle/ +gradle/ +gradlew +gradlew.bat diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..fa191f0 --- /dev/null +++ b/build.gradle @@ -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) + } +} diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml new file mode 100644 index 0000000..ffbd33b --- /dev/null +++ b/config/checkstyle/checkstyle.xml @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..c091d71 --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'my-app' diff --git a/src/main/java/com/example/App.java b/src/main/java/com/example/App.java new file mode 100644 index 0000000..e87a1b9 --- /dev/null +++ b/src/main/java/com/example/App.java @@ -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)); + } +} diff --git a/src/test/java/com/example/AppTest.java b/src/test/java/com/example/AppTest.java new file mode 100644 index 0000000..fa9788b --- /dev/null +++ b/src/test/java/com/example/AppTest.java @@ -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)); } +}