From 632c3cfade056dc572eb17f32ff48a5ecbed371b Mon Sep 17 00:00:00 2001 From: Maksym Sobolyev Date: Mon, 7 Oct 2024 13:27:49 -0700 Subject: [PATCH] Add build_test_rtp_io_dock. --- .github/workflows/rtp.io.yml | 200 +++++++++++++++++++----- docker/Dockerfile.rtp.io | 56 +++++++ scripts/build/get-arch-buildargs.rtp.io | 48 ++++++ 3 files changed, 262 insertions(+), 42 deletions(-) create mode 100644 docker/Dockerfile.rtp.io create mode 100755 scripts/build/get-arch-buildargs.rtp.io diff --git a/.github/workflows/rtp.io.yml b/.github/workflows/rtp.io.yml index 6025d8539a..2d9ade6880 100644 --- a/.github/workflows/rtp.io.yml +++ b/.github/workflows/rtp.io.yml @@ -11,6 +11,11 @@ on: # Allows you to run this workflow manually from the Actions tab workflow_dispatch: +env: + COMPILER: clang-18 + COMPILER_OLD: clang-16 + GHCR_REPO: ghcr.io/${{ github.repository_owner }}/opensips + # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: build_test_rtp_io: @@ -19,35 +24,100 @@ jobs: runs-on: ubuntu-latest container: image: sippylabs/rtpproxy:latest - options: --privileged --sysctl net.ipv6.conf.all.disable_ipv6=0 + options: --cap-add=SYS_PTRACE --privileged --sysctl net.ipv6.conf.all.disable_ipv6=0 env: - COMPILER: clang-18 - BUILD_OS: ubuntu-latest PYTHON_VERSION: 3.12 + BUILD_OS: ubuntu-latest steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - name: Install git - run: | - apt-get update - apt-get install -y git lsb-release gnupg2 wget + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - name: Install git + run: | + apt-get update + apt-get install -y git lsb-release gnupg2 wget - - uses: actions/checkout@v4 - with: - submodules: recursive + - uses: actions/checkout@v4 + with: + submodules: recursive - - name: Install dependencies - run: | - sh -x scripts/build/reset_sources.sh - sh -x scripts/build/install_depends.sh + - name: Checkout VoIPTests repo + uses: actions/checkout@v4 + with: + repository: 'sippy/voiptests' + path: dist/voiptests - - name: Build - run: sh -x scripts/build/do_build.sh + - name: Checkout RTPProxy repo + uses: actions/checkout@v4 + with: + repository: 'sippy/rtpproxy' + path: dist/rtpproxy - - name: Build rtp.io module - run: | - apt-get install -y libsrtp2-dev - ONE_MODULE=rtp.io LDFLAGS=-flto CFLAGS=-flto sh -x scripts/build/do_build.sh + - name: Install dependencies + run: | + sh -x scripts/build/reset_sources.sh + sh -x scripts/build/install_depends.sh + + - name: Build + run: | + KEEP_MODULES="dialog sipmsgops sl tm rr maxfwd rtp.io rtpproxy textops" + SKIP_MODULES="usrloc event_routing clusterer rtp_relay" + mkdir tmp + cd modules + mv ${KEEP_MODULES} ${SKIP_MODULES} ../tmp + rm -rf * + cd ../tmp + mv ${KEEP_MODULES} ${SKIP_MODULES} ../modules + cd .. + rmdir tmp + EXCLUDE_MODULES_ADD="${SKIP_MODULES}" sh -x scripts/build/do_build.sh + + - name: Build rtp.io module + run: | + apt-get install -y libsrtp2-dev + ONE_MODULE=rtp.io LDFLAGS=-flto CFLAGS=-flto sh -x scripts/build/do_build.sh + + - name: Set up Python ${{ env.PYTHON_VERSION }} + uses: actions/setup-python@v5 + with: + python-version: ${{ env.PYTHON_VERSION }} + + - name: Define PYTHON_CMD + run: | + PYTHON_VER="`echo ${{ env.PYTHON_VERSION }} | sed 's|-dev$||'`" + echo "PYTHON_CMD=python${PYTHON_VER}" >> $GITHUB_ENV + + - name: Test rtp.io module + env: + MM_TYPE: opensips + MM_BRANCH: master + MM_ROOT: ../.. + RTPP_BRANCH: DOCKER + RTPPC_TYPE: rtp.io + RTPPROXY_DIST: ../../dist/rtpproxy + run: | + export CC="${COMPILER}" + cd dist/rtpproxy + ./configure + cd ../../dist/voiptests + python -m pip install -r requirements.txt + DEBIAN_FRONTEND=noninteractive apt-get install -y gpp + sh -x ./test_run.sh + + build_rtp_io_dock: + name: Build OpenSIPS+rtp.io Container + runs-on: ubuntu-latest + permissions: + packages: write + env: + BASE_IMAGE: ghcr.io/sippy/rtpproxy:latest-debian_12-slim + outputs: + test_matrix: ${{ steps.set-env.outputs.test_matrix }} + build_image: ${{ steps.set-env.outputs.build_image }} + + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive - name: Checkout VoIPTests repo uses: actions/checkout@v4 @@ -61,29 +131,75 @@ jobs: repository: 'sippy/rtpproxy' path: dist/rtpproxy - - name: Set up Python ${{ env.PYTHON_VERSION }} - uses: actions/setup-python@v5 + - name: Set up QEMU + id: qemu + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 with: - python-version: ${{ env.PYTHON_VERSION }} + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} - - name: Define PYTHON_CMD + - name: Set dynamic environment + id: set-env run: | - PYTHON_VER="`echo ${{ env.PYTHON_VERSION }} | sed 's|-dev$||'`" - echo "PYTHON_CMD=python${PYTHON_VER}" >> $GITHUB_ENV + PLATFORMS="`docker manifest inspect ${{ env.BASE_IMAGE }} | \ + jq -r '.manifests[] | "\(.platform.os)/\(.platform.architecture)\(if .platform.variant != null then "/\(.platform.variant)" else "" end)"' | \ + sort -u | grep -v unknown | paste -sd ','`" + echo "Platforms: ${PLATFORMS}" + GIT_BRANCH="${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" + BUILD_IMAGE="${{ env.GHCR_REPO }}:rtp.io-${GIT_BRANCH}" + echo "PLATFORMS=${PLATFORMS}" >> $GITHUB_ENV + echo "GIT_BRANCH=${GIT_BRANCH}" >> $GITHUB_ENV + echo "BUILD_IMAGE=${BUILD_IMAGE}" >> $GITHUB_ENV + TEST_MATRIX="`echo ${PLATFORMS} | tr ',' '\n' | jq -R . | jq -s . | tr '\n' ' '`" + echo "test_matrix=${TEST_MATRIX}" >> $GITHUB_OUTPUT + echo "build_image=${BUILD_IMAGE}" >> $GITHUB_OUTPUT - - name: Test rtp.io module + - name: Build Docker image + uses: docker/build-push-action@v6 env: - MM_TYPE: opensips - MM_BRANCH: master - MM_ROOT: ../.. - RTPP_BRANCH: DOCKER - RTPPC_TYPE: rtp.io - RTPPROXY_DIST: ../../dist/rtpproxy - run: | - export CC="${COMPILER}" - cd dist/rtpproxy - ./configure - cd ../../dist/voiptests - python -m pip install -r requirements.txt - DEBIAN_FRONTEND=noninteractive apt-get install -y gpp - sh -x ./test_run.sh + CACHE_SPEC: "type=registry,ref=${{ env.BUILD_IMAGE }}-buildcache" + with: + context: . + file: ./docker/Dockerfile.rtp.io + build-args: | + BASE_IMAGE=${{ env.BASE_IMAGE }} + BUILD_OS=debian-12 + COMPILER=${{ env.COMPILER }} + COMPILER_OLD=${{ env.COMPILER_OLD }} + platforms: ${{ env.PLATFORMS }} + cache-from: ${{ env.CACHE_SPEC }} + cache-to: ${{ env.CACHE_SPEC }},mode=max + tags: ${{ env.BUILD_IMAGE }} + push: true + + test_rtp_io_dock: + name: Test OpenSIPS+rtp.io + needs: build_rtp_io_dock + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + test_platform: ${{ fromJSON(needs.build_rtp_io_dock.outputs.test_matrix) }} + env: + PLATFORM: ${{ matrix.test_platform }} + BUILD_IMAGE: ${{ needs.build_rtp_io_dock.outputs.build_image }} + + steps: + - name: Set up QEMU + id: qemu + uses: docker/setup-qemu-action@v3 + with: + platforms: ${{ env.PLATFORM }} + + - name: Test ${{ env.PLATFORM }} + run: | + docker pull ${BUILD_IMAGE} + docker run --platform ${PLATFORM} --name test --cap-add=SYS_PTRACE + --privileged --sysctl net.ipv6.conf.all.disable_ipv6=0 ${BUILD_IMAGE} diff --git a/docker/Dockerfile.rtp.io b/docker/Dockerfile.rtp.io new file mode 100644 index 0000000000..fbeed20585 --- /dev/null +++ b/docker/Dockerfile.rtp.io @@ -0,0 +1,56 @@ +# syntax=docker/dockerfile:1.7-labs + +ARG BASE_IMAGE="sippylabs/rtpproxy:latest" +FROM --platform=$TARGETPLATFORM $BASE_IMAGE AS build +LABEL maintainer="Maksym Sobolyev " + +USER root + +# Set Environment Variables +ENV DEBIAN_FRONTEND=noninteractive + +WORKDIR /src + +ARG COMPILER=clang-18 +ARG COMPILER_OLD=clang-16 +ARG TARGETPLATFORM +ARG BUILD_OS=ubuntu-latest +RUN --mount=type=bind,source=scripts/build,target=scripts/build \ + scripts/build/get-arch-buildargs.rtp.io platformopts +RUN --mount=type=bind,source=scripts/build,target=scripts/build \ + env `scripts/build/get-arch-buildargs.rtp.io platformopts` \ + sh -x scripts/build/install_depends.sh +RUN apt-get install -y gpp python-is-python3 python3-pip +RUN --mount=type=bind,source=dist/voiptests/requirements.txt,target=requirements.txt \ + python -m pip install --break-system-packages -U -r requirements.txt + +COPY --exclude=.git --exclude=.github --exclude=docker --exclude=dist \ + . . + +ARG KEEP_MODULES="dialog sipmsgops sl tm rr maxfwd rtp.io rtpproxy textops" +ARG SKIP_MODULES="usrloc event_routing clusterer rtp_relay" +RUN mkdir tmp && cd modules && mv ${KEEP_MODULES} ${SKIP_MODULES} ../tmp && \ + rm -rf * && cd ../tmp && mv ${KEEP_MODULES} ${SKIP_MODULES} ../modules && \ + cd .. && rmdir tmp +RUN EXCLUDE_MODULES_ADD="${SKIP_MODULES}" \ + env `scripts/build/get-arch-buildargs.rtp.io platformopts` \ + sh -x scripts/build/do_build.sh +RUN apt-get install -y libsrtp2-dev lld-18 +RUN env ONE_MODULE=rtp.io LDFLAGS="-flto -fuse-ld=lld" CFLAGS=-flto \ + env `scripts/build/get-arch-buildargs.rtp.io platformopts` \ + sh -x scripts/build/do_build.sh +ARG CC=${COMPILER} +COPY --exclude=.git --exclude=.github dist/rtpproxy dist/rtpproxy +RUN cd dist/rtpproxy && ./configure + +COPY --exclude=.git --exclude=.github dist/voiptests dist/voiptests + +ENV MM_TYPE=opensips +ENV MM_BRANCH=master +ENV MM_ROOT=../.. +ENV RTPP_BRANCH=DOCKER +ENV RTPPC_TYPE=rtp.io +ENV RTPPROXY_DIST=../../dist/rtpproxy +ENV ALICE_ARGS="-4" +WORKDIR dist/voiptests +ENTRYPOINT [ "sh", "-x", "./test_run.sh" ] diff --git a/scripts/build/get-arch-buildargs.rtp.io b/scripts/build/get-arch-buildargs.rtp.io new file mode 100755 index 0000000000..1b943239da --- /dev/null +++ b/scripts/build/get-arch-buildargs.rtp.io @@ -0,0 +1,48 @@ +#!/bin/sh + +set -e +set -x + +fltplatforms() { + case "${BASE_IMAGE}" in + alpine:3.15) + FILT="grep -v -e ^linux/arm/v6\$" # bus error + ;; + ubuntu:20.04) + FILT="grep -v -e ^linux/arm/v7\$" # broken cmake + ;; + *) + FILT="cat" + ;; + esac + ${FILT} +} + +platformopts() { + case "${BUILD_OS}" in + debian*) + case "${TARGETPLATFORM}" in + linux/ppc64le) + echo "COMPILER=${COMPILER_OLD}" + ;; + esac + ;; + esac + echo "${@}" +} + +echo "BUILD_OS=${BUILD_OS} TARGETPLATFORM=${TARGETPLATFORM}" >&2 + +case "${1}" in +platformopts) + shift + platformopts "${@}" + ;; +fltplatforms) + fltplatforms + ;; +*) + echo "usage: `basename "${0}"` (platformopts|fltplatforms) [opts]" 2>&1 + exit 1 + ;; +esac