Skip to content

Commit b76c8da

Browse files
committed
build: test container: don't pull from docker hub; half support apk files
1 parent 3e033f2 commit b76c8da

3 files changed

Lines changed: 89 additions & 10 deletions

File tree

.github/dockerfiles_feeds/entrypoint.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
set -o errexit # failing commands causes script to fail
55
set -o nounset # undefined variables causes script to fail
66

7+
if [ -z "$(find . -maxdepth 1 -type f -name '*.ipk' -print)" ]
8+
then
9+
echo "this script can only test ipk packages, and none were found"
10+
exit 0
11+
fi
12+
713
echo "src/gz packages_ci file:///ci" >> /etc/opkg/distfeeds.conf
814

915
FINGERPRINT="$(usign -F -p /ci/packages_ci.pub)"

.github/scripts/get-rootfs-url.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env python3
2+
import logging
3+
import os
4+
import requests
5+
6+
logging.basicConfig(level=logging.DEBUG)
7+
log = logging.getLogger(__name__)
8+
9+
"""
10+
our inputs:
11+
BRANCH=master or openwrt-23.05 or openwrt-24.10 etc.
12+
for 23.05, we want something from https://downloads.openwrt.org/releases/23.05-SNAPSHOT/targets/
13+
for master, https://downloads.openwrt.org/snapshots/targets/
14+
TARGET=x86_64 or similar
15+
which means x86/64 (so _ becomes /) inside our targets/ dir
16+
"""
17+
18+
# TODO: once this goes at the end of the yml, exit 1 on failure
19+
20+
def main():
21+
branch = os.environ["BRANCH"]
22+
target = os.environ["TARGET"]
23+
24+
target = target.replace('-', '/')
25+
26+
log.debug(f"got branch {branch}, path for target {target}")
27+
28+
if branch == 'master':
29+
baseurl = 'https://downloads.openwrt.org/snapshots/targets/'
30+
elif branch.startswith('openwrt-'):
31+
rel = branch[8:]
32+
baseurl = 'https://downloads.openwrt.org/releases/' + rel + '-SNAPSHOT/targets/'
33+
else:
34+
raise Exception("don't know downloads URL for branch " + branch)
35+
36+
targeturl = baseurl + target
37+
38+
# log.debug(f"getting ")
39+
sha256sumsreq = requests.get(targeturl + '/sha256sums')
40+
41+
if sha256sumsreq.status_code != 200:
42+
log.error("got non-200 code, stopping")
43+
return
44+
45+
sha256sums = sha256sumsreq.text
46+
47+
# print(sha256sums)
48+
for line in sha256sums.splitlines():
49+
hash, fname = line.split()
50+
if fname.endswith('rootfs.tar.gz'):
51+
if fname.startswith('*'):
52+
fname = fname[1:]
53+
print(targeturl + '/' + fname)
54+
return
55+
56+
log.error("did not find a rootfs.tar.gz in sha256sums, stopping")
57+
58+
if __name__ == '__main__':
59+
main()

.github/workflows/multi-arch-test-build.yml

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -182,44 +182,58 @@ jobs:
182182

183183
- name: Check if any packages were built
184184
run: |
185-
if [ -n "$(find . -maxdepth 1 -type f -name '*.ipk' -print -quit)" ]; then
186-
echo "Found *.ipk files"
187-
HAVE_IPKS=true
185+
if [ -n "$(find . -maxdepth 1 -type f -name '*.[ai]pk' -print -quit)" ]; then
186+
echo "Found *.ipk or *.apk files"
187+
HAVE_PKGS=true
188188
else
189-
echo "No *.ipk files found"
190-
HAVE_IPKS=false
189+
echo "No *.ipk or *.apk files found"
190+
HAVE_PKGS=false
191191
fi
192-
echo "HAVE_IPKS=$HAVE_IPKS" >> $GITHUB_ENV
192+
echo "HAVE_PKGS=$HAVE_PKGS" >> $GITHUB_ENV
193193
194194
- name: Register QEMU
195-
if: ${{ matrix.runtime_test && fromJSON(env.HAVE_IPKS) }}
195+
if: ${{ matrix.runtime_test && fromJSON(env.HAVE_PKGS) }}
196196
run: |
197197
sudo apt-get update
198198
sudo apt-get install -y qemu-user-static binfmt-support
199199
sudo update-binfmts --import
200200
201201
- name: Checkout
202-
if: ${{ matrix.runtime_test && fromJSON(env.HAVE_IPKS) }}
202+
if: ${{ matrix.runtime_test && fromJSON(env.HAVE_PKGS) }}
203203
uses: actions/checkout@v4
204204
with:
205205
repository: openwrt/actions-shared-workflows
206206
path: dockerfiles_feeds
207207
sparse-checkout: |
208208
.github/scripts/ci_helpers.sh
209+
.github/scripts/get-rootfs-url.py
209210
.github/dockerfiles_feeds/Dockerfile
210211
.github/dockerfiles_feeds/entrypoint.sh
211212
sparse-checkout-cone-mode: false
212213

214+
- name: Get rootfs file name
215+
if: ${{ matrix.runtime_test }}
216+
run: |
217+
ROOTFSFILE=$(dockerfiles_feeds/.github/scripts/get-rootfs-url.py)
218+
echo $ROOTFSFILE
219+
if [ -z "$ROOTFSFILE" ] ; then echo "no rootfs" ; exit 1 ; fi
220+
docker import $ROOTFSFILE openwrt/rootfs:$ARCH
221+
docker images
222+
env:
223+
ARCH: ${{ matrix.arch }}-${{ env.BRANCH }}
224+
BRANCH: ${{ env.BRANCH }}
225+
TARGET: ${{ matrix.target }}
226+
213227
- name: Build Docker container
214-
if: ${{ matrix.runtime_test && fromJSON(env.HAVE_IPKS) }}
228+
if: ${{ matrix.runtime_test && fromJSON(env.HAVE_PKGS) }}
215229
run: |
216230
docker build --platform linux/${{ matrix.arch }} -t test-container \
217231
--build-arg ARCH dockerfiles_feeds/.github/dockerfiles_feeds/
218232
env:
219233
ARCH: ${{ matrix.arch }}-${{ env.BRANCH }}
220234

221235
- name: Test via Docker container
222-
if: ${{ matrix.runtime_test && fromJSON(env.HAVE_IPKS) }}
236+
if: ${{ matrix.runtime_test && fromJSON(env.HAVE_PKGS) }}
223237
run: |
224238
docker run --platform linux/${{ matrix.arch }} --rm -v $GITHUB_WORKSPACE:/ci \
225239
-v $GITHUB_WORKSPACE/dockerfiles_feeds:/dockerfiles_feeds \

0 commit comments

Comments
 (0)