-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathaction.yml
More file actions
142 lines (118 loc) · 4.56 KB
/
Copy pathaction.yml
File metadata and controls
142 lines (118 loc) · 4.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
name: 'Caliper - iOS App Size Analyzer'
description: 'Analyze iOS app bundle sizes down to the module level with beautiful interactive reports'
author: 'kibotu'
branding:
icon: 'pie-chart'
color: 'blue'
inputs:
ipa-path:
description: 'Path to the IPA file to analyze'
required: true
link-map-path:
description: 'Path to LinkMap file for accurate binary sizes'
required: false
ownership-file:
description: 'YAML file with module ownership patterns'
required: false
package-resolved-path:
description: 'Path to Package.resolved for version tracking'
required: false
package-mapping-file:
description: 'YAML file for namespaced package mappings'
required: false
output-dir:
description: 'Directory to output report files (defaults to current directory)'
required: false
default: '.'
outputs:
report-json:
description: 'Path to the generated JSON report'
value: ${{ steps.analyze.outputs.report-json }}
report-html:
description: 'Path to the generated HTML report'
value: ${{ steps.analyze.outputs.report-html }}
total-package-size:
description: 'Total IPA size in bytes'
value: ${{ steps.analyze.outputs.total-package-size }}
total-install-size:
description: 'Total installed app size in bytes'
value: ${{ steps.analyze.outputs.total-install-size }}
runs:
using: 'composite'
steps:
- name: Verify macOS runner
shell: bash
run: |
if [[ "$OSTYPE" != "darwin"* ]]; then
echo "❌ Error: Caliper requires macOS runner (uses Xcode tools)"
exit 1
fi
echo "✅ Running on macOS"
- name: Verify Xcode tools
shell: bash
run: |
echo "🔍 Checking required tools..."
if ! command -v swift &> /dev/null; then
echo "❌ Swift not found. Install Xcode Command Line Tools."
exit 1
fi
echo "✅ Swift: $(swift --version | head -n1)"
if ! command -v xcrun &> /dev/null; then
echo "❌ xcrun not found. Install Xcode Command Line Tools."
exit 1
fi
echo "✅ xcrun available"
if ! command -v unzip &> /dev/null; then
echo "❌ unzip not found"
exit 1
fi
echo "✅ unzip available"
- name: Build Caliper
shell: bash
run: |
echo "🔨 Building Caliper..."
cd ${{ github.action_path }}
swift build -c release
echo "✅ Caliper built successfully"
- name: Run Caliper Analysis
id: analyze
shell: bash
run: |
echo "📊 Running Caliper analysis..."
# Build command with required parameter
CMD="${{ github.action_path }}/.build/release/caliper --ipa-path ${{ inputs.ipa-path }}"
# Add optional parameters
if [ -n "${{ inputs.link-map-path }}" ]; then
CMD="$CMD --link-map-path ${{ inputs.link-map-path }}"
fi
if [ -n "${{ inputs.ownership-file }}" ]; then
CMD="$CMD --ownership-file ${{ inputs.ownership-file }}"
fi
if [ -n "${{ inputs.package-resolved-path }}" ]; then
CMD="$CMD --package-resolved-path ${{ inputs.package-resolved-path }}"
fi
if [ -n "${{ inputs.package-mapping-file }}" ]; then
CMD="$CMD --package-mapping-file ${{ inputs.package-mapping-file }}"
fi
# Change to output directory
cd "${{ inputs.output-dir }}"
# Run analysis
eval $CMD
echo "✅ Analysis complete!"
# Set outputs
REPORT_JSON="${{ inputs.output-dir }}/report.json"
REPORT_HTML="${{ inputs.output-dir }}/report.html"
echo "report-json=$REPORT_JSON" >> $GITHUB_OUTPUT
echo "report-html=$REPORT_HTML" >> $GITHUB_OUTPUT
# Extract sizes from JSON report
if [ -f "$REPORT_JSON" ]; then
PACKAGE_SIZE=$(grep -o '"totalPackageSize":[0-9]*' "$REPORT_JSON" | cut -d':' -f2)
INSTALL_SIZE=$(grep -o '"totalInstallSize":[0-9]*' "$REPORT_JSON" | cut -d':' -f2)
echo "total-package-size=$PACKAGE_SIZE" >> $GITHUB_OUTPUT
echo "total-install-size=$INSTALL_SIZE" >> $GITHUB_OUTPUT
# Display human-readable sizes
PACKAGE_MB=$(echo "scale=2; $PACKAGE_SIZE / 1024 / 1024" | bc)
INSTALL_MB=$(echo "scale=2; $INSTALL_SIZE / 1024 / 1024" | bc)
echo "📦 IPA Size: ${PACKAGE_MB} MB"
echo "💾 Install Size: ${INSTALL_MB} MB"
fi