#!/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