Skip to content

Commit

Permalink
Pull image only once.
Browse files Browse the repository at this point in the history
  • Loading branch information
sobomax committed Aug 2, 2024
1 parent 41fe703 commit ae936ea
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 82 deletions.
87 changes: 87 additions & 0 deletions .github/workflows/.main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
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
artifact-files:
required: false
type: string
default: ''
secrets:
required:
- PYPI_USERNAME
- PYPI_PASSWORD

jobs:
job:
runs-on: ubuntu-latest
env:
MM_TYPE: ${{ input.mm-type }}
MM_BRANCH: ${{ input.mm-branch }}
RTPP_BRANCH: DOCKER
RTPPC_TYPE: ${{ matrix.rtppc-type }}
PYTHON_CMD: "python${{ input.python-version }}"
steps:
- name: Download saved Docker image
uses: actions/download-artifact@v4
with:
name: rtpproxy_latest_ubuntu_latest
path: rtpproxy_latest_ubuntu_latest.tar

- name: Load Docker image
run: docker load -i rtpproxy_latest_ubuntu_latest.tar

- name: Set up container environment
run: docker run --privileged -d --name rtpproxy_container sippylabs/rtpproxy:latest-ubuntu_latest

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

- 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
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
115 changes: 33 additions & 82 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,32 @@ on:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# Alice->OpenSIPS->Bob
opensips:
pull_image:
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"
RTPP_IMAGE: sippylabs/rtpproxy:latest-ubuntu_latest
steps:
- name: Pull Docker image
run: docker pull ${RTPP_IMAGE}

- name: Save Docker image
run: docker save ${RTPP_IMAGE} -o rtpproxy_latest_ubuntu_latest.tar

- name: Upload Docker image
uses: actions/upload-artifact@v4
with:
name: rtpproxy_latest_ubuntu_latest
path: rtpproxy_latest_ubuntu_latest.tar

# Alice->OpenSIPS->Bob
opensips:
needs: pull_image
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']
Expand All @@ -59,87 +71,24 @@ 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"
needs: pull_image
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:
if: false
runs-on: ubuntu-latest
container:
image: sippylabs/rtpproxy:latest-ubuntu_latest
Expand Down Expand Up @@ -191,6 +140,7 @@ jobs:

# Alice->Sippy GO B2B->Bob
sippy_go_b2bua:
if: false
runs-on: ubuntu-latest
container:
image: sippylabs/rtpproxy:latest-ubuntu_latest
Expand Down Expand Up @@ -236,6 +186,7 @@ jobs:

# Alice->Kamailio->Bob
kamailio:
if: false
runs-on: ubuntu-latest
container:
image: sippylabs/rtpproxy:latest-ubuntu_latest
Expand Down

0 comments on commit ae936ea

Please sign in to comment.