CI: Fix CI_HELPER
[feed/packages.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 export 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: \(.*\)$#\1#p' ./control)
24 PKG_VERSION="${PKG_VERSION%-[!-]*}"
25 # package source containing test.sh script
26 PKG_SOURCE=$(sed -ne 's#^Source: \(.*\)$#\1#p' ./control)
27 PKG_SOURCE="${PKG_SOURCE#/feed/}"
28
29 echo
30 echo "Testing package $PKG_NAME in version $PKG_VERSION from $PKG_SOURCE"
31
32 if ! [ -d "/ci/$PKG_SOURCE" ]; then
33 echo "$PKG_SOURCE is not a directory"
34 exit 1
35 fi
36
37 PRE_TEST_SCRIPT="/ci/$PKG_SOURCE/pre-test.sh"
38 TEST_SCRIPT="/ci/$PKG_SOURCE/test.sh"
39
40 if ! [ -f "$TEST_SCRIPT" ]; then
41 echo "No test.sh script available"
42 continue
43 fi
44
45 export PKG_NAME PKG_VERSION
46
47 if [ -f "$PRE_TEST_SCRIPT" ]; then
48 echo "Use package specific pre-test.sh"
49 if sh "$PRE_TEST_SCRIPT" "$PKG_NAME" "$PKG_VERSION"; then
50 echo "Pre-test successful"
51 else
52 echo "Pre-test failed"
53 exit 1
54 fi
55 else
56 echo "No pre-test.sh script available"
57 fi
58
59 opkg install "$PKG"
60
61 echo "Use package specific test.sh"
62 if sh "$TEST_SCRIPT" "$PKG_NAME" "$PKG_VERSION"; then
63 echo "Test successful"
64 else
65 echo "Test failed"
66 exit 1
67 fi
68
69 opkg remove "$PKG_NAME" --force-removal-of-dependent-packages --force-remove --autoremove || true
70 done