Skip to content

Commit bc1e5f0

Browse files
committed
Extend jobs to run android and report binary sizes
1 parent 2049052 commit bc1e5f0

1 file changed

Lines changed: 127 additions & 1 deletion

File tree

.github/workflows/build.yml

Lines changed: 127 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ env:
1212
CTEST_OUTPUT_ON_FAILURE: 1
1313

1414
jobs:
15-
build:
15+
desktop-build:
1616
runs-on: ${{ matrix.os }}
1717
strategy:
1818
fail-fast: false
@@ -74,3 +74,129 @@ jobs:
7474
run: |
7575
ctest --test-dir "${{ env.CMAKE_BUILD_DIR }}"
7676
77+
- name: Record binary size
78+
shell: bash
79+
run: |
80+
mkdir -p size-report
81+
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
82+
LIB_FILE=$(find "${{ env.CMAKE_BUILD_DIR }}" -name "sframe.lib" -o -name "sframe.dll" | head -1)
83+
else
84+
LIB_FILE=$(find "${{ env.CMAKE_BUILD_DIR }}" -name "libsframe.a" -o -name "libsframe.so" | head -1)
85+
fi
86+
if [ -n "$LIB_FILE" ]; then
87+
SIZE=$(stat --printf="%s" "$LIB_FILE" 2>/dev/null || stat -f%z "$LIB_FILE" 2>/dev/null)
88+
echo "${{ matrix.os }},${{ matrix.crypto }},no_alloc=${{ matrix.no_alloc }},${SIZE}" > size-report/desktop-${{ matrix.os }}-${{ matrix.crypto }}-${{ matrix.no_alloc }}.csv
89+
fi
90+
91+
- name: Upload size report
92+
uses: actions/upload-artifact@v4
93+
with:
94+
name: size-desktop-${{ matrix.os }}-${{ matrix.crypto }}-no_alloc_${{ matrix.no_alloc }}
95+
path: size-report/
96+
97+
android-build:
98+
runs-on: ubuntu-latest
99+
strategy:
100+
fail-fast: false
101+
matrix:
102+
crypto: [OPENSSL_1_1, OPENSSL_3, BORINGSSL]
103+
abi: [arm64-v8a, armeabi-v7a, x86_64]
104+
no_alloc: [OFF, ON]
105+
include:
106+
- abi: arm64-v8a
107+
vcpkg-triplet: arm64-android
108+
- abi: armeabi-v7a
109+
vcpkg-triplet: arm-neon-android
110+
- abi: x86_64
111+
vcpkg-triplet: x64-android
112+
113+
env:
114+
CMAKE_BUILD_DIR: ${{ github.workspace }}/build
115+
CMAKE_GENERATOR: "Ninja"
116+
117+
steps:
118+
- uses: actions/checkout@v4
119+
120+
- name: dependencies
121+
run: |
122+
sudo apt-get install -y nasm ninja-build
123+
124+
- name: Restore cache
125+
uses: actions/cache@v4
126+
with:
127+
path: |
128+
${{ env.CMAKE_BUILD_DIR }}/vcpkg_installed
129+
key: android-${{ matrix.abi }}-${{ matrix.crypto }}-${{ hashFiles( '**/vcpkg.json' ) }}
130+
131+
- name: configure
132+
run: cmake -B "${{ env.CMAKE_BUILD_DIR }}"
133+
-DCMAKE_TOOLCHAIN_FILE="$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake"
134+
-DVCPKG_TARGET_TRIPLET="${{ matrix.vcpkg-triplet }}"
135+
-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE="$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake"
136+
-DANDROID_ABI="${{ matrix.abi }}"
137+
-DANDROID_PLATFORM=android-24
138+
-DCRYPTO="${{ matrix.crypto }}"
139+
-DVCPKG_MANIFEST_DIR="alternatives/${{ matrix.crypto }}"
140+
-DNO_ALLOC="${{ matrix.no_alloc }}"
141+
142+
- name: build
143+
run: cmake --build "${{ env.CMAKE_BUILD_DIR }}" --config Release
144+
145+
- name: Record binary size
146+
run: |
147+
mkdir -p size-report
148+
LIB_FILE=$(find "${{ env.CMAKE_BUILD_DIR }}" -name "libsframe.a" -o -name "libsframe.so" | head -1)
149+
if [ -n "$LIB_FILE" ]; then
150+
SIZE=$(stat --printf="%s" "$LIB_FILE")
151+
echo "android-${{ matrix.abi }},${{ matrix.crypto }},no_alloc=${{ matrix.no_alloc }},${SIZE}" > size-report/android-${{ matrix.abi }}-${{ matrix.crypto }}-${{ matrix.no_alloc }}.csv
152+
fi
153+
154+
- name: Upload size report
155+
uses: actions/upload-artifact@v4
156+
with:
157+
name: size-android-${{ matrix.abi }}-${{ matrix.crypto }}-no_alloc_${{ matrix.no_alloc }}
158+
path: size-report/
159+
160+
size-report:
161+
if: github.event_name == 'pull_request'
162+
needs: [desktop-build, android-build]
163+
runs-on: ubuntu-latest
164+
permissions:
165+
pull-requests: write
166+
steps:
167+
- name: Download all size reports
168+
uses: actions/download-artifact@v4
169+
with:
170+
pattern: size-*
171+
merge-multiple: true
172+
path: sizes
173+
174+
- name: Generate summary comment
175+
run: |
176+
{
177+
echo "## 📦 Binary Size Report"
178+
echo ""
179+
echo "| Platform | Crypto | Config | Size |"
180+
echo "|----------|--------|--------|------|"
181+
for f in sizes/*.csv; do
182+
[ -f "$f" ] || continue
183+
while IFS=, read -r platform crypto config size; do
184+
if [ "$size" -ge 1048576 ] 2>/dev/null; then
185+
human_size="$(awk "BEGIN {printf \"%.2f MiB\", $size/1048576}")"
186+
elif [ "$size" -ge 1024 ] 2>/dev/null; then
187+
human_size="$(awk "BEGIN {printf \"%.2f KiB\", $size/1024}")"
188+
else
189+
human_size="${size} B"
190+
fi
191+
echo "| ${platform} | ${crypto} | ${config} | ${human_size} |"
192+
done < "$f"
193+
done
194+
} > comment-body.md
195+
cat comment-body.md
196+
197+
- name: Post PR comment
198+
uses: marocchino/sticky-pull-request-comment@v2
199+
with:
200+
header: binary-size-report
201+
path: comment-body.md
202+

0 commit comments

Comments
 (0)