Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 39 additions & 17 deletions .github/dockerfiles_feeds/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,41 @@
set -o errexit # failing commands causes script to fail
set -o nounset # undefined variables causes script to fail

echo "src/gz packages_ci file:///ci" >> /etc/opkg/distfeeds.conf
mkdir -p /var/lock/
mkdir -p /var/log/

FINGERPRINT="$(usign -F -p /ci/packages_ci.pub)"
cp /ci/packages_ci.pub "/etc/opkg/keys/$FINGERPRINT"
if [ $PKG_MANAGER = "opkg" ]; then
echo "src/gz packages_ci file:///ci" >> /etc/opkg/distfeeds.conf

mkdir -p /var/lock/
FINGERPRINT="$(usign -F -p /ci/packages_ci.pub)"
cp /ci/packages_ci.pub "/etc/opkg/keys/$FINGERPRINT"

opkg update
opkg update
fi

CI_HELPER="${CI_HELPER:-/ci/.github/workflows/ci_helpers.sh}"

for PKG in /ci/*.ipk; do
tar -xzOf "$PKG" ./control.tar.gz | tar xzf - ./control
# package name including variant
PKG_NAME=$(sed -ne 's#^Package: \(.*\)$#\1#p' ./control)
# package version without release
PKG_VERSION=$(sed -ne 's#^Version: \(.*\)$#\1#p' ./control)
PKG_VERSION="${PKG_VERSION%-[!-]*}"
# package source containing test.sh script
PKG_SOURCE=$(sed -ne 's#^Source: \(.*\)$#\1#p' ./control)
PKG_SOURCE="${PKG_SOURCE#/feed/}"
for PKG in /ci/*.[ai]pk; do
if [ $PKG_MANAGER = "opkg" ]; then
tar -xzOf "$PKG" ./control.tar.gz | tar xzf - ./control
# package name including variant
PKG_NAME=$(sed -ne 's#^Package: \(.*\)$#\1#p' ./control)
# package version without release
PKG_VERSION=$(sed -ne 's#^Version: \(.*\)$#\1#p' ./control)
PKG_VERSION="${PKG_VERSION%-[!-]*}"
# package source containing test.sh script
PKG_SOURCE=$(sed -ne 's#^Source: \(.*\)$#\1#p' ./control)
PKG_SOURCE="${PKG_SOURCE#/feed/}"
elif [ $PKG_MANAGER = "apk" ]; then
# package name including variant
PKG_NAME=$(apk adbdump --format json "$PKG" | jsonfilter -e '@["info"]["name"]')
# package version without release
PKG_VERSION=$(apk adbdump --format json "$PKG" | jsonfilter -e '@["info"]["version"]')
PKG_VERSION="${PKG_VERSION%-[!-]*}"
# package source containing test.sh script
PKG_SOURCE=$(apk adbdump --format json "$PKG" | jsonfilter -e '@["info"]["origin"]')
PKG_SOURCE="${PKG_SOURCE#/feed/}"
fi

echo
echo "Testing package $PKG_NAME in version $PKG_VERSION from $PKG_SOURCE"
Expand Down Expand Up @@ -56,7 +70,11 @@ for PKG in /ci/*.ipk; do
echo "No pre-test.sh script available"
fi

opkg install "$PKG"
if [ $PKG_MANAGER = "opkg" ]; then
opkg install "$PKG"
elif [ $PKG_MANAGER = "apk" ]; then
apk add --allow-untrusted "$PKG"
fi

echo "Use package specific test.sh"
if sh "$TEST_SCRIPT" "$PKG_NAME" "$PKG_VERSION"; then
Expand All @@ -66,5 +84,9 @@ for PKG in /ci/*.ipk; do
exit 1
fi

opkg remove "$PKG_NAME" --force-removal-of-dependent-packages --force-remove --autoremove || true
if [ $PKG_MANAGER = "opkg" ]; then
opkg remove "$PKG_NAME" --force-removal-of-dependent-packages --force-remove --autoremove || true
elif [ $PKG_MANAGER = "apk" ]; then
apk del -r "$PKG_NAME"
fi
done
28 changes: 18 additions & 10 deletions .github/workflows/multi-arch-test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -185,24 +185,30 @@ jobs:

- name: Check if any packages were built
run: |
if [ -n "$(find . -maxdepth 1 -type f -name '*.ipk' -print -quit)" ]; then
if [ -n "$(find . -maxdepth 1 -type f -name '*.apk' -print -quit)" ]; then
echo "Found *.apk files"
HAVE_PKGS=true
PKG_MANAGER=apk
elif [ -n "$(find . -maxdepth 1 -type f -name '*.ipk' -print -quit)" ]; then
echo "Found *.ipk files"
HAVE_IPKS=true
HAVE_PKGS=true
PKG_MANAGER=opkg
else
echo "No *.ipk files found"
HAVE_IPKS=false
echo "No *.apk or *.ipk files found"
HAVE_PKGS=false
fi
echo "HAVE_IPKS=$HAVE_IPKS" >> $GITHUB_ENV
echo "HAVE_PKGS=$HAVE_PKGS" >> $GITHUB_ENV
echo "PKG_MANAGER=$PKG_MANAGER" >> $GITHUB_ENV

- name: Register QEMU
if: ${{ matrix.runtime_test && fromJSON(env.HAVE_IPKS) }}
if: ${{ matrix.runtime_test && fromJSON(env.HAVE_PKGS) }}
run: |
sudo apt-get update
sudo apt-get install -y qemu-user-static binfmt-support
sudo update-binfmts --import

- name: Checkout
if: ${{ matrix.runtime_test && fromJSON(env.HAVE_IPKS) }}
if: ${{ matrix.runtime_test && fromJSON(env.HAVE_PKGS) }}
uses: actions/checkout@v4
with:
repository: openwrt/actions-shared-workflows
Expand All @@ -214,16 +220,18 @@ jobs:
sparse-checkout-cone-mode: false

- name: Build Docker container
if: ${{ matrix.runtime_test && fromJSON(env.HAVE_IPKS) }}
if: ${{ matrix.runtime_test && fromJSON(env.HAVE_PKGS) }}
run: |
docker build --platform linux/${{ matrix.arch }} -t test-container \
--build-arg ARCH dockerfiles_feeds/.github/dockerfiles_feeds/
env:
ARCH: ${{ matrix.arch }}-${{ env.BRANCH }}

- name: Test via Docker container
if: ${{ matrix.runtime_test && fromJSON(env.HAVE_IPKS) }}
if: ${{ matrix.runtime_test && fromJSON(env.HAVE_PKGS) }}
run: |
docker run --platform linux/${{ matrix.arch }} --rm -v $GITHUB_WORKSPACE:/ci \
-v $GITHUB_WORKSPACE/dockerfiles_feeds:/dockerfiles_feeds \
-e CI_HELPER=/dockerfiles_feeds/scripts/ci_helpers.sh test-container
-e CI_HELPER=/dockerfiles_feeds/scripts/ci_helpers.sh \
-e PKG_MANAGER=${{ env.PKG_MANAGER }} \
test-container