Skip to content

Commit f67ccbb

Browse files
authored
Test C++ executable on multiple Linux distributions in Github Actions (#19)
1 parent a399504 commit f67ccbb

3 files changed

Lines changed: 215 additions & 4 deletions

File tree

.github/workflows/build-windows.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,16 @@ jobs:
6969
name: win-ia32-mailsync
7070
path: Windows/mailsync.tar.gz
7171

72-
# Validate that the program exits with code 1 (missing arguments). If any DLLs are missing that
72+
# Validate that the program exits with code 0 (help/usage shown). If any DLLs are missing that
7373
# prevent the application from starting, a code like -1073741515 will be returned.
7474
- name: Validate executable
7575
shell: pwsh
7676
run: |
7777
$process = Start-Process -FilePath "..\app\dist\mailsync.exe" -PassThru -Wait -NoNewWindow
7878
$exitCode = $process.ExitCode
7979
80-
if ($exitCode -ne 1) {
81-
Write-Host "We expected mailsync.exe to exit with code 1, but we got $exitCode instead."
80+
if ($exitCode -ne 0) {
81+
Write-Host "We expected mailsync.exe to exit with code 0, but we got $exitCode instead."
8282
exit 1
8383
} else {
8484
Write-Host "Exit code was as expected: $exitCode"

.github/workflows/build.yml

Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,221 @@ jobs:
9999
fi
100100
aws s3 sync ../app/dist s3://mailspring-builds/mailsync/${GITHUB_SHA:0:8}/${OS_DIR}/ --delete
101101
102+
- name: Copy Linux artifact for upload
103+
if: runner.os == 'Linux'
104+
run: cp ../app/dist/mailsync.tar.gz ./mailsync.tar.gz
105+
106+
- name: Upload Linux artifact for distribution testing
107+
if: runner.os == 'Linux'
108+
uses: actions/upload-artifact@v4
109+
with:
110+
name: mailsync-linux
111+
path: mailsync.tar.gz
112+
retention-days: 1
113+
102114
- name: Cache build dependencies
103115
uses: actions/cache@v4
104116
with:
105117
path: /tmp/mailsync-build-deps-v2
106118
key: ${{ runner.os }}-mailsync-deps-${{ hashFiles('**/build.sh') }}
107119
restore-keys: |
108120
${{ runner.os }}-mailsync-deps-
121+
122+
test-fedora:
123+
needs: build
124+
runs-on: ubuntu-22.04
125+
strategy:
126+
matrix:
127+
fedora_version: ['40', '41']
128+
steps:
129+
- name: Download artifact
130+
uses: actions/download-artifact@v4
131+
with:
132+
name: mailsync-linux
133+
134+
- name: Test on Fedora ${{ matrix.fedora_version }}
135+
run: |
136+
docker run --rm -v ${{ github.workspace }}:/workspace fedora:${{ matrix.fedora_version }} bash -c "
137+
set -e
138+
echo '=== Testing mailsync on Fedora ${{ matrix.fedora_version }} ==='
139+
140+
# Install required runtime dependencies (from RPM spec)
141+
dnf install -y glibc libstdc++ libcurl openssl libicu libuuid cyrus-sasl-lib \
142+
libXScrnSaver libsecret libtidy ca-certificates libappindicator-gtk3 file
143+
144+
# Extract to a directory containing 'mailspring' in the path
145+
# (required by branding check in main.cpp that exits with code 2)
146+
cd /workspace
147+
mkdir -p mailspring
148+
cd mailspring
149+
tar -xzf ../mailsync.tar.gz
150+
151+
# Debug: show extracted files and binary info
152+
echo 'Extracted files:'
153+
ls -la
154+
echo ''
155+
echo 'Wrapper script (mailsync):'
156+
cat ./mailsync
157+
echo ''
158+
echo 'Binary info (mailsync.bin):'
159+
file ./mailsync.bin
160+
echo ''
161+
162+
echo 'Checking for missing shared libraries:'
163+
ldd ./mailsync.bin || true
164+
echo ''
165+
166+
# Run mailsync via wrapper (wrapper sets LD_LIBRARY_PATH and SASL_PATH)
167+
echo 'Running mailsync --help...'
168+
./mailsync --help > /tmp/output.txt 2>&1; EXIT_CODE=\$?
169+
cat /tmp/output.txt
170+
echo ''
171+
echo \"Exit code: \$EXIT_CODE\"
172+
echo ''
173+
174+
# Verify help message is printed
175+
if grep -q 'USAGE:' /tmp/output.txt && grep -q 'CONFIG_DIR_PATH' /tmp/output.txt; then
176+
echo '✓ mailsync runs successfully and prints help message on Fedora ${{ matrix.fedora_version }}'
177+
else
178+
echo '✗ mailsync failed to print expected help message'
179+
echo 'Output was:'
180+
cat /tmp/output.txt
181+
echo ''
182+
echo 'Checking for missing libraries (not found):'
183+
ldd ./mailsync.bin 2>&1 | grep 'not found' || echo 'No missing libraries detected'
184+
exit 1
185+
fi
186+
"
187+
188+
test-arch:
189+
needs: build
190+
runs-on: ubuntu-22.04
191+
steps:
192+
- name: Download artifact
193+
uses: actions/download-artifact@v4
194+
with:
195+
name: mailsync-linux
196+
197+
- name: Test on Arch Linux
198+
run: |
199+
docker run --rm -v ${{ github.workspace }}:/workspace archlinux:latest bash -c "
200+
set -e
201+
echo '=== Testing mailsync on Arch Linux ==='
202+
203+
# Update package database and install required runtime dependencies
204+
# Only install what mailsync CLI actually needs (not GUI dependencies)
205+
pacman -Syu --noconfirm
206+
pacman -S --noconfirm glibc gcc-libs curl openssl icu util-linux-libs cyrus-sasl file \
207+
libsecret tidy ca-certificates libgcrypt nss glib2
208+
209+
# Extract to a directory containing 'mailspring' in the path
210+
# (required by branding check in main.cpp that exits with code 2)
211+
cd /workspace
212+
mkdir -p mailspring
213+
cd mailspring
214+
tar -xzf ../mailsync.tar.gz
215+
216+
# Debug: show extracted files and binary info
217+
echo 'Extracted files:'
218+
ls -la
219+
echo ''
220+
echo 'Wrapper script (mailsync):'
221+
cat ./mailsync
222+
echo ''
223+
echo 'Binary info (mailsync.bin):'
224+
file ./mailsync.bin
225+
echo ''
226+
227+
echo 'Checking for missing shared libraries:'
228+
ldd ./mailsync.bin || true
229+
echo ''
230+
231+
# Run mailsync via wrapper (wrapper sets LD_LIBRARY_PATH and SASL_PATH)
232+
echo 'Running mailsync --help...'
233+
./mailsync --help > /tmp/output.txt 2>&1; EXIT_CODE=\$?
234+
cat /tmp/output.txt
235+
echo ''
236+
echo \"Exit code: \$EXIT_CODE\"
237+
echo ''
238+
239+
# Verify help message is printed
240+
if grep -q 'USAGE:' /tmp/output.txt && grep -q 'CONFIG_DIR_PATH' /tmp/output.txt; then
241+
echo '✓ mailsync runs successfully and prints help message on Arch Linux'
242+
else
243+
echo '✗ mailsync failed to print expected help message'
244+
echo 'Output was:'
245+
cat /tmp/output.txt
246+
echo ''
247+
echo 'Checking for missing libraries (not found):'
248+
ldd ./mailsync.bin 2>&1 | grep 'not found' || echo 'No missing libraries detected'
249+
exit 1
250+
fi
251+
"
252+
253+
test-ubuntu:
254+
needs: build
255+
runs-on: ubuntu-22.04
256+
strategy:
257+
matrix:
258+
ubuntu_version: ['22.04', '24.04']
259+
steps:
260+
- name: Download artifact
261+
uses: actions/download-artifact@v4
262+
with:
263+
name: mailsync-linux
264+
265+
- name: Test on Ubuntu ${{ matrix.ubuntu_version }}
266+
run: |
267+
docker run --rm -v ${{ github.workspace }}:/workspace ubuntu:${{ matrix.ubuntu_version }} bash -c "
268+
set -e
269+
echo '=== Testing mailsync on Ubuntu ${{ matrix.ubuntu_version }} ==='
270+
271+
# Install required runtime dependencies (from debian control.in)
272+
apt-get update
273+
apt-get install -y libcurl4 libssl3 libicu-dev uuid-runtime libsasl2-2 \
274+
libsecret-1-dev libgtk2.0-0 libudev1 libgcrypt20 libnotify4 libxtst6 \
275+
libnss3 libglib2.0-bin xdg-utils libtidy-dev file
276+
277+
# Extract to a directory containing 'mailspring' in the path
278+
# (required by branding check in main.cpp that exits with code 2)
279+
cd /workspace
280+
mkdir -p mailspring
281+
cd mailspring
282+
tar -xzf ../mailsync.tar.gz
283+
284+
# Debug: show extracted files and binary info
285+
echo 'Extracted files:'
286+
ls -la
287+
echo ''
288+
echo 'Wrapper script (mailsync):'
289+
cat ./mailsync
290+
echo ''
291+
echo 'Binary info (mailsync.bin):'
292+
file ./mailsync.bin
293+
echo ''
294+
295+
echo 'Checking for missing shared libraries:'
296+
ldd ./mailsync.bin || true
297+
echo ''
298+
299+
# Run mailsync via wrapper (wrapper sets LD_LIBRARY_PATH and SASL_PATH)
300+
echo 'Running mailsync --help...'
301+
./mailsync --help > /tmp/output.txt 2>&1; EXIT_CODE=\$?
302+
cat /tmp/output.txt
303+
echo ''
304+
echo \"Exit code: \$EXIT_CODE\"
305+
echo ''
306+
307+
# Verify help message is printed
308+
if grep -q 'USAGE:' /tmp/output.txt && grep -q 'CONFIG_DIR_PATH' /tmp/output.txt; then
309+
echo '✓ mailsync runs successfully and prints help message on Ubuntu ${{ matrix.ubuntu_version }}'
310+
else
311+
echo '✗ mailsync failed to print expected help message'
312+
echo 'Output was:'
313+
cat /tmp/output.txt
314+
echo ''
315+
echo 'Checking for missing libraries (not found):'
316+
ldd ./mailsync.bin 2>&1 | grep 'not found' || echo 'No missing libraries detected'
317+
exit 1
318+
fi
319+
"

MailSync/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ string exectuablePath = argv[0];
542542

543543
if (options[HELP] || argc == 0) {
544544
option::printUsage(std::cout, usage);
545-
return 1;
545+
return 0;
546546
}
547547

548548
// check required environment

0 commit comments

Comments
 (0)