CI: sync up with changes in packages repo
[feed/telephony.git] / .github / workflows / entrypoint.sh
1 #!/bin/sh
2
3 # not enabling `errtrace` and `pipefail` since those are bash specific
4 set -o errexit # failing commands causes script to fail
5 set -o nounset # undefined variables causes script to fail
6
7 mkdir -p /var/lock/
8
9 opkg update
10
11 [ -n "${CI_HELPER:=''}" ] || CI_HELPER="/ci/.github/workflows/ci_helpers.sh"
12
13 for PKG in /ci/*.ipk; do
14 tar -xzOf "$PKG" ./control.tar.gz | tar xzf - ./control
15 # package name including variant
16 PKG_NAME=$(sed -ne 's#^Package: \(.*\)$#\1#p' ./control)
17 # package version without release
18 PKG_VERSION=$(sed -ne 's#^Version: \(.*\)-[0-9]*$#\1#p' ./control)
19 # package source contianing test.sh script
20 PKG_SOURCE=$(sed -ne 's#^Source: .*/\(.*\)$#\1#p' ./control)
21
22 echo "Testing package $PKG_NAME in version $PKG_VERSION from $PKG_SOURCE"
23
24 opkg install "$PKG"
25
26 export PKG_NAME PKG_VERSION CI_HELPER
27
28 TEST_SCRIPT=$(find /ci/ -name "$PKG_SOURCE" -type d)/test.sh
29
30 if [ -f "$TEST_SCRIPT" ]; then
31 echo "Use package specific test.sh"
32 if sh "$TEST_SCRIPT" "$PKG_NAME" "$PKG_VERSION"; then
33 echo "Test successful"
34 else
35 echo "Test failed"
36 exit 1
37 fi
38 else
39 echo "No test.sh script available"
40 fi
41
42 opkg remove "$PKG_NAME" --force-removal-of-dependent-packages --force-remove
43 done