Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sobomax committed Oct 15, 2024
1 parent 7d28303 commit bc7ff2c
Show file tree
Hide file tree
Showing 6 changed files with 185 additions and 103 deletions.
139 changes: 139 additions & 0 deletions .github/workflows/.rtp.io.yml
Original file line number Diff line number Diff line change
@@ -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
92 changes: 12 additions & 80 deletions .github/workflows/rtp.io.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -188,18 +118,20 @@ 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:
- name: Set up QEMU
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
2 changes: 1 addition & 1 deletion Makefile.defs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 9 additions & 10 deletions docker/Dockerfile.rtp.io
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions scripts/build/do_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
32 changes: 22 additions & 10 deletions scripts/build/get-arch-buildargs.rtp.io
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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
Expand All @@ -41,6 +50,9 @@ platformopts)
fltplatforms)
fltplatforms
;;
isbrokenplatform)
isbrokenplatform
;;
*)
echo "usage: `basename "${0}"` (platformopts|fltplatforms) [opts]" 2>&1
exit 1
Expand Down

0 comments on commit bc7ff2c

Please sign in to comment.