From bc089c28cd9330487e91ef7448769920cc4182ef Mon Sep 17 00:00:00 2001 From: Samuel Lebailly Date: Mon, 17 Mar 2025 08:05:39 +0100 Subject: [PATCH 1/5] Feature(RA-37): fix indentation error on epic CI . --- .github/workflows/ci-epic.yml | 55 +++++++++++++++++------------------ 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/.github/workflows/ci-epic.yml b/.github/workflows/ci-epic.yml index 71aa9df..59d3e32 100644 --- a/.github/workflows/ci-epic.yml +++ b/.github/workflows/ci-epic.yml @@ -38,34 +38,33 @@ jobs: - name: Download dependencies run: ./gradlew dependencies - # Step : Lancer les tests unitaire + jacocoreport - - name: Run Tests/generate Jacoco cover report - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - uses: reactivecircus/android-emulator-runner@v2 - with: - target: google_apis - arch: x86_64 - api-level: 35 - script: | - echo "--- [Waiting for emulator to stabilize...]" - #sleep 30 - adb wait-for-device - - echo "--- [Unlocking emulator screen...]" - adb shell input keyevent 82 - adb shell wm dismiss-keyguard - - echo "--- [Lint debug]" - ./gradlew lintDebug - - echo "--- [Generating Jacoco report...]" - ./gradlew jacocoReport - - echo "--- [Checking if Jacoco report exists...]" - ls app/build/reports/jacoco/jacocoTestReport - cat app/build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml || echo " [X] - Jacoco report not found" - +# Step : Lancer les tests unitaire + jacocoreport + - name: Run Tests/generate Jacoco cover report + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + uses: reactivecircus/android-emulator-runner@v2 + with: + target: google_apis + arch: x86_64 + api-level: 35 + script: | + echo "--- [Waiting for emulator to stabilize...]" + #sleep 30 + adb wait-for-device + + echo "--- [Unlocking emulator screen...]" + adb shell input keyevent 82 + adb shell wm dismiss-keyguard + + echo "--- [Lint debug]" + ./gradlew lintDebug + + echo "--- [Generating Jacoco report...]" + ./gradlew jacocoReport + + echo "--- [Checking if Jacoco report exists...]" + ls app/build/reports/jacoco/jacocoTestReport + cat app/build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml || echo " [X] - Jacoco report not found" # Step 6 : Vérification du statut du job - name: Fail PR on error From b5bbf98cb8d8c7eda1676ed47fb3847df84d0222 Mon Sep 17 00:00:00 2001 From: Samuel Lebailly Date: Mon, 17 Mar 2025 08:10:48 +0100 Subject: [PATCH 2/5] Feature(RA-37): Reduce CI Job between classic branch and Epic branch . --- .github/workflows/ci-epic.yml | 43 +++++++---------------------------- 1 file changed, 8 insertions(+), 35 deletions(-) diff --git a/.github/workflows/ci-epic.yml b/.github/workflows/ci-epic.yml index 59d3e32..4386739 100644 --- a/.github/workflows/ci-epic.yml +++ b/.github/workflows/ci-epic.yml @@ -4,7 +4,7 @@ on: pull_request: branches: - "epic/**" - types: [opened, synchronize, reopened] + types: [opened, synchronize, reopened, ready_for_review, edited] jobs: unit-tests: @@ -27,44 +27,17 @@ jobs: - name: Make gradlew executable run: chmod +x ./gradlew - # Step 4 : Reconstruire le fichier keystore à partir du secret - - name: Decode keystore file - run: | - echo "${{ secrets.KEYSTORE_FILE_BASE64 }}" | base64 -d > app/rebonnte-release-key.jks - ls -la app/ - - # Step 4 : Installation des dépendances du projet - name: Download dependencies run: ./gradlew dependencies -# Step : Lancer les tests unitaire + jacocoreport - - name: Run Tests/generate Jacoco cover report - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - uses: reactivecircus/android-emulator-runner@v2 - with: - target: google_apis - arch: x86_64 - api-level: 35 - script: | - echo "--- [Waiting for emulator to stabilize...]" - #sleep 30 - adb wait-for-device - - echo "--- [Unlocking emulator screen...]" - adb shell input keyevent 82 - adb shell wm dismiss-keyguard - - echo "--- [Lint debug]" - ./gradlew lintDebug - - echo "--- [Generating Jacoco report...]" - ./gradlew jacocoReport - - echo "--- [Checking if Jacoco report exists...]" - ls app/build/reports/jacoco/jacocoTestReport - cat app/build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml || echo " [X] - Jacoco report not found" + # Step 5 : Exécution des tests unitaires et analyse lint + - name: Run Unit Tests & Lint + run: | + echo "--- [Running Lint...]" + ./gradlew lintDebug + echo "--- [Running Unit Tests...]" + ./gradlew testDebugUnitTest # Step 6 : Vérification du statut du job - name: Fail PR on error From f5e2dc1ada995620a324dc511d3e3ebb8aa750ec Mon Sep 17 00:00:00 2001 From: Samuel Lebailly Date: Mon, 17 Mar 2025 08:32:18 +0100 Subject: [PATCH 3/5] Feature(RA-37): Update the main branch CI to init the CD on firebase. --- .github/workflows/ci-main.yml | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-main.yml b/.github/workflows/ci-main.yml index 0628894..7560463 100644 --- a/.github/workflows/ci-main.yml +++ b/.github/workflows/ci-main.yml @@ -8,7 +8,7 @@ on: jobs: - unit-tests: + build: runs-on: ubuntu-latest steps: @@ -99,4 +99,28 @@ jobs: # Step : No Validation PR en cas d'échec - name: Clearance PR if: ${{ failure() }} - run: echo "Build ou analyse de qualité échouée, PR bloquée." \ No newline at end of file + run: echo "Build ou analyse de qualité échouée, PR bloquée." + + # Step : firebase deploy + deploy: + needs: build + if: github.event_name == 'pull_request' && github.ref == 'refs/heads/main + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Download APK Artifact + uses: actions/download-artifact@v4 + with: + name: release-apk + path: app/build/outputs/apk/release/ + + - name: Upload artifact to Firebase App Distribution + uses: wzieba/Firebase-Distribution-Github-Action@v1.5.1 + with: + appId: ${{secrets.FIREBASE_APP_ID}} + token: ${{secrets.FIREBASE_TOKEN}} + #serviceCredentialsFileContent: ${{ secrets.CREDENTIAL_FILE_CONTENT }} + groups: testers + file: app/build/outputs/apk/release/app-release.apk \ No newline at end of file From ccfa4c0b6755d5fb9fdd9a10920a686171a78665 Mon Sep 17 00:00:00 2001 From: Samuel Lebailly Date: Mon, 17 Mar 2025 08:41:02 +0100 Subject: [PATCH 4/5] Feature(RA-37): Fix epic CI keystore fail. --- .github/workflows/ci-epic.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci-epic.yml b/.github/workflows/ci-epic.yml index 4386739..4e72710 100644 --- a/.github/workflows/ci-epic.yml +++ b/.github/workflows/ci-epic.yml @@ -27,6 +27,12 @@ jobs: - name: Make gradlew executable run: chmod +x ./gradlew + # Step 3.5 : Reconstruire le fichier keystore à partir du secret + - name: Decode keystore file + run: | + echo "${{ secrets.KEYSTORE_FILE_BASE64 }}" | base64 -d > app/rebonnte-release-key.jks + ls -la app/ + # Step 4 : Installation des dépendances du projet - name: Download dependencies run: ./gradlew dependencies From 59367446722ad0a9497c1b45a53e0fe94726edb4 Mon Sep 17 00:00:00 2001 From: Samuel Lebailly Date: Mon, 17 Mar 2025 09:04:39 +0100 Subject: [PATCH 5/5] Feature(RA-37): Fix develop CI --- .github/workflows/ci-develop.yml | 61 ++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 26 deletions(-) diff --git a/.github/workflows/ci-develop.yml b/.github/workflows/ci-develop.yml index 1b2048b..4baf3a3 100644 --- a/.github/workflows/ci-develop.yml +++ b/.github/workflows/ci-develop.yml @@ -5,7 +5,6 @@ on: branches: - "develop" - jobs: unit-tests: runs-on: ubuntu-latest @@ -32,42 +31,52 @@ jobs: run: | echo "${{ secrets.KEYSTORE_FILE_BASE64 }}" | base64 -d > app/rebonnte-release-key.jks ls -la app/ + + + #start emulator and run instrumented tests + - name: Enable KVM + run: | + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules + sudo udevadm control --reload-rules + sudo udevadm trigger --name-match=kvm + # Step : Récupérer l'historique Git complet pour SonarCloud + - name: Fetch full Git history + run: git fetch --unshallow # Step 4 : Installation des dépendances du projet - name: Download dependencies run: ./gradlew dependencies - - # Step : Lancer les tests unitaire + jacocoreport - - name: Run Tests/generate Jacoco cover report + + # Step : Lancer les tests unitaire et instrumented + jacocoreport + sonar analyse + - name: Run Tests/generate Jacoco cover report and Sonar Quality Gate analyse env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} uses: reactivecircus/android-emulator-runner@v2 with: target: google_apis arch: x86_64 api-level: 35 script: | - echo "--- [Waiting for emulator to stabilize...]" - #sleep 30 - adb wait-for-device - - echo "--- [Unlocking emulator screen...]" - adb shell input keyevent 82 - adb shell wm dismiss-keyguard - - echo "--- [Lint debug]" - ./gradlew lintDebug - - echo "--- [Generating Jacoco report...]" - ./gradlew jacocoReport - - echo "--- [Checking if Jacoco report exists...]" - ls app/build/reports/jacoco/jacocoTestReport - cat app/build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml || echo " [X] - Jacoco report not found" - + echo "--- [Waiting for emulator to stabilize...]" + #sleep 30 + adb wait-for-device + + echo "--- [Unlocking emulator screen...]" + adb shell input keyevent 82 + adb shell wm dismiss-keyguard + + echo "--- [Lint debug]" + ./gradlew lintDebug + + echo "--- [Generating Jacoco report...]" + ./gradlew jacocoReport + + echo "--- [Checking if Jacoco report exists...]" + ls app/build/reports/jacoco/jacocoTestReport + cat app/build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml || echo " [X] - Jacoco report not found" - # Step 6 : Vérification du statut du job - - name: Fail PR on error + # Step : No Validation PR en cas d'échec + - name: Clearance PR if: ${{ failure() }} - run: exit 1 \ No newline at end of file + run: echo "Build ou analyse de qualité échouée, PR bloquée." \ No newline at end of file