diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 5929cb615..6b7479ebb 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -15,6 +15,8 @@ jobs:
with:
access_token: ${{ github.token }}
- uses: jdx/mise-action@v2
+ with:
+ cache: false
- name: Checkout
uses: actions/checkout@v2
- name: Create test env
diff --git a/.github/workflows/periphery.yml b/.github/workflows/periphery.yml
new file mode 100644
index 000000000..7d35025b7
--- /dev/null
+++ b/.github/workflows/periphery.yml
@@ -0,0 +1,35 @@
+name: CI workflow
+
+on:
+ pull_request:
+ branches: [ master ]
+
+jobs:
+ build:
+ name: Scan unused code
+ runs-on: [ self-hosted, iOS ]
+
+ steps:
+ - name: Cancel Previous Runs
+ uses: styfle/cancel-workflow-action@0.12.1
+ with:
+ access_token: ${{ github.token }}
+ - uses: jdx/mise-action@v2
+ with:
+ cache: false
+ - name: Checkout
+ uses: actions/checkout@v2
+ - name: Periphery
+ id: periphery
+ run: ./scripts/periphery.sh
+ - uses: mshick/add-pr-comment@v2
+ with:
+ message: |
+ Found ${{ steps.periphery.outputs.unused_count }} unused code occurences
+
+ Expand
+
+ ```
+ ${{ steps.periphery.outputs.detailed_output }}
+ ```
+
diff --git a/.github/workflows/uitests.yml b/.github/workflows/uitests.yml
index 3f02f0a8d..e5e270b13 100644
--- a/.github/workflows/uitests.yml
+++ b/.github/workflows/uitests.yml
@@ -15,6 +15,8 @@ jobs:
with:
access_token: ${{ github.token }}
- uses: jdx/mise-action@v2
+ with:
+ cache: false
- name: Checkout
uses: actions/checkout@v2
- name: Create test env
diff --git a/.mise.toml b/.mise.toml
index f412386bf..ba46e2475 100644
--- a/.mise.toml
+++ b/.mise.toml
@@ -1,4 +1,5 @@
[tools]
tuist = '4.9.0'
+periphery = '2.18.0'
swiftformat = '0.53.7'
-swiftlint = '0.54.0'
\ No newline at end of file
+swiftlint = '0.54.0'
diff --git a/.periphery.yml b/.periphery.yml
new file mode 100644
index 000000000..6e4d22d0a
--- /dev/null
+++ b/.periphery.yml
@@ -0,0 +1,19 @@
+clean_build: true
+retain_objc_accessible: true
+retain_public: true
+schemes:
+- Infomaniak Mail
+- MailAppIntentsExtension
+- MailCore
+- MailCoreUI
+- MailNotificationServiceExtension
+- MailResources
+- MailShareExtension
+targets:
+- Infomaniak Mail
+- MailAppIntentsExtension
+- MailCore
+- MailNotificationServiceExtension
+- MailResources
+- MailShareExtension
+workspace: Mail.xcworkspace
diff --git a/scripts/periphery.sh b/scripts/periphery.sh
new file mode 100755
index 000000000..97c6a99d6
--- /dev/null
+++ b/scripts/periphery.sh
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+eval "$($HOME/.local/bin/mise activate -C $SRCROOT bash --shims)"
+
+tuist install
+tuist generate -n
+
+
+# Perform the periphery scan and handle directory removal based on argument
+if [[ "$1" == "--full-dir" ]]; then
+ detailedOutput=$(periphery scan --quiet --enable-unused-import-analysis)
+else
+ detailedOutput=$(periphery scan --quiet --enable-unused-import-analysis | sed "s|$(pwd)/||g")
+fi
+
+unusedCount=$(wc -l <<< "$detailedOutput" | tr -d '[:space:]')
+
+echo "$detailedOutput"
+echo "Total unused instances $unusedCount"
+
+# Output script result to GITHUB_OUTPUT to get it in next step
+echo 'detailed_output<> $GITHUB_OUTPUT
+echo "$detailedOutput" >> $GITHUB_OUTPUT
+echo 'EOF' >> $GITHUB_OUTPUT
+
+echo "unused_count=$unusedCount" >> $GITHUB_OUTPUT