Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/docker/Dockerfile.ssut
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# syntax=docker/dockerfile:1

ARG BASE_IMAGE=ghcr.io/sippy/rtpproxy:latest
FROM ${BASE_IMAGE}

ARG MM_TYPE
ARG MM_BRANCH

ENV MM_TYPE=${MM_TYPE} \
MM_BRANCH=${MM_BRANCH} \
RTPP_BRANCH=DOCKER \
BASEDIR=/opt/voiptests \
BUILDDIR=/opt/voiptests \
PYTHON_CMD=python3 \
DEBIAN_FRONTEND=noninteractive

WORKDIR /opt/voiptests

COPY . /opt/voiptests

RUN /bin/sh -eux ./cibits/build_ssut_image.sh
257 changes: 222 additions & 35 deletions .github/workflows/.main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,28 @@ name: Reusable Workflow
on:
workflow_call:
inputs:
python-version:
required: false
type: string
default: '3.12'
mm-type:
required: true
type: string
mm-branch:
required: false
type: string
default: 'master'
mm-auth:
mm-auths:
required: false
type: string
default: ''
rtppc-type:
default: '[""]'
python-versions:
required: false
type: string
default: '["3.12"]'
rtppc-types:
required: true
type: string
use-local-image:
required: false
type: boolean
default: false
rtpp-image:
required: false
type: string
Expand All @@ -35,63 +39,246 @@ on:
default: ''

jobs:
test:
build_ssut_image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
outputs:
image-ref: ${{ steps.meta.outputs.image-ref }}
image-artifact: ${{ steps.meta.outputs.image-artifact }}
env:
DOCKER_BUILD_SUMMARY: false
DOCKER_BUILD_RECORD_UPLOAD: false
steps:
- uses: actions/checkout@v5

- name: Compute image metadata
id: meta
run: |
MM_BRANCH_SAFE="$(echo '${{ inputs.mm-branch }}' | sed 's|[^a-zA-Z0-9_.-]|-|g')"
SHA_SHORT="$(printf '%s' "$GITHUB_SHA" | cut -c1-12)"
IMAGE_REF="ghcr.io/${{ github.repository_owner }}/voiptests-${{ inputs.mm-type }}:ssut-${MM_BRANCH_SAFE}-${SHA_SHORT}"
IMAGE_ARTIFACT="ssut-image-${{ inputs.mm-type }}-${MM_BRANCH_SAFE}-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
echo "image-ref=${IMAGE_REF}" >> "$GITHUB_OUTPUT"
echo "image-artifact=${IMAGE_ARTIFACT}" >> "$GITHUB_OUTPUT"

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GHCR
if: ${{ !inputs.use-local-image }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push SSUT image
if: ${{ !inputs.use-local-image }}
uses: docker/build-push-action@v6
with:
context: .
file: ./.github/docker/Dockerfile.ssut
push: true
tags: ${{ steps.meta.outputs.image-ref }}
build-args: |
BASE_IMAGE=${{ inputs.rtpp-image }}:${{ inputs.rtpp-image-tag }}
MM_TYPE=${{ inputs.mm-type }}
MM_BRANCH=${{ inputs.mm-branch }}

- name: Build SSUT image tarball
if: ${{ inputs.use-local-image }}
uses: docker/build-push-action@v6
with:
context: .
file: ./.github/docker/Dockerfile.ssut
outputs: type=docker,dest=/tmp/ssut-image.tar
tags: ${{ steps.meta.outputs.image-ref }}
build-args: |
BASE_IMAGE=${{ inputs.rtpp-image }}:${{ inputs.rtpp-image-tag }}
MM_TYPE=${{ inputs.mm-type }}
MM_BRANCH=${{ inputs.mm-branch }}

- name: Upload SSUT image artifact
if: ${{ inputs.use-local-image }}
uses: actions/upload-artifact@v4
with:
name: ${{ steps.meta.outputs.image-artifact }}
path: /tmp/ssut-image.tar

test_ghcr:
if: ${{ !inputs.use-local-image }}
runs-on: ubuntu-latest
needs: [build_ssut_image]
container:
image: ${{ inputs.rtpp-image }}:${{ inputs.rtpp-image-tag }}
image: ${{ needs.build_ssut_image.outputs.image-ref }}
options: --privileged --sysctl net.ipv6.conf.all.disable_ipv6=0
env:
MM_TYPE: ${{ inputs.mm-type }}
MM_BRANCH: ${{ inputs.mm-branch }}
RTPP_BRANCH: DOCKER
RTPPC_TYPE: ${{ inputs.rtppc-type }}
RTPPC_TYPE: ${{ matrix.rtppc-type }}
MM_AUTH: ${{ matrix.mm-auth }}
ARTIFACT_FILES: ${{ inputs.artifact-files }}
strategy:
fail-fast: false
matrix:
rtppc-type: ${{ fromJSON(inputs.rtppc-types) }}
mm-auth: ${{ fromJSON(inputs.mm-auths) }}
python-version: ${{ fromJSON(inputs.python-versions) }}
steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ inputs.python-version }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
python-version: ${{ matrix.python-version }}

- name: Define PYTHON_CMD
run: |
PYTHON_VER="`echo ${{ matrix.python-version }} | sed 's|-dev$||'`"
echo "PYTHON_CMD=python${PYTHON_VER}" >> $GITHUB_ENV
run: echo "PYTHON_CMD=${pythonLocation}/bin/python" >> "$GITHUB_ENV"

- name: before_install
run: sh -x cibits/before_install.sh
- name: Install Python dependencies
run: |
cd /opt/voiptests
${PYTHON_CMD} -m pip install --upgrade pip
${PYTHON_CMD} -m pip install -r requirements.txt
if [ "${MM_TYPE}" = "b2bua" ]
then
${PYTHON_CMD} -m pip install -U -r dist/b2bua/requirements.txt
fi

- name: transform_var
id: transform_var
- name: Build artifact name
id: artifact_name
run: |
ARTNAME="test-logs_${{ inputs.mm-type }}_${{ inputs.mm-branch }}_${{ inputs.rtppc-type }}"
MM_AUTH="`echo "${{ inputs.mm-auth }}" | sed 's|/|.|g'`"
if [ "${MM_AUTH}" != "" ]
ARTNAME="test-logs_${{ inputs.mm-type }}_${{ inputs.mm-branch }}_${{ matrix.rtppc-type }}"
MM_AUTH_SAFE="$(echo "${{ matrix.mm-auth }}" | sed 's|/|.|g')"
if [ -n "${MM_AUTH_SAFE}" ]
then
ARTNAME="${ARTNAME}_${MM_AUTH}"
echo "MM_AUTH=${{ inputs.mm-auth }}" >> $GITHUB_ENV
ARTNAME="${ARTNAME}_${MM_AUTH_SAFE}"
fi
if [ "${{ inputs.mm-type }}" = "b2bua" ]
then
ARTNAME="${ARTNAME}_${{ inputs.python-version }}"
ARTNAME="${ARTNAME}_${{ matrix.python-version }}"
fi
echo "ARTNAME=${ARTNAME}" >> $GITHUB_OUTPUT
echo "artname=${ARTNAME}" >> "$GITHUB_OUTPUT"

- name: Test (debug)
- name: Run tests
run: |
cd /opt/voiptests
rm -rf test.logs
LOG_FILES="bob.log alice.log rtpproxy.log"
if [ -n "${ARTIFACT_FILES}" ]
then
LOG_FILES="${LOG_FILES} ${ARTIFACT_FILES}"
fi

RTPP_VERSION=debug sh -x ./test_run.sh
mkdir -p test.logs/debug
mv bob.log alice.log rtpproxy.log ${{ inputs.artifact-files }} test.logs/debug
mv ${LOG_FILES} test.logs/debug

- name: Test (production)
run: |
RTPP_VERSION=production sh -x ./test_run.sh
mkdir -p test.logs/production
mv bob.log alice.log rtpproxy.log ${{ inputs.artifact-files }} test.logs/production
mv ${LOG_FILES} test.logs/production

- name: Upload test logs
uses: actions/upload-artifact@v4
with:
name: ${{ steps.artifact_name.outputs.artname }}
path: /opt/voiptests/test.logs
continue-on-error: true

test_local:
if: ${{ inputs.use-local-image }}
runs-on: ubuntu-latest
needs: [build_ssut_image]
strategy:
fail-fast: false
matrix:
rtppc-type: ${{ fromJSON(inputs.rtppc-types) }}
mm-auth: ${{ fromJSON(inputs.mm-auths) }}
python-version: ${{ fromJSON(inputs.python-versions) }}
steps:
- name: Download SSUT image artifact
uses: actions/download-artifact@v4
with:
name: ${{ needs.build_ssut_image.outputs.image-artifact }}
path: /tmp

- name: Load SSUT image
run: docker load --input /tmp/ssut-image.tar

- name: Build artifact name
id: artifact_name
run: |
ARTNAME="test-logs_${{ inputs.mm-type }}_${{ inputs.mm-branch }}_${{ matrix.rtppc-type }}"
MM_AUTH_SAFE="$(echo "${{ matrix.mm-auth }}" | sed 's|/|.|g')"
if [ -n "${MM_AUTH_SAFE}" ]
then
ARTNAME="${ARTNAME}_${MM_AUTH_SAFE}"
fi
if [ "${{ inputs.mm-type }}" = "b2bua" ]
then
ARTNAME="${ARTNAME}_${{ matrix.python-version }}"
fi
echo "artname=${ARTNAME}" >> "$GITHUB_OUTPUT"

- name: Run tests in local image
run: |
PYTHON_VER="$(echo '${{ matrix.python-version }}' | sed 's|-dev$||')"
CTR_NAME="voiptests-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}-${{ strategy.job-index }}"
trap 'docker rm -f "${CTR_NAME}" >/dev/null 2>&1 || true' EXIT

docker create \
--name "${CTR_NAME}" \
--privileged \
--sysctl net.ipv6.conf.all.disable_ipv6=0 \
-e MM_TYPE='${{ inputs.mm-type }}' \
-e MM_BRANCH='${{ inputs.mm-branch }}' \
-e MM_AUTH='${{ matrix.mm-auth }}' \
-e RTPP_BRANCH='DOCKER' \
-e RTPPC_TYPE='${{ matrix.rtppc-type }}' \
-e ARTIFACT_FILES='${{ inputs.artifact-files }}' \
-e PYTHON_CMD="python${PYTHON_VER}" \
'${{ needs.build_ssut_image.outputs.image-ref }}' \
/bin/sh -lc '
set -e
cd /opt/voiptests
if ! command -v "${PYTHON_CMD}" >/dev/null 2>&1
then
PYTHON_CMD=python3
fi
export PYTHON_CMD
export PIP_BREAK_SYSTEM_PACKAGES=1

${PYTHON_CMD} -m pip install --upgrade pip
${PYTHON_CMD} -m pip install -r requirements.txt
if [ "${MM_TYPE}" = "b2bua" ]
then
${PYTHON_CMD} -m pip install -U -r dist/b2bua/requirements.txt
fi

rm -rf test.logs
LOG_FILES="bob.log alice.log rtpproxy.log"
if [ -n "${ARTIFACT_FILES}" ]
then
LOG_FILES="${LOG_FILES} ${ARTIFACT_FILES}"
fi

RTPP_VERSION=debug sh -x ./test_run.sh
mkdir -p test.logs/debug
mv ${LOG_FILES} test.logs/debug

RTPP_VERSION=production sh -x ./test_run.sh
mkdir -p test.logs/production
mv ${LOG_FILES} test.logs/production
'

docker start -a "${CTR_NAME}"
rm -rf test.logs
docker cp "${CTR_NAME}:/opt/voiptests/test.logs" ./test.logs

- name: Test logs
- name: Upload test logs
uses: actions/upload-artifact@v4
with:
name: ${{ steps.transform_var.outputs.ARTNAME }}
name: ${{ steps.artifact_name.outputs.artname }}
path: test.logs
continue-on-error: true
Loading
Loading