From da1855ae12687286c08c554d9e0153bfc2c2accc Mon Sep 17 00:00:00 2001 From: Maksym Sobolyev Date: Fri, 2 Aug 2024 14:04:12 -0700 Subject: [PATCH] Unify testing pipeline using reusable workflow. --- .github/workflows/.main.yml | 88 ++++++++++++++ .github/workflows/main.yml | 234 +++++------------------------------- 2 files changed, 118 insertions(+), 204 deletions(-) create mode 100644 .github/workflows/.main.yml diff --git a/.github/workflows/.main.yml b/.github/workflows/.main.yml new file mode 100644 index 0000000..611ea15 --- /dev/null +++ b/.github/workflows/.main.yml @@ -0,0 +1,88 @@ +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: + required: false + type: string + default: '' + rtppc-type: + required: true + type: string + rtpp-image: + required: false + type: string + default: 'sippylabs/rtpproxy:latest-ubuntu_latest' + artifact-files: + required: false + type: string + default: '' + +jobs: + test: + runs-on: ubuntu-latest + container: + image: ${{ inputs.rtpp-image }} + options: --privileged + env: + MM_TYPE: ${{ inputs.mm-type }} + MM_BRANCH: ${{ inputs.mm-branch }} + RTPP_BRANCH: DOCKER + RTPPC_TYPE: ${{ inputs.rtppc-type }} + steps: + - uses: actions/checkout@v4 + + - name: Set up Python ${{ inputs.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ inputs.python-version }} + + - name: Define PYTHON_CMD + run: | + PYTHON_VER="`echo ${{ matrix.python-version }} | sed 's|-dev$||'`" + echo "PYTHON_CMD=python${PYTHON_VER}" >> $GITHUB_ENV + + - name: before_install + run: sh -x cibits/before_install.sh + + - name: transform_var + id: transform_var + 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}" != "" ] + then + ARTNAME="${ARTNAME}_${MM_AUTH}" + echo "MM_AUTH=${{ inputs.mm-auth }}" >> $GITHUB_ENV + fi + if [ "${{ inputs.mm-type }}" = "b2bua" ] + then + ARTNAME="${ARTNAME}_${{ inputs.python-version }}" + fi + echo "ARTNAME=${ARTNAME}" >> $GITHUB_OUTPUT + + - name: script + run: sh -x ./test_run.sh + + - name: Test logs + uses: actions/upload-artifact@v4 + with: + name: ${{ steps.transform_var.outputs.ARTNAME }} + path: | + bob.log + alice.log + rtpproxy.log + ${{ inputs.artifact-files }} + continue-on-error: true diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9faba9b..730a9b1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -23,18 +23,12 @@ on: jobs: # Alice->OpenSIPS->Bob opensips: - runs-on: ubuntu-latest - container: - image: sippylabs/rtpproxy:latest-ubuntu_latest - options: --privileged - env: - MM_TYPE: opensips - MM_BRANCH: ${{ matrix.mm-branch }} - RTPP_BRANCH: DOCKER - RTPPC_TYPE: ${{ matrix.rtppc-type }} - python-version: '3.12' - PYTHON_CMD: "python3.12" - + uses: ./.github/workflows/.main.yml + with: + mm-type: 'opensips' + mm-branch: ${{ matrix.mm-branch }} + rtppc-type: ${{ matrix.rtppc-type }} + artifact-files: 'opensips.cfg' strategy: matrix: mm-branch: ['master', '3.5', '3.4', '3.3', '3.2'] @@ -59,227 +53,59 @@ jobs: - mm-branch: '3.1' rtppc-type: 'udp6' - # Steps represent a sequence of tasks that will be executed as part of the job - steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v4 - - - name: Set up Python ${{ env.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ env.python-version }} - - - name: before_install - run: sh -x cibits/before_install.sh - - - name: script - run: sh -x ./test_run.sh - - - name: Test logs - uses: actions/upload-artifact@v4 - with: - name: test-logs_opensips_${{ matrix.mm-branch }}_${{ matrix.rtppc-type }} - path: | - opensips.cfg - bob.log - alice.log - rtpproxy.log - continue-on-error: true - # Alice->OpenSIPS(RFC8760)->Bob opensips_rfc8760: - runs-on: ubuntu-latest - container: - image: sippylabs/rtpproxy:latest-ubuntu_latest - options: --privileged - env: - MM_TYPE: opensips - MM_BRANCH: master - MM_REPO: https://github.com/OpenSIPS/opensips.git - MM_AUTH: ${{ matrix.mm-auth }} - RTPP_BRANCH: DOCKER - RTPPC_TYPE: ${{ matrix.rtppc-type }} - python-version: '3.12' - PYTHON_CMD: "python3.12" + uses: ./.github/workflows/.main.yml + with: + mm-type: 'opensips' + mm-auth: ${{ matrix.mm-auth }} + rtppc-type: ${{ matrix.rtppc-type }} + artifact-files: 'opensips.cfg' strategy: matrix: rtppc-type: ['unix', 'udp', 'udp6', 'tcp', 'tcp6'] mm-auth: ['passtr', 'UAC', 'UAS/auth', 'UAS/auth_db/calculate_ha1', 'UAS/auth_db/ha1'] - # Steps represent a sequence of tasks that will be executed as part of the job - steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v4 - - - name: Set up Python ${{ env.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ env.python-version }} - - - name: before_install - run: sh -x cibits/before_install.sh - - - name: script - run: sh -x ./test_run.sh - - - name: transform_var - id: transform_var - run: echo "mm_auth=`echo ${{ matrix.mm-auth }} | sed 's|/|.|g'`" >> $GITHUB_OUTPUT - - - name: Test logs - uses: actions/upload-artifact@v4 - with: - name: test-logs_opensips_rfc8760_${{ matrix.rtppc-type }}_${{ steps.transform_var.outputs.mm_auth }} - path: | - opensips.cfg - bob.log - alice.log - rtpproxy.log - continue-on-error: true - # Alice->Sippy Python B2B->Bob sippy_py_b2bua: - runs-on: ubuntu-latest - container: - image: sippylabs/rtpproxy:latest-ubuntu_latest - options: --privileged - env: - MM_TYPE: b2bua - MM_BRANCH: ${{ matrix.mm-branch }} - RTPP_BRANCH: DOCKER - RTPPC_TYPE: ${{ matrix.rtppc-type }} - + uses: ./.github/workflows/.main.yml + with: + mm-type: 'b2bua' + mm-branch: ${{ matrix.mm-branch }} + rtppc-type: ${{ matrix.rtppc-type }} + python-version: ${{ matrix.python-version }} + artifact-files: 'b2bua.log' strategy: matrix: mm-branch: ['master', 'PRACK'] rtppc-type: ['unix', 'cunix', 'udp', 'udp6', 'tcp', 'tcp6'] python-version: ['3.9', '3.10', '3.11', '3.12', '3.13-dev'] - # Steps represent a sequence of tasks that will be executed as part of the job - steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v4 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - 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 - - - name: before_install - run: sh -x cibits/before_install.sh - - - name: script - run: sh -x ./test_run.sh - - - - name: Test logs - uses: actions/upload-artifact@v4 - with: - name: test-logs_sippy_py_b2bua_${{ matrix.python-version }}_${{ matrix.mm-branch }}_${{ matrix.rtppc-type }} - path: | - b2bua.log - bob.log - alice.log - rtpproxy.log - continue-on-error: true - # Alice->Sippy GO B2B->Bob sippy_go_b2bua: - runs-on: ubuntu-latest - container: - image: sippylabs/rtpproxy:latest-ubuntu_latest - options: --privileged - env: - MM_TYPE: go-b2bua - MM_BRANCH: master - RTPP_BRANCH: DOCKER - RTPPC_TYPE: ${{ matrix.rtppc-type }} - python-version: '3.12' - PYTHON_CMD: "python3.12" - + uses: ./.github/workflows/.main.yml + with: + mm-type: 'go-b2bua' + rtppc-type: ${{ matrix.rtppc-type }} + artifact-files: 'b2bua.log' strategy: matrix: rtppc-type: ['unix', 'cunix', 'udp', 'udp6', 'tcp', 'tcp6'] - # Steps represent a sequence of tasks that will be executed as part of the job - steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v4 - - - name: Set up Python ${{ env.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ env.python-version }} - - - name: before_install - run: sh -x cibits/before_install.sh - - - name: script - run: sh -x ./test_run.sh - - - name: Test logs - uses: actions/upload-artifact@v4 - with: - name: test-logs_sippy_go_b2bua_${{ matrix.rtppc-type }} - path: | - b2bua.log - bob.log - alice.log - rtpproxy.log - continue-on-error: true - # Alice->Kamailio->Bob kamailio: - runs-on: ubuntu-latest - container: - image: sippylabs/rtpproxy:latest-ubuntu_latest - options: --privileged - env: - MM_TYPE: kamailio - MM_BRANCH: ${{ matrix.mm-branch }} - RTPP_BRANCH: DOCKER - RTPPC_TYPE: ${{ matrix.rtppc-type }} - python-version: '3.12' - PYTHON_CMD: "python3.12" - + uses: ./.github/workflows/.main.yml + with: + mm-type: 'kamailio' + mm-branch: ${{ matrix.mm-branch }} + rtppc-type: ${{ matrix.rtppc-type }} + artifact-files: 'kamailio.cfg' strategy: matrix: mm-branch: ['master', '5.8', '5.7', '5.6', '5.5', '5.4', '5.3', '5.2', '5.1', '5.0', '4.4'] rtppc-type: ['unix', 'udp', 'udp6'] - # Steps represent a sequence of tasks that will be executed as part of the job - steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v4 - - - name: Set up Python ${{ env.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ env.python-version }} - - - name: before_install - run: sh -x cibits/before_install.sh - - - name: script - run: sh -x ./test_run.sh - - - name: Test logs - uses: actions/upload-artifact@v4 - with: - name: test-logs_kamailio_${{ matrix.mm-branch }}_${{ matrix.rtppc-type }} - path: | - kamailio.cfg - bob.log - alice.log - rtpproxy.log - continue-on-error: true - publish: needs: [opensips, opensips_rfc8760, sippy_py_b2bua, sippy_go_b2bua, kamailio] if: github.event_name == 'release' && github.event.action == 'created'