diff --git a/.github/workflows/.rtp.io.yml b/.github/workflows/.rtp.io.yml new file mode 100644 index 0000000000..5b2402932f --- /dev/null +++ b/.github/workflows/.rtp.io.yml @@ -0,0 +1,139 @@ +name: rtp.io + +on: + workflow_call: + inputs: + llvm-version: + required: false + type: string + default: '18' + llvm-version-old: + required: false + type: string + default: '16' + ghcr-repo: + required: false + type: string + default: ghcr.io/${{ github.repository_owner }}/opensips + rtpp-repo: + required: false + type: string + default: ghcr.io/sippy/rtpproxy:latest + rtpp-tag: + required: false + type: string + default: debian_12-slim + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + build_rtp_io_dock: + name: Build OpenSIPS+rtp.io Container + runs-on: ubuntu-latest + permissions: + packages: write + env: + BASE_IMAGE: ${{ inputs.rtpp-repo }}-${{ inputs.rtpp-tag }} + 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 + with: + repository: 'sippy/voiptests' + path: dist/voiptests + + - name: Checkout RTPProxy repo + uses: actions/checkout@v4 + with: + repository: 'sippy/rtpproxy' + path: dist/rtpproxy + + - 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: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set dynamic environment + id: set-env + run: | + 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 | ./scripts/build/get-arch-buildargs.rtp.io fltplatforms | paste -sd ','`" + echo "Platforms: ${PLATFORMS}" + GIT_BRANCH="${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" + BUILD_IMAGE="${{ inputs.ghcr-repo }}:rtp.io-${GIT_BRANCH}" + BUILD_OS="`echo ${{ inputs.rtpp-tag }} | sed 's|-.*|| ; s|_|-|g'`" + echo "PLATFORMS=${PLATFORMS}" >> $GITHUB_ENV + echo "GIT_BRANCH=${GIT_BRANCH}" >> $GITHUB_ENV + echo "BUILD_IMAGE=${BUILD_IMAGE}" >> $GITHUB_ENV + echo "BUILD_OS=${BUILD_OS}" >> $GITHUB_ENV + for _p in `echo ${PLATFORMS} | tr ',' '\n'`; \ + do \ + if TARGETPLATFORM=${_p} ./scripts/build/get-arch-buildargs.rtp.io isbrokenplatform; \ + then \ + TEST_MATRIX="${_p}${TEST_MATRIX:+,}${TEST_MATRIX}"; \ + fi; \ + done + TEST_MATRIX="`echo ${TEST_MATRIX} | tr ',' '\n' | jq -R . | jq -s . | tr '\n' ' '`" + echo "test_matrix=${TEST_MATRIX}" >> $GITHUB_OUTPUT + echo "build_image=${BUILD_IMAGE}" >> $GITHUB_OUTPUT + + - name: Build Docker image + uses: docker/build-push-action@v6 + env: + 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=${{ env.BUILD_OS }} + LLVM_VER=${{ inputs.llvm-version }} + LLVM_VER_OLD=${{ inputs.llvm-version-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: + BUILD_OS: debian-12 + TARGETPLATFORM: ${{ 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.TARGETPLATFORM }} + + - name: Test ${{ env.TARGETPLATFORM }} + run: | + docker pull ${BUILD_IMAGE} + docker run --platform ${TARGETPLATFORM} --name test --cap-add=SYS_PTRACE \ + --privileged --sysctl net.ipv6.conf.all.disable_ipv6=0 ${BUILD_IMAGE} + timeout-minutes: 2 diff --git a/.github/workflows/rtp.io.yml b/.github/workflows/rtp.io.yml index 2d9ade6880..0732109e07 100644 --- a/.github/workflows/rtp.io.yml +++ b/.github/workflows/rtp.io.yml @@ -12,8 +12,8 @@ on: workflow_dispatch: env: - COMPILER: clang-18 - COMPILER_OLD: clang-16 + LLVM_VER: 18 + LLVM_VER_OLD: 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 @@ -30,7 +30,9 @@ jobs: BUILD_OS: ubuntu-latest steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - name: Set up environment + run: echo "COMPILER=clang-${LLVM_VER}" >> $GITHUB_ENV + - name: Install git run: | apt-get update @@ -105,79 +107,7 @@ jobs: 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 - with: - repository: 'sippy/voiptests' - path: dist/voiptests - - - name: Checkout RTPProxy repo - uses: actions/checkout@v4 - with: - repository: 'sippy/rtpproxy' - path: dist/rtpproxy - - - 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: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Set dynamic environment - id: set-env - run: | - 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: Build Docker image - uses: docker/build-push-action@v6 - env: - 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 + uses: ./.github/workflows/.rtp.io.yml test_rtp_io_dock: name: Test OpenSIPS+rtp.io @@ -188,7 +118,8 @@ jobs: matrix: test_platform: ${{ fromJSON(needs.build_rtp_io_dock.outputs.test_matrix) }} env: - PLATFORM: ${{ matrix.test_platform }} + BUILD_OS: debian-12 + TARGETPLATFORM: ${{ matrix.test_platform }} BUILD_IMAGE: ${{ needs.build_rtp_io_dock.outputs.build_image }} steps: @@ -196,10 +127,11 @@ jobs: id: qemu uses: docker/setup-qemu-action@v3 with: - platforms: ${{ env.PLATFORM }} + platforms: ${{ env.TARGETPLATFORM }} - - name: Test ${{ env.PLATFORM }} + - name: Test ${{ env.TARGETPLATFORM }} run: | docker pull ${BUILD_IMAGE} - docker run --platform ${PLATFORM} --name test --cap-add=SYS_PTRACE + docker run --platform ${TARGETPLATFORM} --name test --cap-add=SYS_PTRACE \ --privileged --sysctl net.ipv6.conf.all.disable_ipv6=0 ${BUILD_IMAGE} + timeout-minutes: 2 diff --git a/Makefile.defs b/Makefile.defs index 88ae6b4984..4b3d9ebd6f 100644 --- a/Makefile.defs +++ b/Makefile.defs @@ -1124,7 +1124,7 @@ endif #ARCH, sparc64 #if ipaq/netwinder ifeq ($(ARCH), arm) # if gcc -ifeq ($(CC_NAME), gcc) +ifeq ($(CC_NAME:clang=gcc), gcc) #common stuff CFLAGS+=$(CC_OPTIMIZE_FLAG) -funroll-loops -Wcast-align $(PROFILE) \ -Wall -marm diff --git a/docker/Dockerfile.rtp.io b/docker/Dockerfile.rtp.io index fbeed20585..3c771133fd 100644 --- a/docker/Dockerfile.rtp.io +++ b/docker/Dockerfile.rtp.io @@ -11,14 +11,12 @@ ENV DEBIAN_FRONTEND=noninteractive WORKDIR /src -ARG COMPILER=clang-18 -ARG COMPILER_OLD=clang-16 +ARG LLVM_VER=18 +ARG LLVM_VER_OLD=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` \ + 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 \ @@ -33,15 +31,16 @@ 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` \ + 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 eval `./scripts/build/get-arch-buildargs.rtp.io platformopts` && \ + apt-get install -y libsrtp2-dev ${LINKER} RUN env ONE_MODULE=rtp.io LDFLAGS="-flto -fuse-ld=lld" CFLAGS=-flto \ - env `scripts/build/get-arch-buildargs.rtp.io platformopts` \ + 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 +RUN eval `./scripts/build/get-arch-buildargs.rtp.io platformopts` && \ + cd dist/rtpproxy && CC="${COMPILER}" ./configure COPY --exclude=.git --exclude=.github dist/voiptests dist/voiptests diff --git a/scripts/build/do_build.sh b/scripts/build/do_build.sh index a102da8b5b..425fdba967 100755 --- a/scripts/build/do_build.sh +++ b/scripts/build/do_build.sh @@ -19,9 +19,9 @@ MAKE_CMD="${MAKE_ENV} make" if [ ! -z "${ONE_MODULE}" ] then - env CC_EXTRA_OPTS="${CC_EXTRA_OPTS:-"-Werror"}" ${MAKE_CMD} \ + env CC_EXTRA_OPTS="${CC_EXTRA_OPTS:-"-Werror -Wno-atomic-alignment"}" ${MAKE_CMD} \ -C "modules/${ONE_MODULE}" else - env CC_EXTRA_OPTS="${CC_EXTRA_OPTS:-"-Werror"}" ${MAKE_CMD} \ + env CC_EXTRA_OPTS="${CC_EXTRA_OPTS:-"-Werror -Wno-atomic-alignment"}" ${MAKE_CMD} \ exclude_modules="${EXCLUDE_MODULES}" "${@}" ${MAKE_TGT:-"all"} fi diff --git a/scripts/build/get-arch-buildargs.rtp.io b/scripts/build/get-arch-buildargs.rtp.io index 53352644e1..48cbbddee4 100755 --- a/scripts/build/get-arch-buildargs.rtp.io +++ b/scripts/build/get-arch-buildargs.rtp.io @@ -1,15 +1,24 @@ #!/bin/sh set -e -set -x + +isbrokenplatform() { + case "${BUILD_OS}" in + debian*) + case "${TARGETPLATFORM}" in + linux/386 | linux/arm/v7 | linux/mips64le | linux/ppc64le | linux/s390x) + exit 1 + ;; + esac + ;; + esac + exit 0 +} 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 + case "${BUILD_OS}" in + debian*) + FILT="grep -v -e ^linux/arm/v5\$" # broken 64-bit stdatomics ;; *) FILT="cat" @@ -19,20 +28,20 @@ fltplatforms() { } platformopts() { + out="COMPILER=clang-${LLVM_VER} LINKER=lld-${LLVM_VER}" case "${BUILD_OS}" in debian*) case "${TARGETPLATFORM}" in linux/ppc64le | linux/arm/v7 | linux/mips64le | linux/arm/v5) - echo "COMPILER=${COMPILER_OLD}" + out="COMPILER=clang-${LLVM_VER_OLD} LINKER=lld-${LLVM_VER_OLD}" ;; esac ;; esac + echo "${out}" echo "${@}" } -echo "BUILD_OS=${BUILD_OS} TARGETPLATFORM=${TARGETPLATFORM}" >&2 - case "${1}" in platformopts) shift @@ -41,6 +50,9 @@ platformopts) fltplatforms) fltplatforms ;; +isbrokenplatform) + isbrokenplatform + ;; *) echo "usage: `basename "${0}"` (platformopts|fltplatforms) [opts]" 2>&1 exit 1