commit 2a09218de5641c286516314599a19f52a28bc23a Author: Maxime Pierront <46542631+MaximePIERRONT@users.noreply.github.com> Date: Sat Oct 19 16:05:29 2024 +0200 first commit 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 0000000..f081527 Binary files /dev/null and b/README.md differ 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