Rollback some stupid stuff #2
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: | ||
actions_ref: | ||
description: 'Reference to the actions: owner/repo@branch' | ||
type: string | ||
required: true | ||
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 | ||
Build: | ||
needs: [ Setup ] | ||
uses: ./.github/workflows/AsteriskBuildAndCache.yml | ||
with: | ||
actions_ref: ${{ inputs.actions_ref }} | ||
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: | ||
needs: Build | ||
uses: ./.github/workflows/RunAsteriskUnitTests.yml | ||
with: | ||
actions_ref: ${{ inputs.actions_ref }} | ||
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: | ||
needs: Build | ||
name: Gate | ||
if: ${{ inputs.gatetest_list != '[]' }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
group: ${{ fromJSON(inputs.gatetest_list) }} | ||
uses: ./.github/workflows/RunAsteriskGateTests.yml | ||
with: | ||
actions_ref: ${{ inputs.actions_ref }} | ||
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 |