|
| 1 | +// Jenkins configuration. |
| 2 | +properties ([ |
| 3 | + buildDiscarder( |
| 4 | + logRotator(artifactDaysToKeepStr: '', |
| 5 | + artifactNumToKeepStr: '', |
| 6 | + daysToKeepStr: '30', |
| 7 | + numToKeepStr: '100' |
| 8 | + ) |
| 9 | + ) |
| 10 | +]) |
| 11 | + |
| 12 | +// RaaS credentials and settings. |
| 13 | +raas_username = "ci" |
| 14 | +raas_password = "ci" |
| 15 | +raas_timeout = 1200 |
| 16 | + |
| 17 | +// Test combinations, for each listed target, each toolchain is build and tested on RaaS instance. |
| 18 | +targets = [ |
| 19 | + "K64F": ["toolchains": [ "ARM", "IAR", "GCC_ARM"], "raas": "eeva.mbedcloudtesting.com"], |
| 20 | + "NUCLEO_F429ZI": ["toolchains": [ "ARM", "IAR", "GCC_ARM"], "raas": "ruka.mbedcloudtesting.com"], |
| 21 | +] |
| 22 | + |
| 23 | +// Map toolchains to compiler labels to find suitable node on Jenkins. |
| 24 | +def nodes = [ |
| 25 | + ARM: "armcc", |
| 26 | + IAR: "iar_arm", |
| 27 | + GCC_ARM: "arm-none-eabi-gcc", |
| 28 | + SXOS: "linux" |
| 29 | +] |
| 30 | + |
| 31 | +// Initial maps for parallel build steps |
| 32 | +def buildStepsForParallel = [:] |
| 33 | +def testStepsForParallel = [:] |
| 34 | + |
| 35 | +for (target in targets.keySet()) { |
| 36 | + for (toolchain_key in targets[target]["toolchains"]) { |
| 37 | + echo "Include for build: ${target} ${toolchain_key}" |
| 38 | + |
| 39 | + def stepName = "${target} ${toolchain_key}" |
| 40 | + buildStepsForParallel[stepName] = buildStep(target, nodes[toolchain_key], toolchain_key) |
| 41 | + } |
| 42 | +} |
| 43 | + |
| 44 | +for (target in targets.keySet()) { |
| 45 | + for (toolchain_key in targets[target]["toolchains"]) { |
| 46 | + echo "Include for test: ${target} ${toolchain_key}" |
| 47 | + |
| 48 | + def stepName = "${target} ${toolchain_key}" |
| 49 | + testStepsForParallel[stepName] = testStep(target, nodes[toolchain_key], toolchain_key) |
| 50 | + } |
| 51 | +} |
| 52 | + |
| 53 | +// Actually run the steps in parallel - parallel takes a map as an argument, hence the above. |
| 54 | +timestamps { |
| 55 | + parallel buildStepsForParallel |
| 56 | + parallel testStepsForParallel |
| 57 | +} |
| 58 | + |
| 59 | +// Create build steps for parallel execution. |
| 60 | +def buildStep(target, compilerLabel, toolchain) { |
| 61 | + return { |
| 62 | + stage("Build_${target}_${toolchain}") { |
| 63 | + node("${compilerLabel}") { |
| 64 | + deleteDir() |
| 65 | + |
| 66 | + echo "buildStep: ${target} ${compilerLabel} ${toolchain}" |
| 67 | + dir("test") { |
| 68 | + |
| 69 | + // checkout PR. |
| 70 | + checkout scm |
| 71 | + |
| 72 | + // checkout newest Mbed OS release. |
| 73 | + sh "mbed new ." |
| 74 | + |
| 75 | + if (toolchain == "GCC_ARM") { |
| 76 | + // use custom release profile from minimal-printf to override functions in GCC. |
| 77 | + sh "mbed test -vv --compile -m ${target} -t ${toolchain} -n '*minimal-printf*' --build ci --stats-depth 10 --profile ./profiles/release.json" |
| 78 | + } else { |
| 79 | + // use default release profile for ARM and IAR. |
| 80 | + sh "mbed test -vv --compile -m ${target} -t ${toolchain} -n '*minimal-printf*' --build ci --stats-depth 10" |
| 81 | + } |
| 82 | + |
| 83 | + // stash build directory for testins step. |
| 84 | + stash name: "minimal-printf-greentea-${target}-${toolchain}", includes: "ci/**" |
| 85 | + } |
| 86 | + |
| 87 | + step([$class: 'WsCleanup']) |
| 88 | + } |
| 89 | + } |
| 90 | + } |
| 91 | +} |
| 92 | + |
| 93 | +def testStep(target, compilerLabel, toolchain) { |
| 94 | + return { |
| 95 | + stage("Light suite ${target}_${toolchain}") { |
| 96 | + node("${compilerLabel}") { |
| 97 | + deleteDir() |
| 98 | + |
| 99 | + echo "testStep: ${target} ${toolchain}" |
| 100 | + |
| 101 | + // unstash build directory containing greentea tests. |
| 102 | + unstash "minimal-printf-greentea-${target}-${toolchain}" |
| 103 | + |
| 104 | + // setup RaaS environment. |
| 105 | + env.RAAS_USERNAME = raas_username |
| 106 | + env.RAAS_PASSWORD = raas_password |
| 107 | + env.RAAS_PYCLIENT_FORCE_REMOTE_ALLOCATION = 1 |
| 108 | + env.RAAS_PYCLIENT_ALLOCATION_QUEUE_TIMEOUT = raas_timeout |
| 109 | + |
| 110 | + raas = targets[target]["raas"] |
| 111 | + |
| 112 | + // execute greentea on RaaS. |
| 113 | + execute("mbedgt --grm ${target}:raas_client:${raas}:80 -vV --test-spec ./ci/test_spec.json --polling-timeout 240") |
| 114 | + |
| 115 | + // Clean up workarea. |
| 116 | + step([$class: 'WsCleanup']) |
| 117 | + } |
| 118 | + } |
| 119 | + } |
| 120 | +} |
0 commit comments