From 2a09218de5641c286516314599a19f52a28bc23a Mon Sep 17 00:00:00 2001 From: Maxime Pierront <46542631+MaximePIERRONT@users.noreply.github.com> Date: Sat, 19 Oct 2024 16:05:29 +0200 Subject: [PATCH] first commit --- .github/workflows/maven.yml | 27 ++++++++++++++++++ .gitignore | 1 + .gitlab-ci.yml | 23 +++++++++++++++ .idea/.gitignore | 10 +++++++ .idea/compiler.xml | 13 +++++++++ .idea/jarRepositories.xml | 20 +++++++++++++ .idea/misc.xml | 12 ++++++++ .idea/vcs.xml | 6 ++++ README.md | Bin 0 -> 28 bytes pom.xml | 18 ++++++++++++ src/main/java/com/example/App.java | 9 ++++++ src/main/java/com/example/Calculator.java | 11 +++++++ src/test/java/com/example/CalculatorTest.java | 18 ++++++++++++ 13 files changed, 168 insertions(+) create mode 100644 .github/workflows/maven.yml create mode 100644 .gitignore create mode 100644 .gitlab-ci.yml create mode 100644 .idea/.gitignore create mode 100644 .idea/compiler.xml create mode 100644 .idea/jarRepositories.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/vcs.xml create mode 100644 README.md create mode 100644 pom.xml create mode 100644 src/main/java/com/example/App.java create mode 100644 src/main/java/com/example/Calculator.java create mode 100644 src/test/java/com/example/CalculatorTest.java diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml new file mode 100644 index 0000000..ca19b90 --- /dev/null +++ b/.github/workflows/maven.yml @@ -0,0 +1,27 @@ +name: Java CI with Maven + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Set up JDK 21 + uses: actions/setup-java@v3 + with: + java-version: '21' + distribution: 'temurin' + cache: maven + + - name: Build with Maven + run: mvn -B compile --file pom.xml + + - name: Run tests + run: mvn -B test --file pom.xml \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a6f89c2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target/ \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..5660dfd --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,23 @@ +image: maven:3.8.8-openjdk-21-slim + +variables: + MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository" + +cache: + paths: + - .m2/repository + +stages: + - build + - test + - integration-test + +build: + stage: build + script: + - mvn compile + +test: + stage: test + script: + - mvn test \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..5178307 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,10 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml + +/target/ diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..338276e --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..712ab9d --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..14cbe7b --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..f0815274791759975f344a4162fb6ca1eb617bc3 GIT binary patch literal 28 fcmezWPnki1A(v(X)XnZ literal 0 HcmV?d00001 diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..d3fd3e3 --- /dev/null +++ b/pom.xml @@ -0,0 +1,18 @@ + + 4.0.0 + com.example + demo-app + jar + 1.0-SNAPSHOT + ci-cd-app + http://maven.apache.org + + + org.junit.jupiter + junit-jupiter-engine + 5.11.2 + test + + + diff --git a/src/main/java/com/example/App.java b/src/main/java/com/example/App.java new file mode 100644 index 0000000..1051dc4 --- /dev/null +++ b/src/main/java/com/example/App.java @@ -0,0 +1,9 @@ +package com.example; + +public class App +{ + public static void main( String[] args ) + { + + } +} diff --git a/src/main/java/com/example/Calculator.java b/src/main/java/com/example/Calculator.java new file mode 100644 index 0000000..9d1a45a --- /dev/null +++ b/src/main/java/com/example/Calculator.java @@ -0,0 +1,11 @@ +package com.example; + +public class Calculator { + public int add(int a, int b) { + return a + b; + } + + public int subtract(int a, int b) { + return a - b; + } +} \ No newline at end of file diff --git a/src/test/java/com/example/CalculatorTest.java b/src/test/java/com/example/CalculatorTest.java new file mode 100644 index 0000000..575f928 --- /dev/null +++ b/src/test/java/com/example/CalculatorTest.java @@ -0,0 +1,18 @@ +package com.example; + +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + +class CalculatorTest { + @Test + void testAdd() { + Calculator calculator = new Calculator(); + assertEquals(5, calculator.add(2, 3)); + } + + @Test + void testSubtract() { + Calculator calculator = new Calculator(); + assertEquals(2, calculator.subtract(5, 3)); + } +} \ No newline at end of file