From bf600c6688ae7c0e26cd816e9d6aae21d597e6ef Mon Sep 17 00:00:00 2001 From: SIM <simeonlama00@gmail.com> Date: Sun, 9 Mar 2025 01:09:41 +0100 Subject: [PATCH 1/4] La fonction fibonnacci et les tests --- src/main/java/algorithms/Fibonacci.java | 4 ++++ src/test/java/{FactorialTest.java => AlgorithmTest.java} | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 src/main/java/algorithms/Fibonacci.java rename src/test/java/{FactorialTest.java => AlgorithmTest.java} (99%) diff --git a/src/main/java/algorithms/Fibonacci.java b/src/main/java/algorithms/Fibonacci.java new file mode 100644 index 0000000..ae6c7c1 --- /dev/null +++ b/src/main/java/algorithms/Fibonacci.java @@ -0,0 +1,4 @@ +package algorithms; + +public class Fibonacci { +} diff --git a/src/test/java/FactorialTest.java b/src/test/java/AlgorithmTest.java similarity index 99% rename from src/test/java/FactorialTest.java rename to src/test/java/AlgorithmTest.java index 7b59bc8..6b2d259 100644 --- a/src/test/java/FactorialTest.java +++ b/src/test/java/AlgorithmTest.java @@ -11,4 +11,4 @@ public class FactorialTest { public void testFactorial(){ assertEquals(6, Factorial.calculate(3)); } -} +} \ No newline at end of file -- GitLab From 22f69d6db9c5bd34b88bdbf99ed8cc750ae29b92 Mon Sep 17 00:00:00 2001 From: SIM <simeonlama00@gmail.com> Date: Sun, 9 Mar 2025 01:29:47 +0100 Subject: [PATCH 2/4] essayer les teste sur gitlab --- .github/workflow/RunTests.yml | 29 +++++++++++++++++++++++++ src/main/java/algorithms/Fibonacci.java | 6 +++++ src/test/java/AlgorithmTest.java | 9 +++++++- 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 .github/workflow/RunTests.yml diff --git a/.github/workflow/RunTests.yml b/.github/workflow/RunTests.yml new file mode 100644 index 0000000..5f09fc9 --- /dev/null +++ b/.github/workflow/RunTests.yml @@ -0,0 +1,29 @@ + name: Run Tests + + # Exécuter le workflow sur chaque "push" (ou pull request si nécessaire) + on: + push: + branches: + - main # Déclenche sur la branche "main" (vous pouvez modifier selon votre branche) + pull_request: + branches: + - main + + jobs: + test: + runs-on: ubuntu-latest + + steps: + # Étape 1 : Récupérer le code source + - name: Checkout repository + uses: actions/checkout@v3 + + # Étape 2 : Configurer Java + - name: Set up JDK + uses: actions/setup-java@v3 + with: + java-version: '17' # Remplacez par la version Java utilisée par votre projet + + # Étape 3 : Installer les dépendances et exécuter les tests + - name: Run tests with Maven + run: mvn test \ No newline at end of file diff --git a/src/main/java/algorithms/Fibonacci.java b/src/main/java/algorithms/Fibonacci.java index ae6c7c1..ea2b72c 100644 --- a/src/main/java/algorithms/Fibonacci.java +++ b/src/main/java/algorithms/Fibonacci.java @@ -1,4 +1,10 @@ package algorithms; public class Fibonacci { + public static int calculate(int n){ + if(n <= 1){ + return n; + } + return calculate(n-1) + calculate(n-2); + } } diff --git a/src/test/java/AlgorithmTest.java b/src/test/java/AlgorithmTest.java index 6b2d259..72c6f87 100644 --- a/src/test/java/AlgorithmTest.java +++ b/src/test/java/AlgorithmTest.java @@ -1,14 +1,21 @@ import algorithms.Factorial; +import algorithms.Fibonacci; import org.javagrader.Grade; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; @Grade -public class FactorialTest { +public class AlgorithmTest { @Test @Grade(value = 1) public void testFactorial(){ assertEquals(6, Factorial.calculate(3)); } + + @Test + @Grade(value = 1) + public void testFibonacci(){ + assertEquals(55, Fibonacci.calculate(10)); + } } \ No newline at end of file -- GitLab From 21c05d9b221f6c51133a0dac8802dbd5233871cb Mon Sep 17 00:00:00 2001 From: SIM <simeonlama00@gmail.com> Date: Sun, 9 Mar 2025 01:36:22 +0100 Subject: [PATCH 3/4] les testes automatique sur git --- .github/workflow/RunTests.yml | 29 ----------------------------- .github/workflow/ci.yml | 29 +++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 29 deletions(-) delete mode 100644 .github/workflow/RunTests.yml create mode 100644 .github/workflow/ci.yml diff --git a/.github/workflow/RunTests.yml b/.github/workflow/RunTests.yml deleted file mode 100644 index 5f09fc9..0000000 --- a/.github/workflow/RunTests.yml +++ /dev/null @@ -1,29 +0,0 @@ - name: Run Tests - - # Exécuter le workflow sur chaque "push" (ou pull request si nécessaire) - on: - push: - branches: - - main # Déclenche sur la branche "main" (vous pouvez modifier selon votre branche) - pull_request: - branches: - - main - - jobs: - test: - runs-on: ubuntu-latest - - steps: - # Étape 1 : Récupérer le code source - - name: Checkout repository - uses: actions/checkout@v3 - - # Étape 2 : Configurer Java - - name: Set up JDK - uses: actions/setup-java@v3 - with: - java-version: '17' # Remplacez par la version Java utilisée par votre projet - - # Étape 3 : Installer les dépendances et exécuter les tests - - name: Run tests with Maven - run: mvn test \ No newline at end of file diff --git a/.github/workflow/ci.yml b/.github/workflow/ci.yml new file mode 100644 index 0000000..e94219d --- /dev/null +++ b/.github/workflow/ci.yml @@ -0,0 +1,29 @@ +name: Java CI + +on: + push: + branches: + - main # Exécuter les tests quand on push sur la branche "main" + pull_request: + branches: + - main # Exécuter les tests lors d'un Pull Request vers "main" + +jobs: + test: + runs-on: ubuntu-latest # Utiliser Ubuntu comme environnement + + steps: + - name: Checkout du code + uses: actions/checkout@v3 + + - name: Configurer Java + uses: actions/setup-java@v3 + with: + distribution: 'temurin' # JDK OpenJDK de Eclipse Temurin + java-version: '17' # Remplace par ta version si nécessaire + + - name: Compiler le projet avec Maven + run: mvn clean package + + - name: Exécuter les tests Maven + run: mvn test -- GitLab From 1ba590ee20a9af006384bdf6399f0d32821054a9 Mon Sep 17 00:00:00 2001 From: SIM <simeonlama00@gmail.com> Date: Sun, 9 Mar 2025 01:56:02 +0100 Subject: [PATCH 4/4] les tests automatique --- .github/workflows/main.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..e94219d --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,29 @@ +name: Java CI + +on: + push: + branches: + - main # Exécuter les tests quand on push sur la branche "main" + pull_request: + branches: + - main # Exécuter les tests lors d'un Pull Request vers "main" + +jobs: + test: + runs-on: ubuntu-latest # Utiliser Ubuntu comme environnement + + steps: + - name: Checkout du code + uses: actions/checkout@v3 + + - name: Configurer Java + uses: actions/setup-java@v3 + with: + distribution: 'temurin' # JDK OpenJDK de Eclipse Temurin + java-version: '17' # Remplace par ta version si nécessaire + + - name: Compiler le projet avec Maven + run: mvn clean package + + - name: Exécuter les tests Maven + run: mvn test -- GitLab