Skip to content

Commit

Permalink
Test native 1
Browse files Browse the repository at this point in the history
  • Loading branch information
gtjoseph committed Oct 4, 2024
1 parent 101a05d commit e11416b
Show file tree
Hide file tree
Showing 13 changed files with 207 additions and 97 deletions.
38 changes: 26 additions & 12 deletions .github/workflows/AsteriskBuildAndCache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ on:
type: string
default: ""
required: false
sipp_version:
required: false
type: string
default: v3.6.1
output_cache_dir:
type: string
required: false
Expand Down Expand Up @@ -61,6 +65,7 @@ env:
BUILD_SCRIPT: ${{ inputs.build_script }}
BUILD_OPTIONS: ${{ inputs.build_options }}
MODULES_BLACKLIST: ${{ inputs.modules_blacklist }}
SIPP_VERSION: ${{ inputs.sipp_version }}
CACHE_DIR: ${{ github.workspace }}/${{ inputs.output_cache_dir }}
REPO_DIR: ${{ github.event.repository.name }}
REPO_ORG: ${{ github.event.repository.owner.login }}
Expand All @@ -69,30 +74,26 @@ env:
SCRIPT_DIR: ${{ github.workspace }}/asterisk-ci-actions/scripts
BUILD_CACHE_DIR: ${{ github.workspace }}/${{ inputs.build_cache_dir }}
BUILD_CACHE_KEY: ${{ inputs.build_cache_key }}
CI_BRANCH: main
CI_BRANCH: main-test-native

jobs:
Build:
name: ${{ inputs.base_branch }}-build
runs-on: ubuntu-latest
container:
image: ghcr.io/asterisk/asteriskci-agent-rocky8:latest
options: --privileged
defaults:
run:
shell: bash
steps:
- name: DumpEnvironment
if: ${{ inputs.debug }}
uses: asterisk/asterisk-ci-actions/DumpEnvironmentAction@main
- name: Setup Runner
uses: asterisk/asterisk-ci-actions/SetupUbuntuRunner@main-test-native

- name: BuildAsterisk
run: |
sysctl -w kernel.core_pattern=/tmp/core-%e-%t
chmod 1777 /tmp
# Building Asterisk
echo "*** Cloning ${REPO_ORG}/${ACTION_DIR}"
git clone ${GITHUB_SERVER_URL}/${REPO_ORG}/${ACTION_DIR}
git -C ${ACTION_DIR} checkout ${CI_BRANCH:-main}
REPO_DIR=$(basename ${ASTERISK_REPO})
mkdir -p ${REPO_DIR}
mkdir -p ${CACHE_DIR}
Expand All @@ -106,9 +107,9 @@ jobs:
cd ${REPO_DIR}
echo "*** Running Alembic Tests"
${SCRIPT_DIR}/setupDatabase.sh
${SCRIPT_DIR}/runAlembicTests.sh
${SCRIPT_DIR}/teardownDatabase.sh --stop-database
sudo ${SCRIPT_DIR}/setupDatabase.sh
sudo ${SCRIPT_DIR}/runAlembicTests.sh
sudo ${SCRIPT_DIR}/teardownDatabase.sh --stop-database
echo "*** Starting build"
${SCRIPT_DIR}/${BUILD_SCRIPT} --github --branch-name=${BASE_BRANCH} \
Expand All @@ -134,6 +135,19 @@ jobs:
# We don't care if it fails
gh cache delete ${BUILD_CACHE_KEY} || :
- name: BuildSipp
run: |
# Building sipp
cd ${GITHUB_WORKSPACE}
echo "*** Checking out sipp ${SIPP_VERSION}"
git clone ${GITHUB_SERVER_URL}/SIPp/sipp.git
cd sipp
git checkout ${SIPP_VERSION}
echo "*** Building sipp ${SIPP_VERSION}"
./build.sh --full &>/tmp/sipp.build.out || { cat /tmp/sipp.build.out ; exit 1 ; }
echo "*** Installing sipp ${SIPP_VERSION} to ${BUILD_CACHE_DIR}"
install -D -t ${BUILD_CACHE_DIR}/usr/bin sipp
- id: cache-build-output
name: CacheBuildProducts
uses: actions/cache/save@v4
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/AsteriskPRStateChangedPriv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ env:
SHA: ${{ github.event.workflow_run.head_sha }}
HEAD_REPO: ${{ github.event.workflow_run.head_repository.full_name }}
WORKFLOW: ${{ github.event.workflow.name }}
BUILD_CACHE_KEY_PREFIX: ${{ github.event.workflow.name }}-${{ github.event.workflow_run.run_number }}

jobs:
PRStateChangedPriv:
Expand Down Expand Up @@ -135,4 +136,6 @@ jobs:
- name: PostComplete
if: github.event.action == 'completed'
run: |
gh cache delete -R ${REPO} ${WORKFLOW}-${PR_NUMBER}-${BASE_BRANCH} || :
if [ "${CONCLUSION}" == "success"] ; then
gh cache delete -R ${REPO} ${BUILD_CACHE_KEY_PREFIX}-${PR_NUMBER}-${BASE_BRANCH} || :
fi
58 changes: 52 additions & 6 deletions .github/workflows/AsteriskUnitGateTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ on:
user_group:
required: false
type: string
default: asteriskci:users
realtime:
type: boolean
required: false
Expand All @@ -68,7 +67,47 @@ on:
required: true

jobs:
Setup:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: DumpEnvironment
uses: asterisk/asterisk-ci-actions/DumpEnvironmentAction@main
- name: Dirs
run: |
echo "::group::env"
printenv | sort
echo "::endgroup::"
echo "::group::GITHUB_WORKSPCE: ${GITHUB_WORKSPACE}"
ls -al ${GITHUB_WORKSPACE}
echo "::endgroup::"
echo "::group::HOME: ${HOME}"
ls -al ${HOME}
echo "::endgroup::"
echo "::group::RUNNER_WORKSPACE: ${RUNNER_WORKSPACE}"
ls -al ${RUNNER_WORKSPACE}
echo "::endgroup::"
if [ -n "${GITHUB_ACTION_PATH}" ] ; then
echo "::group::GITHUB_ACTION_PATH: ${GITHUB_ACTION_PATH}"
ls -al ${GITHUB_ACTION_PATH}
echo "::endgroup::"
fi
echo "::group::/home/runner/work"
sudo ls -al /home/runner/work
echo "::endgroup::"
echo "::group::ROOT"
sudo ls -al /
echo "::endgroup::"
Build:
if: false
uses: ./.github/workflows/AsteriskBuildAndCache.yml
with:
test_type: ${{ inputs.test_type }}
Expand All @@ -79,10 +118,11 @@ jobs:
build_options: ${{ inputs.build_options }}
modules_blacklist: ${{ inputs.modules_blacklist }}
build_cache_dir: ${{ inputs.build_cache_dir }}
build_cache_key: ${{ github.workflow }}-${{ inputs.pr_number }}-${{ inputs.base_branch }}
build_cache_key: ${{ github.workflow }}-${{ github.run_number }}-${{ inputs.pr_number }}-${{ inputs.base_branch }}
secrets: inherit

Unit:
if: false
needs: Build
uses: ./.github/workflows/RunAsteriskUnitTests.yml
with:
Expand All @@ -92,10 +132,11 @@ jobs:
unittest_command: ${{ inputs.unittest_command }}
output_cache_dir: ${{ inputs.output_cache_dir }}
build_cache_dir: ${{ inputs.build_cache_dir }}
build_cache_key: ${{ github.workflow }}-${{ inputs.pr_number }}-${{ inputs.base_branch }}
build_cache_key: ${{ github.workflow }}-${{ github.run_number }}-${{ inputs.pr_number }}-${{ inputs.base_branch }}
secrets: inherit

Gate:
if: false
needs: Build
name: Gate
if: ${{ inputs.gatetest_list != '[]' }}
Expand All @@ -113,7 +154,7 @@ jobs:
gatetest_group: ${{ matrix.group }}
gatetest_commands: ${{ inputs.gatetest_commands }}
build_cache_dir: ${{ inputs.build_cache_dir }}
build_cache_key: ${{ github.workflow }}-${{ inputs.pr_number }}-${{ inputs.base_branch }}
build_cache_key: ${{ github.workflow }}-${{ github.run_number }}-${{ inputs.pr_number }}-${{ inputs.base_branch }}
realtime: ${{ inputs.realtime }}
secrets: inherit

Expand All @@ -130,10 +171,11 @@ jobs:
ASTERISK_REPO: ${{ inputs.asterisk_repo }}
RESULT_UNIT: ${{ needs.Unit.result }}
RESULT_GATE: ${{ needs.Gate.result }}
BUILD_CACHE_KEY: ${{ github.workflow }}-${{ inputs.pr_number }}-${{ inputs.base_branch }}
BUILD_CACHE_KEY: ${{ github.workflow }}-${{ github.run_number }}-${{ inputs.pr_number }}-${{ inputs.base_branch }}
run: |
gh cache delete -R ${ASTERISK_REPO} ${BUILD_CACHE_KEY} || :
# Check Results
declare -i rc=0
keep_cache=false
echo "all results: ${{ toJSON(needs.*.result) }}"
case $RESULT_UNIT in
success)
Expand All @@ -145,6 +187,7 @@ jobs:
;;
*)
echo "One or more unit tests failed ($RESULT)"
keep_cache=true
rc+=1
esac
case $RESULT_GATE in
Expand All @@ -156,6 +199,9 @@ jobs:
;;
*)
echo "One or more gate tests failed ($RESULT)"
keep_cache=true
rc+=1
esac
$keep_cache || gh cache delete -R ${ASTERISK_REPO} ${BUILD_CACHE_KEY} || :
exit $rc
28 changes: 18 additions & 10 deletions .github/workflows/RunAsteriskGateTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ on:
user_group:
type: string
required: false
default: asteriskci:users
testsuite_repo:
description: 'Testsuite Repo (default: asterisk/testsuite)'
type: string
Expand Down Expand Up @@ -56,7 +55,7 @@ env:
REPO_DIR: ${{ github.event.repository.name }}
REPO_ORG: ${{ github.event.repository.owner.login }}
REALTIME: ${{ inputs.realtime }}
CI_BRANCH: main
CI_BRANCH: main-test-native

TESTSUITE_REPO: ${{ inputs.testsuite_repo }}
TESTSUITE_TEST_PR: ${{ inputs.testsuite_test_pr }}
Expand All @@ -67,32 +66,41 @@ jobs:
RunGateTests:
name: ${{ inputs.base_branch }}-${{ inputs.gatetest_group }}
runs-on: ubuntu-latest
container:
image: ghcr.io/asterisk/asteriskci-agent-rocky8:latest
options: --privileged
defaults:
run:
shell: bash
steps:
- name: Restore Asterisk Cache
uses: asterisk/asterisk-ci-actions/RestoreAsteriskFromCache@main
- name: "Setup Runner"
uses: asterisk/asterisk-ci-actions/SetupUbuntuRunner@main-test-native

- name: "Restore Asterisk Cache"
uses: asterisk/asterisk-ci-actions/RestoreAsteriskFromCache@main-test-native
with:
repo_dir: ${{ github.event.repository.name }}
build_cache_dir: ${{ inputs.build_cache_dir }}
build_cache_key: ${{ inputs.build_cache_key }}
user_group: ${{ inputs.user_group }}

- name: Setup
- name: "Checkout CI"
run: |
# Checkout CI
echo "UNIT_TEST_NAME=unit-${BASE_BRANCH//\//-}" >> "${GITHUB_ENV}"
echo "*** Cloning ${REPO_ORG}/${ACTION_DIR}"
git clone ${GITHUB_SERVER_URL}/${REPO_ORG}/${ACTION_DIR}
git -C ${ACTION_DIR} checkout ${CI_BRANCH:-main}
- name: "Setup testsuite"
run: |
# Setup testsuite
${SCRIPT_DIR}/setupAsteriskGateTests.sh
mkdir -p ${OUTPUT_DIR}
- name: Test
- name: "Run Gate Test ${{inputs.gatetest_group}}"
run: |
# Run Gate Test ${{inputs.gatetest_group}}
TESTRC=0
${SCRIPT_DIR}/runAsteriskGateTests.sh \
sudo ${SCRIPT_DIR}/runAsteriskGateTests.sh \
--testsuite-dir=${TESTSUITE_DIR} \
--test-timeout=${TEST_TIMEOUT} --realtime=$REALTIME --stop-database=true \
--testsuite-command="${TEST_OPTIONS} ${TEST_CMD}" || TESTRC=1
exit $TESTRC
Expand Down
21 changes: 10 additions & 11 deletions .github/workflows/RunAsteriskUnitTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ on:
user_group:
type: string
required: false
default: asteriskci:users
unittest_command:
type: string
required: true
Expand Down Expand Up @@ -42,7 +41,7 @@ env:
OUTPUT_DIR: ${{ github.workspace }}/${{ inputs.output_cache_dir }}/output
REPO_DIR: ${{ github.event.repository.name }}
REPO_ORG: ${{ github.event.repository.owner.login }}
CI_BRANCH: main
CI_BRANCH: main-test-native
BUILD_CACHE_DIR: ${{ inputs.build_cache_dir }}
BUILD_CACHE_KEY: ${{ inputs.build_cache_key }}
UNITTEST_COMMAND: ${{ inputs.unittest_command }}
Expand All @@ -51,40 +50,40 @@ jobs:
RunUnitTests:
name: ${{ inputs.base_branch }}-unit
runs-on: ubuntu-latest
container:
image: ghcr.io/asterisk/asteriskci-agent-rocky8:latest
options: --privileged
defaults:
run:
shell: bash
steps:
- name: Setup Runner
uses: asterisk/asterisk-ci-actions/SetupUbuntuRunner@main-test-native

- name: Restore Asterisk Cache
uses: asterisk/asterisk-ci-actions/RestoreAsteriskFromCache@main
uses: asterisk/asterisk-ci-actions/RestoreAsteriskFromCache@main-test-native
with:
repo_dir: ${{ github.event.repository.name }}
build_cache_dir: ${{ inputs.build_cache_dir }}
build_cache_key: ${{ inputs.build_cache_key }}
user_group: ${{ inputs.user_group }}

- name: Setup
- name: Checkout CI
run: |
sysctl -w kernel.core_pattern=/tmp/core-%e-%t
chmod 1777 /tmp
# Checkout CI
echo "UNIT_TEST_NAME=unit-${BASE_BRANCH//\//-}" >> "${GITHUB_ENV}"
echo "*** Cloning ${REPO_ORG}/${ACTION_DIR}"
git clone ${GITHUB_SERVER_URL}/${REPO_ORG}/${ACTION_DIR}
git -C ${ACTION_DIR} checkout ${CI_BRANCH:-main}
mkdir -p ${OUTPUT_DIR}
- name: Run Unit Tests
run: |
# Run Unit Tests
if [ -d ${REPO_DIR} ] ; then
echo "*** Found asterisk source cache '${REPO_DIR}'"
chown -R ${USER_GROUP} ${REPO_DIR}
[ -n "${USER_GROUP}" ] && chown -R ${USER_GROUP} ${REPO_DIR}
cd ${REPO_DIR}
[ -f tests/keys/rsa_key1.key ] && \
chmod go-rw tests/keys/rsa_key1.key || :
fi
mkdir -p ${OUTPUT_DIR}
echo "*** Running asterisk unit tests"
${SCRIPT_DIR}/runAsteriskUnitTests.sh --no-expect --github \
--user-group=${USER_GROUP} \
Expand Down
Loading

0 comments on commit e11416b

Please sign in to comment.