Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sobomax committed Oct 22, 2024
1 parent 0f85429 commit cbc3d9b
Showing 1 changed file with 120 additions and 40 deletions.
160 changes: 120 additions & 40 deletions .github/workflows/.rtp.io.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,60 @@ on:
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:
set_env:
name: Set Environment
runs-on: ubuntu-latest
env:
BASE_IMAGE: ${{ inputs.rtpp-repo }}-${{ inputs.rtpp-tag }}
outputs:
platforms: ${{ steps.set-env.outputs.platforms }}
build-matrix: ${{ steps.set-env.outputs.build-matrix }}
test-matrix: ${{ steps.set-env.outputs.test-matrix }}
build-os: ${{ steps.set-env.outputs.build-os }}
build-image: ${{ steps.set-env.outputs.build-image }}
git-branch: ${{ steps.set-env.outputs.git-branch }}
steps:
- uses: actions/checkout@v4

- name: Set dynamic environment
id: set-env
run: |
BUILD_OS="`echo ${{ inputs.rtpp-tag }} | sed 's|-.*|| ; s|_|-|g'`"
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 | BUILD_OS="${BUILD_OS}" ./scripts/build/get-arch-buildargs.rtp.io fltplatforms | paste -sd ','`"
BUILD_MATRIX="`echo ${PLATFORMS} | tr ',' '\n' | jq -R . | jq -s . | tr '\n' ' '`"
GIT_BRANCH="${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
GIT_BRANCH="${GIT_BRANCH#refs/tags/}"
BUILD_IMAGE="${{ inputs.ghcr-repo }}:rtp.io-${{ inputs.rtpp-tag }}-${GIT_BRANCH}"
echo "Platforms: ${PLATFORMS}"
for _p in `echo ${PLATFORMS} | tr ',' '\n'`; \
do \
if TARGETPLATFORM="${_p}" BUILD_OS="${BUILD_OS}" ./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 "platforms=${PLATFORMS}" >> $GITHUB_OUTPUT
echo "build-matrix=${BUILD_MATRIX}" >> $GITHUB_OUTPUT
echo "test-matrix=${TEST_MATRIX}" >> $GITHUB_OUTPUT
echo "build-os=${BUILD_OS}" >> $GITHUB_OUTPUT
echo "build-image=${BUILD_IMAGE}" >> $GITHUB_OUTPUT
echo "git-branch=${GIT_BRANCH}" >> $GITHUB_OUTPUT
build_rtp_io_dock:
name: Build OpenSIPS+rtp.io Container
name: Build Container (GHCR)
needs: set_env
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 }}
BUILD_OS: ${{ needs.set_env.outputs.build-os }}
PLATFORMS: ${{ needs.set_env.outputs.platforms }}
BUILD_IMAGE: ${{ needs.set_env.outputs.build-image }}

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -66,32 +108,6 @@ jobs:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set dynamic environment
id: set-env
run: |
BUILD_OS="`echo ${{ inputs.rtpp-tag }} | sed 's|-.*|| ; s|_|-|g'`"
echo "BUILD_OS=${BUILD_OS}" >> $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 | BUILD_OS="${BUILD_OS}" ./scripts/build/get-arch-buildargs.rtp.io fltplatforms | paste -sd ','`"
echo "Platforms: ${PLATFORMS}"
GIT_BRANCH="${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
GIT_BRANCH="${GIT_BRANCH#refs/tags/}"
BUILD_IMAGE="${{ inputs.ghcr-repo }}:rtp.io-${{ inputs.rtpp-tag }}-${GIT_BRANCH}"
echo "PLATFORMS=${PLATFORMS}" >> $GITHUB_ENV
echo "GIT_BRANCH=${GIT_BRANCH}" >> $GITHUB_ENV
echo "BUILD_IMAGE=${BUILD_IMAGE}" >> $GITHUB_ENV
for _p in `echo ${PLATFORMS} | tr ',' '\n'`; \
do \
if TARGETPLATFORM="${_p}" BUILD_OS="${BUILD_OS}" ./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:
Expand All @@ -110,24 +126,88 @@ jobs:
tags: ${{ env.BUILD_IMAGE }}
push: true

build_rtp_io_dock_local:
name: Build Container (Local)
needs: set_env
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform: ${{ fromJSON(needs.set_env.outputs.build-matrix) }}
env:
BASE_IMAGE: ${{ inputs.rtpp-repo }}-${{ inputs.rtpp-tag }}
BUILD_OS: ${{ needs.set_env.outputs.build-os }}

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
with:
platforms: ${{ matrix.platform }}

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

- name: Set dynamic environment
id: set-env
run: |
OUTPUT_TAG="myimage:`echo ${{ matrix.platform }} | sed 's|/|-|g'`"
OUTPUT_IMAGE_N="image-`echo ${{ matrix.platform }} | sed 's|/|-|g'`"
OUTPUT_IMAGE="./${OUTPUT_IMAGE_N}.tar"
echo OUTPUT_TAG="${OUTPUT_TAG}" >> $GITHUB_ENV
echo OUTPUT_IMAGE="${OUTPUT_IMAGE}" >> $GITHUB_ENV
echo OUTPUT_IMAGE_N="${OUTPUT_IMAGE_N}" >> $GITHUB_ENV
- name: Build Docker image
uses: docker/build-push-action@v6
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: ${{ matrix.platform }}
tags: ${{ env.OUTPUT_TAG }}
outputs: type=docker,dest=${{ env.OUTPUT_IMAGE }}

- name: Upload image artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.OUTPUT_IMAGE_N }}
path: ${{ env.OUTPUT_IMAGE }}

test_rtp_io_dock:
name: Test OpenSIPS+rtp.io
needs: build_rtp_io_dock
name: Test (GHCR)
needs: [build_rtp_io_dock, set_env]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
test_platform: ${{ fromJSON(needs.build_rtp_io_dock.outputs.test_matrix) }}
test_platform: ${{ fromJSON(needs.set_env.outputs.test-matrix) }}
env:
TARGETPLATFORM: ${{ matrix.test_platform }}
BUILD_IMAGE: ${{ needs.build_rtp_io_dock.outputs.build_image }}
BUILD_IMAGE: ${{ needs.set_env.outputs.build-image }}
BUILD_OS: ${{ needs.set_env.outputs.build-os }}

steps:
- name: Set dynamic environment
run: |
BUILD_OS="`echo ${{ inputs.rtpp-tag }} | sed 's|-.*|| ; s|_|-|g'`"
echo "BUILD_OS=${BUILD_OS}" >> $GITHUB_ENV
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v3
Expand Down

0 comments on commit cbc3d9b

Please sign in to comment.