6332011a2e14fdd3e2f1447204a5aba3b4fd4467
[feed/routing.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 echo "src/gz packages_ci file:///ci" >> /etc/opkg/distfeeds.conf
8
9 FINGERPRINT="$(usign -F -p /ci/packages_ci.pub)"
10 cp /ci/packages_ci.pub "/etc/opkg/keys/$FINGERPRINT"
11
12 mkdir -p /var/lock/
13
14 opkg update
15
16 [ -n "${CI_HELPER:=''}" ] || CI_HELPER="/ci/.github/workflows/ci_helpers.sh"
17
18 for PKG in /ci/*.ipk; do
19 tar -xzOf "$PKG" ./control.tar.gz | tar xzf - ./control
20 # package name including variant
21 PKG_NAME=$(sed -ne 's#^Package: \(.*\)$#\1#p' ./control)
22 # package version without release
23 PKG_VERSION=$(sed -ne 's#^Version: \(.*\)-[0-9]*$#\1#p' ./control)
24 # package source contianing test.sh script
25 PKG_SOURCE=$(sed -ne 's#^Source: .*/\(.*\)$#\1#p' ./control)
26
27 echo "Testing package $PKG_NAME in version $PKG_VERSION from $PKG_SOURCE"
28
29 opkg install "$PKG"
30
31 export PKG_NAME PKG_VERSION CI_HELPER
32
33 TEST_SCRIPT=$(find /ci/ -name "$PKG_SOURCE" -type d)/test.sh
34
35 if [ -f "$TEST_SCRIPT" ]; then
36 echo "Use package specific test.sh"
37 if sh "$TEST_SCRIPT" "$PKG_NAME" "$PKG_VERSION"; then
38 echo "Test succesful"
39 else
40 echo "Test failed"
41 exit 1
42 fi
43 else
44 echo "No test.sh script available"
45 fi
46
47 opkg remove "$PKG_NAME" --force-removal-of-dependent-packages --force-remove --autoremove || true
48 done