diff --git a/.github/workflows/.rtp.io.yml b/.github/workflows/.rtp.io.yml index 99567940b1..fdcc9d8d75 100644 --- a/.github/workflows/.rtp.io.yml +++ b/.github/workflows/.rtp.io.yml @@ -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 + 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 @@ -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: @@ -110,24 +126,78 @@ jobs: tags: ${{ env.BUILD_IMAGE }} push: true + build_rtp_io_dock_local: + name: Build OpenSIPS+rtp.io 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: 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: myimage:${{ matrix.platform }} + outputs: type=docker,dest=./image-${{ matrix.platform }}.tar + + - name: Upload image artifact + uses: actions/upload-artifact@v3 + with: + name: image-${{ matrix.platform }} + path: ./image-${{ matrix.platform }}.tar + test_rtp_io_dock: name: Test OpenSIPS+rtp.io - needs: build_rtp_io_dock + 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