[Openvpn-devel,v2] GitHub Actions: Use Docker Images for Ubuntu test runs

Message ID 20220823134218.895-1-timo@rothenpieler.org
State Not Applicable
Headers show
Series [Openvpn-devel,v2] GitHub Actions: Use Docker Images for Ubuntu test runs | expand

Commit Message

Timo Rothenpieler Aug. 23, 2022, 3:42 a.m. UTC
The ubuntu-18.04 base image is deprecated and in the process of being phased out:
https://github.blog/changelog/2022-08-09-github-actions-the-ubuntu-18-04-actions-runner-image-is-being-deprecated-and-will-be-removed-by-12-1-22/

It is already causing build failures during the scheduled periods mentioned in the blog post.

This is the best alternative I found which does not drop any tests or test environments.
Sadly GHAs build-in container-capabilities can't be used, since they don't allow specifying --network host.
Without that, IPv6 related tests fail, since the Docker deployment on GHA does not support IPv6, even in 2022:
https://github.com/actions/runner-images/issues/668

So instead this manually invokes docker to run the tests in the respective Ubuntu Docker-Image.
Some dependencies had to be added since the Docker-Images are more barebones than the Github-Runner images.
Otherwise, nothing about the test setup changed.
---
Was missing DEBIAN_FRONTEND=noninteractive


 .github/workflows/build.yaml | 43 ++++++++++++++++++++----------------
 1 file changed, 24 insertions(+), 19 deletions(-)

Comments

Timo Rothenpieler Aug. 23, 2022, 4:07 a.m. UTC | #1
On 23/08/2022 15:42, Timo Rothenpieler wrote:
> +        run: docker exec ovpn -e DEBIAN_FRONTEND=noninteractive sh -c "apt update && apt install -y liblzo2-dev libpam0g-dev liblz4-dev libcap-ng-dev linux-libc-dev man2html libcmocka-dev python3-docutils build-essential pkgconf libtool automake autoconf iproute2 git ${SSLPKG} ${NLPKG}"

Still not 100% right unfortunately... the -e DEB... part needs to go 
before the image name, and after exec.

Patch

diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index b0f67a78..53662120 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -162,79 +162,84 @@  jobs:
     strategy:
       fail-fast: false
       matrix:
-        os: [ubuntu-18.04, ubuntu-20.04, ubuntu-22.04]
+        img: ["ubuntu:18.04", "ubuntu:20.04", "ubuntu:22.04"]
         sslpkg: [libmbedtls-dev]
         ssllib: [mbedtls]
         libname: [mbed TLS]
 
         include:
-          - os: ubuntu-18.04
+          - img: "ubuntu:18.04"
             sslpkg: "libssl1.0-dev"
             ssllib: openssl
             libname: OpenSSL 1.0.2
-          - os: ubuntu-18.04
+          - img: "ubuntu:18.04"
             sslpkg: "libssl-dev"
             libname: OpenSSL 1.1.1
             ssllib: openssl
-          - os: ubuntu-20.04
+          - img: "ubuntu:20.04"
             sslpkg: "libssl-dev"
             libname: OpenSSL 1.1.1
             ssllib: openssl
-          - os: ubuntu-22.04
+          - img: "ubuntu:22.04"
             sslpkg: "libssl-dev"
             libname: OpenSSL 3.0.2
             ssllib: openssl
-          - os: ubuntu-20.04
+          - img: "ubuntu:20.04"
             sslpkg: "libssl-dev"
             libname: OpenSSL 1.1.1
             ssllib: openssl
             extraconf: "--enable-iproute2"
-          - os: ubuntu-20.04
+          - img: "ubuntu:20.04"
             sslpkg: "libssl-dev"
             libname: OpenSSL 1.1.1
             ssllib: openssl
             extraconf: "--enable-async-push"
-          - os: ubuntu-20.04
+          - img: "ubuntu:20.04"
             sslpkg: "libssl-dev"
             libname: OpenSSL 1.1.1
             ssllib: openssl
             extraconf: "--disable-management"
-          - os: ubuntu-20.04
+          - img: "ubuntu:20.04"
             sslpkg: "libssl-dev"
             libname: OpenSSL 1.1.1
             ssllib: openssl
             extraconf: "--enable-small"
-          - os: ubuntu-20.04
+          - img: "ubuntu:20.04"
             sslpkg: "libssl-dev"
             libname: OpenSSL 1.1.1
             ssllib: openssl
             extraconf: "--disable-lzo --disable-lz4"
-          - os: ubuntu-20.04
+          - img: "ubuntu:20.04"
             sslpkg: "libssl-dev"
             libname: OpenSSL 1.1.1
             ssllib: openssl
             extraconf: "--enable-dco"
             nlpkg: "libnl-genl-3-dev"
 
-    name: "gcc - ${{matrix.os}} - ${{matrix.libname}} ${{matrix.extraconf}}"
+    name: "gcc - ${{matrix.img}} - ${{matrix.libname}} ${{matrix.extraconf}}"
     env:
       SSLPKG: "${{matrix.sslpkg}}"
       NLPKG: "${{matrix.nlpkg}}"
 
-    runs-on: ${{matrix.os}}
+    runs-on: ubuntu-latest
     steps:
-      - name: Install dependencies
-        run: sudo apt update && sudo apt install -y liblzo2-dev libpam0g-dev liblz4-dev libcap-ng-dev linux-libc-dev man2html libcmocka-dev python3-docutils libtool automake autoconf ${SSLPKG} ${NLPKG}
       - name: Checkout OpenVPN
         uses: actions/checkout@v3
+      - name: Setup Container
+        run: docker run --name ovpn --detach --rm --cap-add NET_ADMIN --network host -v "$PWD:/wd" --workdir=/wd "${{matrix.img}}" sleep 3600
+      - name: Install dependencies
+        run: docker exec ovpn -e DEBIAN_FRONTEND=noninteractive sh -c "apt update && apt install -y liblzo2-dev libpam0g-dev liblz4-dev libcap-ng-dev linux-libc-dev man2html libcmocka-dev python3-docutils build-essential pkgconf libtool automake autoconf iproute2 git ${SSLPKG} ${NLPKG}"
       - name: autoconf
-        run: autoreconf -fvi
+        run: docker exec ovpn autoreconf -fvi
       - name: configure
-        run: ./configure --with-crypto-library=${{matrix.ssllib}} ${{matrix.extraconf}} --enable-werror
+        run: docker exec ovpn ./configure --with-crypto-library=${{matrix.ssllib}} ${{matrix.extraconf}} --enable-werror
       - name: make all
-        run: make -j3
+        run: docker exec ovpn make -j3
       - name: make check
-        run: make check
+        run: docker exec ovpn make check
+      - name: Docker Cleanup
+        if: always()
+        run: docker kill ovpn || true
 
   ubuntu-clang-asan:
     strategy: