cache-domains: added pre-test.sh CI step
[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 export PKG_NAME PKG_VERSION CI_HELPER
30
31 PRE_TEST_SCRIPT=$(find /ci/ -name "$PKG_SOURCE" -type d)/pre-test.sh
32
33 if [ -f "$PRE_TEST_SCRIPT" ]; then
34 echo "Use package specific pre-test.sh"
35 if sh "$PRE_TEST_SCRIPT" "$PKG_NAME" "$PKG_VERSION"; then
36 echo "Pre-test successful"
37 else
38 echo "Pre-test failed"
39 exit 1
40 fi
41 else
42 echo "No pre-test.sh script available"
43 fi
44
45 opkg install "$PKG"
46
47 TEST_SCRIPT=$(find /ci/ -name "$PKG_SOURCE" -type d)/test.sh
48
49 if [ -f "$TEST_SCRIPT" ]; then
50 echo "Use package specific test.sh"
51 if sh "$TEST_SCRIPT" "$PKG_NAME" "$PKG_VERSION"; then
52 echo "Test succesful"
53 else
54 echo "Test failed"
55 exit 1
56 fi
57 else
58 echo "No test.sh script available"
59 fi
60
61 opkg remove "$PKG_NAME" --force-removal-of-dependent-packages --force-remove --autoremove || true
62 done