-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: Detect unused code with Periphery (#1401)
- Loading branch information
Showing
6 changed files
with
86 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
<details> | ||
<summary>Expand</summary> | ||
``` | ||
${{ steps.periphery.outputs.detailed_output }} | ||
``` | ||
</details> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
[tools] | ||
tuist = '4.9.0' | ||
periphery = '2.18.0' | ||
swiftformat = '0.53.7' | ||
swiftlint = '0.54.0' | ||
swiftlint = '0.54.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<<EOF' >> $GITHUB_OUTPUT | ||
echo "$detailedOutput" >> $GITHUB_OUTPUT | ||
echo 'EOF' >> $GITHUB_OUTPUT | ||
|
||
echo "unused_count=$unusedCount" >> $GITHUB_OUTPUT |