Test native 1 #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: UnitGateTest | ||
on: | ||
workflow_call: | ||
inputs: | ||
test_type: | ||
description: 'weekly, nightly, prstatechange, prrecheck, cherry-pick, mergepr' | ||
required: true | ||
type: string | ||
asterisk_repo: | ||
required: true | ||
type: string | ||
pr_number: | ||
required: true | ||
type: string | ||
base_branch: | ||
required: true | ||
type: string | ||
is_cherry_pick: | ||
required: false | ||
type: boolean | ||
default: false | ||
build_script: | ||
required: false | ||
type: string | ||
default: "buildAsterisk.sh" | ||
build_options: | ||
required: false | ||
type: string | ||
default: "" | ||
output_cache_dir: | ||
required: false | ||
type: string | ||
default: cache | ||
build_cache_dir: | ||
required: false | ||
type: string | ||
default: build-cache | ||
modules_blacklist: | ||
type: string | ||
default: "" | ||
required: false | ||
unittest_command: | ||
type: string | ||
required: true | ||
testsuite_repo: | ||
type: string | ||
required: false | ||
default: asterisk/testsuite | ||
testsuite_test_pr: | ||
type: string | ||
required: false | ||
gatetest_list: | ||
type: string | ||
required: true | ||
gatetest_commands: | ||
type: string | ||
required: true | ||
user_group: | ||
required: false | ||
type: string | ||
realtime: | ||
type: boolean | ||
required: false | ||
default: false | ||
secrets: | ||
TOKEN: | ||
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 }} | ||
asterisk_repo: ${{ inputs.asterisk_repo }} | ||
pr_number: ${{ inputs.pr_number }} | ||
base_branch: ${{ inputs.base_branch }} | ||
is_cherry_pick: ${{ inputs.is_cherry_pick }} | ||
build_options: ${{ inputs.build_options }} | ||
modules_blacklist: ${{ inputs.modules_blacklist }} | ||
build_cache_dir: ${{ inputs.build_cache_dir }} | ||
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: | ||
test_type: ${{ inputs.test_type }} | ||
base_branch: ${{ inputs.base_branch }} | ||
user_group: ${{ inputs.user_group }} | ||
unittest_command: ${{ inputs.unittest_command }} | ||
output_cache_dir: ${{ inputs.output_cache_dir }} | ||
build_cache_dir: ${{ inputs.build_cache_dir }} | ||
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 != '[]' }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
group: ${{ fromJSON(inputs.gatetest_list) }} | ||
uses: ./.github/workflows/RunAsteriskGateTests.yml | ||
with: | ||
test_type: ${{ inputs.test_type }} | ||
base_branch: ${{ inputs.base_branch }} | ||
user_group: ${{ inputs.user_group }} | ||
testsuite_repo: ${{ inputs.testsuite_repo }} | ||
testsuite_test_pr: ${{ inputs.testsuite_test_pr }} | ||
gatetest_group: ${{ matrix.group }} | ||
gatetest_commands: ${{ inputs.gatetest_commands }} | ||
build_cache_dir: ${{ inputs.build_cache_dir }} | ||
build_cache_key: ${{ github.workflow }}-${{ github.run_number }}-${{ inputs.pr_number }}-${{ inputs.base_branch }} | ||
realtime: ${{ inputs.realtime }} | ||
secrets: inherit | ||
Results: | ||
name: '**Results-${{ inputs.base_branch }}' | ||
if: always() | ||
runs-on: ubuntu-latest | ||
needs: [Unit,Gate] | ||
steps: | ||
- name: Check test matrix status | ||
env: | ||
GH_TOKEN: ${{ secrets.TOKEN }} | ||
PR_NUMBER: ${{ inputs.pr_number }} | ||
ASTERISK_REPO: ${{ inputs.asterisk_repo }} | ||
RESULT_UNIT: ${{ needs.Unit.result }} | ||
RESULT_GATE: ${{ needs.Gate.result }} | ||
BUILD_CACHE_KEY: ${{ github.workflow }}-${{ github.run_number }}-${{ inputs.pr_number }}-${{ inputs.base_branch }} | ||
run: | | ||
# Check Results | ||
declare -i rc=0 | ||
keep_cache=false | ||
echo "all results: ${{ toJSON(needs.*.result) }}" | ||
case $RESULT_UNIT in | ||
success) | ||
echo "Unit tests passed" | ||
;; | ||
skipped) | ||
echo "Unit tests were skipped because of an earlier failure" | ||
rc+=1 | ||
;; | ||
*) | ||
echo "One or more unit tests failed ($RESULT)" | ||
keep_cache=true | ||
rc+=1 | ||
esac | ||
case $RESULT_GATE in | ||
success) | ||
echo "Gate tests passed" | ||
;; | ||
skipped) | ||
echo "Gate tests were not requested" | ||
;; | ||
*) | ||
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 |