Browse Source

Update open wrt test (#6010)

Adding in tests of various versions of OpenWrt. Also simplified the way to reproduce potential issues and added in breadcrumbs for debugging.

Co-authored-by: Andras Fekete <andras@wolfssl.com>
András Fekete 1 year ago
parent
commit
8ecd906c23
3 changed files with 44 additions and 25 deletions
  1. 30 7
      .github/workflows/docker-OpenWrt.yml
  2. 8 14
      Docker/OpenWrt/Dockerfile
  3. 6 4
      Docker/OpenWrt/README.md

+ 30 - 7
.github/workflows/docker-OpenWrt.yml

@@ -2,7 +2,8 @@
 # there aren't any compatibility issues. Take a look at Docker/OpenWrt/README.md
 name: OpenWrt test
 concurrency:
-    group: ${{ github.ref }}
+    group: ${{ github.head_ref || github.run_id }}
+#    cancel-in-progress: true
 
 on:
     push:
@@ -11,23 +12,45 @@ on:
         branches: [ '*' ]
 
 jobs:
+    build_library:
+        name: Compile libwolfssl.so
+        runs-on: ubuntu-latest
+        container:
+            image: alpine:latest
+        steps:
+            - name: Install required tools
+              run: apk add argp-standalone asciidoc bash bc binutils bzip2 cdrkit coreutils diffutils elfutils-dev findutils flex musl-fts-dev g++ gawk gcc gettext git grep intltool libxslt linux-headers make musl-libintl musl-obstack-dev ncurses-dev openssl-dev patch perl python3-dev rsync tar unzip util-linux wget zlib-dev autoconf automake libtool
+            - uses: actions/checkout@v3
+            - name: Compile libwolfssl.so
+              run: ./autogen.sh && ./configure --enable-all && make
+            - name: Upload libwolfssl.so
+              uses: actions/upload-artifact@v3
+              with:
+                name: libwolfssl.so
+                path: src/.libs/libwolfssl.so
+                retention-days: 1
     compile_container:
-        name: Build OpenWrt test container
+        name: OpenWrt test
         runs-on: ubuntu-latest
+        needs: build_library
+        strategy:
+            matrix:
+                release: [ "snapshot", "22.03-SNAPSHOT", "21.02-SNAPSHOT" ] # some other versions: 21.02.0 21.02.5 22.03.0 22.03.3
         steps:
             - uses: actions/checkout@v3
-            - uses: docker/setup-qemu-action@v2
             - uses: docker/setup-buildx-action@v2
+            - uses: actions/download-artifact@v3
+              with:
+                name: libwolfssl.so
+                path: Docker/OpenWrt/.
             -
               name: Build but dont push
               uses: docker/build-push-action@v3
               with:
-                  context: .
+                  context: Docker/OpenWrt
                   platforms: linux/amd64
-                  file: Docker/OpenWrt/Dockerfile
                   push: false
                   tags: openwrt-test:latest
-#                  cache-from: type=registry,ref=openwrt-test:latest
-#                  cache-to: type=inline
+                  build-args: DOCKER_BASE_CONTAINER=openwrt/rootfs:x86-64-${{ matrix.release }}
                   cache-from: type=gha
                   cache-to: type=gha,mode=max

+ 8 - 14
Docker/OpenWrt/Dockerfile

@@ -1,18 +1,12 @@
 # This Dockerfile is used in conjunction with the docker-OpenWrt.yml GitHub Action.
-FROM alpine:latest AS builder
-
-RUN apk add argp-standalone asciidoc bash bc binutils bzip2 cdrkit coreutils \
-  diffutils elfutils-dev findutils flex musl-fts-dev g++ gawk gcc gettext git \
-  grep intltool libxslt linux-headers make musl-libintl musl-obstack-dev \
-  ncurses-dev openssl-dev patch perl python3-dev rsync tar \
-  unzip util-linux wget zlib-dev autoconf automake libtool
-COPY . /workspace
-RUN cd /workspace && ./autogen.sh && ./configure --enable-all && make
-
-FROM openwrt/rootfs:x86-64-22.03.0
+ARG DOCKER_BASE_CONTAINER=openwrt/rootfs:x86-64-snapshot
+FROM $DOCKER_BASE_CONTAINER
 
 RUN mkdir -p /var/lock # Fix for parent container
-RUN rm -f /usr/lib/libwolfssl* # make sure to eliminate existing wolfSSL library
-COPY --from=builder /workspace/src/.libs/libwolfssl.so.35.3.0 /usr/lib/libwolfssl.so.5.4.0.ee39414e
-COPY Docker/OpenWrt/runTests.sh /tmp/.
+COPY libwolfssl.so /tmp/libwolfssl.so
+RUN export LIBWOLFSSL=$(ls /usr/lib/libwolfssl.so.* -1); \
+                      rm ${LIBWOLFSSL} && ln -s /tmp/libwolfssl.so ${LIBWOLFSSL}
+# for debugging purposes to make sure the correct library is tested
+RUN ls -Ll /usr/lib/libwolfssl* && ldd /lib/libustream-ssl.so | grep wolfssl
+COPY runTests.sh /tmp/.
 RUN /tmp/runTests.sh

+ 6 - 4
Docker/OpenWrt/README.md

@@ -4,8 +4,10 @@ compile a new libwolfssl that gets placed in official OpenWrt containers to
 run some tests ensuring the library is still compatible with existing
 binaries.
 
-To run the build locally, you can run (in your wolfSSL root directory):
-docker build -t openwrt -f Docker/OpenWrt/Dockerfile .
+To run the test locally, build libwolfssl.so (or download from the GitHub Action)
+and put it in Docker/OpenWrt. Then switch to that folder and run:
+docker build -t openwrt --build-args DOCKER_BASE_CONTAINER=<openwrtContainer> .
+where 'openwrtContainer' => "openwrt/rootfs:x86-64-22.03-SNAPSHOT" or similar
 
-This should build the entire container and run some sample tests. The resulting
-container then can be used to evaluate OpenWrt with the latest wolfSSL library.
+This should run some sample tests. The resulting container then can be used to
+evaluate OpenWrt with the latest wolfSSL library.