-
Notifications
You must be signed in to change notification settings - Fork 3
173 lines (168 loc) · 5.45 KB
/
AsteriskUnitGateTest.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
name: UnitGateTest
on:
workflow_call:
inputs:
actions_ref:
description: 'JSON object reference to the actions: { "owner": "asterisk", "repo": "asterisk-ci-actions", "branch": "main" }'
type: string
required: false
default: '{ "owner": "asterisk", "repo": "asterisk-ci-actions", "branch": "main" }'
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:
Build:
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
Cleanup:
name: '**Cleanup-${{ 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 0