Skip to content

Commit c0c3ab0

Browse files
committed
add CI tests
1 parent 258b598 commit c0c3ab0

3 files changed

Lines changed: 107 additions & 0 deletions

File tree

.github/scripts/run_tests.sh

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#!/bin/sh -eu
2+
3+
case "$RUNNER_OS" in
4+
Linux)
5+
ug_build=UltraGrid-continuous-x86_64.AppImage
6+
prepare() {
7+
chmod +x "$ug_build"
8+
./"$ug_build" --appimage-extract
9+
}
10+
run=squashfs-root/AppRun
11+
;;
12+
Windows)
13+
ug_build=UltraGrid-continuous-win64.zip
14+
prepare() {
15+
unzip "$ug_build"
16+
}
17+
run=UltraGrid-continuous-win64/uv.exe
18+
;;
19+
macOS)
20+
ug_build=UltraGrid-continuous-arm64.dmg
21+
prepare() {
22+
hdiutil mount "$ug_build"
23+
}
24+
run=/Volumes/ULTRAGRID/uv-qt.app/Contents/MacOS/uv
25+
esac
26+
27+
curl -LOf https://github.com/CESNET/UltraGrid/releases/download/continuous/\
28+
"$ug_build"
29+
30+
prepare
31+
32+
## used by run_test_data.sh
33+
## @param $1 args
34+
## @param $2 timeout (optional, default 5)
35+
## @param $3 opts (optional) - should_fail
36+
add_test() {
37+
eval "test_${test_count}_args=\${1?}"
38+
eval "test_${test_count}_timeout=\${2:-5}"
39+
eval "test_${test_count}_opts=\${3-}"
40+
test_count=$((test_count + 1))
41+
}
42+
43+
test_count=0
44+
. "$(dirname "$0")"/run_tests_data.sh
45+
46+
set +e
47+
i=0
48+
while [ $i -lt $test_count ]; do
49+
eval "args=\$test_${i}_args"
50+
eval "timeout=\$test_${i}_timeout"
51+
eval "opts=\$test_${i}_opts"
52+
53+
timeout "$timeout" "$run" "$args"
54+
rc=$?
55+
56+
if [ $rc = 124 ]; then
57+
printf "UG with arguments %s timeout (limit: %d sec)!\n" \
58+
"$args" "$timeout"
59+
exit 1
60+
fi
61+
62+
if expr -- "$opts" : '.*should_fail' >/dev/null; then
63+
if [ $rc -eq 0 ]; then
64+
printf "UG with arguments %s should have failed but\
65+
returned 0!\n" "$args"
66+
exit 1
67+
fi
68+
else
69+
if [ $rc -ne 0 ]; then
70+
printf "UG with arguments %s returned %d but should have\
71+
succeeeded!\n" "$args" "$rc"
72+
exit 1
73+
fi
74+
75+
fi
76+
77+
i=$((i + 1))
78+
done
79+

.github/scripts/run_tests_data.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
add_test -v # basic sanity test
2+
add_test --nonexistent-param 5 should_fail
3+

.github/workflows/daily_tests.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Continuous daily build tests
2+
3+
on:
4+
push:
5+
branches:
6+
- run_tests
7+
schedule:
8+
- cron: '30 4 * * *' # every day at 4:30 UTC
9+
10+
jobs:
11+
run_tests:
12+
strategy:
13+
matrix:
14+
os: [ubuntu-latest, windows-latest, macos-latest]
15+
16+
runs-on: ${{ matrix.os }}
17+
defaults:
18+
run:
19+
shell: ${{ matrix.os == 'windows-latest' && 'C:\shells\msys2bash.cmd {0}' || 'bash {0}' }}
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
- name: Run
24+
shell: bash
25+
run: .github/scripts/run_tests.sh

0 commit comments

Comments
 (0)