-
Notifications
You must be signed in to change notification settings - Fork 517
/
Jenkinsfile_int_sims
244 lines (211 loc) · 9.17 KB
/
Jenkinsfile_int_sims
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
#!/usr/bin/env groovy
//=============================================================================
// Pipeline parameters
//=============================================================================
properties([parameters([
string(name: 'branch', defaultValue: ''),
booleanParam(name: 'test_sims', defaultValue: true, description: 'Run all Simulations'),
booleanParam(name: 'internal_simulations', defaultValue: true, description: 'This option asks for default agent from Jenkins')
])])
//=============================================================================
// Configuration
//=============================================================================
boolean test_sims = params.get('test_sims')
//=============================================================================
// Globals
//=============================================================================
// Map that contains stages of tests
def all_tests = [:]
// Task to Label map
task_label = [
'create_afi': 't2.l_50',
'simulation': 'z1d.l',
'dcp_gen': 'z1d.2xl',
'runtime': 'f1.2xl',
'runtime_all_slots': 'f1.16xl',
'source_scripts': 'c4.xl',
'md_links': 'c4.xl',
'find_tests': 't2.l_50',
'sdaccel_builds': 'z1d.2xl'
]
// Put the latest version last
def xilinx_versions = [ '2021.2' ]
// We want the default to be the latest.
def default_xilinx_version = xilinx_versions.last()
def simulator_tool_default_map = [
'2019.1' : [
'vivado': 'xilinx/SDx/2019.1.op2552052',
'vcs': 'synopsys/vcs-mx/N-2017.12-SP2',
'questa': 'questa/10.6c_1',
'ies': 'incisive/15.20.063'
],
'2019.2' : [
'vivado': 'xilinx/Vivado/2019.2',
'vcs': 'synopsys/vcs-mx/O-2018.09-SP2-1',
'questa': 'questa/2019.2',
'ies': 'incisive/15.20.063'
],
'2020.1' : [
'vivado': 'xilinx/Vivado/2020.1',
'vcs': 'synopsys/vcs-mx/P-2019.06-SP1-1',
'questa': 'questa/2019.4',
'ies': 'incisive/15.20.079'
],
'2020.2' : [
'vivado': 'xilinx/Vivado/2020.2',
'vcs': 'synopsys/vcs-mx/Q-2020.03',
'questa': 'questa/2020.2',
'ies': 'incisive/15.20.083'
],
'2021.1' : [
'vivado': 'xilinx/Vivado/2021.1',
'vcs': 'synopsys/vcs/R-2020.12',
'questa': 'questa/2020.4',
'ies': 'incisive/15.20.083'
],
'2021.2' : [
'vivado': 'xilinx/Vivado/2021.2',
'vcs': 'synopsys/vcs/R-2020.12',
'questa': 'questa/2020.4',
'xcelium': 'xcelium/20.09.006'
]
]
// Get serializable entry set
@NonCPS def entrySet(m) {m.collect {k, v -> [key: k, value: v]}}
@NonCPS
def is_public_repo() {
echo "Change URL: ${env.CHANGE_URL}"
return (env.CHANGE_URL =~ /^(\S+)?aws-fpga\/pull\/(\d+)$/)
}
def get_task_label(Map args=[ : ]) {
String task_label = args.xilinx_version + '_' + task_label[args.task]
if (params.internal_simulations) {
echo "internal simulation agent requested"
task_label = 'f1_3rd_party_sims'
}
echo "Label Requested: $task_label"
return task_label
}
def abort_previous_running_builds() {
def hi = Hudson.instance
def pname = env.JOB_NAME.split('/')[0]
hi.getItem(pname).getItem(env.JOB_BASE_NAME).getBuilds().each{ build ->
def executor = build.getExecutor()
if (build.number != currentBuild.number && build.number < currentBuild.number && executor != null) {
executor.interrupt(
Result.ABORTED,
new CauseOfInterruption.UserInterruption("Aborted by #${currentBuild.number}"))
println("Aborted previous running build #${build.number}")
} else {
println("Build is not running or is current build, not aborting - #${build.number}")
}
}
}
// Wait for input if we are running on a public repo to avoid malicious PRS
if (is_public_repo()) {
input "Running on a public repository, do you want to proceed with running the tests?"
} else {
echo "Running on a private repository"
}
//Abort previous builds on PR when we push new commits
// env.CHANGE_ID is only available on PR's and not on branch builds
if (env.CHANGE_ID) {
abort_previous_running_builds()
}
def run_junit(String report_file) {
if (fileExists(report_file)) {
junit healthScaleFactor: 10.0, testResults: report_file
} else {
echo "Pytest wasn't run for stage. Report file not generated: ${report_file}"
}
}
def git_cleanup() {
sh """
set -e
sudo git reset --hard
sudo git clean -fdx
"""
}
//=============================================================================
// Simulations
//=============================================================================
if (test_sims) {
all_tests['Run Sims'] = {
stage('Run Sims') {
def cl_names = ['cl_vhdl_hello_world', 'cl_uram_example', 'cl_dram_dma', 'cl_hello_world', 'cl_sde']
def simulators = ['vivado']
def sim_nodes = [:]
if(params.internal_simulations) {
simulators = ['vcs', 'xcelium', 'questa', 'vivado']
}
for (x in cl_names) {
for (y in xilinx_versions) {
for (z in simulators) {
String xilinx_version = y
String cl_name = x
String simulator = z
if((cl_name == 'cl_vhdl_hello_world') && (simulator == 'xcelium')) {
println ("Skipping Simulator: ${simulator} CL: ${cl_name}")
continue;
}
String cl_dir_name = cl_name
if(cl_name == 'cl_vhdl_hello_world') {
cl_dir_name = "cl_hello_world_vhdl"
}
String node_name = "Sim ${cl_name} ${xilinx_version} ${simulator}"
String key = "test_${cl_name}__"
String report_file = "test_sims_${cl_name}_${xilinx_version}.xml"
def tool_module_map = simulator_tool_default_map.get(xilinx_version)
String vcs_module = tool_module_map.get('vcs')
String questa_module = tool_module_map.get('questa')
String xcelium_module = tool_module_map.get('xcelium')
String vivado_module = tool_module_map.get('vivado')
if(params.internal_simulations) {
report_file = "test_sims_${cl_name}_${xilinx_version}_${simulator}.xml"
}
sim_nodes[node_name] = {
node(get_task_label(task: 'simulation', xilinx_version: xilinx_version)) {
checkout scm
try {
if(params.internal_simulations) {
sh """
set -e
module purge
module load python/3.7.2
module load python/2.7.14
module load slurm
module load ${vivado_module}
module load ${vcs_module}
module load ${questa_module}
module load ${xcelium_module}
source $WORKSPACE/hdk_setup.sh
python2.7 -m pytest -v $WORKSPACE/hdk/tests/simulation_tests/test_sims.py -k \"${key}\" --junit-xml $WORKSPACE/${report_file} --simulator ${simulator} --batch 'TRUE'
"""
} else {
sh """
set -e
source $WORKSPACE/shared/tests/bin/setup_test_hdk_env.sh
python2.7 -m pytest -v $WORKSPACE/hdk/tests/simulation_tests/test_sims.py -k \"${key}\" --junit-xml $WORKSPACE/${report_file} --simulator ${simulator} --batch 'FALSE'
"""
}
} catch (exc) {
echo "${node_name} failed"
throw exc
} finally {
run_junit(report_file)
archiveArtifacts artifacts: "hdk/cl/examples/${cl_dir_name}/**/*.sim.log", fingerprint: true
}
}
}
}
}
}
parallel sim_nodes
}
}
}
//=============================================================================
// SDK Tests
//=============================================================================
// Run the tests here
parallel all_tests