Jenkinsfile 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. parallel_nodes(['linux && cura', 'windows && cura']) {
  2. timeout(time: 2, unit: "HOURS") {
  3. // Prepare building
  4. stage('Prepare') {
  5. // Ensure we start with a clean build directory.
  6. step([$class: 'WsCleanup'])
  7. // Checkout whatever sources are linked to this pipeline.
  8. checkout scm
  9. }
  10. // If any error occurs during building, we want to catch it and continue with the "finale" stage.
  11. catchError {
  12. stage('Pre Checks') {
  13. if (isUnix()) {
  14. // Check shortcut keys
  15. try {
  16. sh """
  17. echo 'Check for duplicate shortcut keys in all translation files.'
  18. ${env.CURA_ENVIRONMENT_PATH}/master/bin/python3 scripts/check_shortcut_keys.py
  19. """
  20. } catch(e) {
  21. currentBuild.result = "UNSTABLE"
  22. }
  23. // Check setting visibilities
  24. try {
  25. sh """
  26. echo 'Check for duplicate shortcut keys in all translation files.'
  27. ${env.CURA_ENVIRONMENT_PATH}/master/bin/python3 scripts/check_setting_visibility.py
  28. """
  29. } catch(e) {
  30. currentBuild.result = "UNSTABLE"
  31. }
  32. }
  33. }
  34. // Building and testing should happen in a subdirectory.
  35. dir('build') {
  36. // Perform the "build". Since Uranium is Python code, this basically only ensures CMake is setup.
  37. stage('Build') {
  38. def branch = env.BRANCH_NAME
  39. if(!fileExists("${env.CURA_ENVIRONMENT_PATH}/${branch}")) {
  40. branch = "master"
  41. }
  42. // Ensure CMake is setup. Note that since this is Python code we do not really "build" it.
  43. def uranium_dir = get_workspace_dir("Ultimaker/Uranium/${branch}")
  44. cmake("..", "-DCMAKE_PREFIX_PATH=\"${env.CURA_ENVIRONMENT_PATH}/${branch}\" -DCMAKE_BUILD_TYPE=Release -DURANIUM_DIR=\"${uranium_dir}\"")
  45. }
  46. // Try and run the unit tests. If this stage fails, we consider the build to be "unstable".
  47. stage('Unit Test') {
  48. if (isUnix()) {
  49. // For Linux to show everything
  50. def branch = env.BRANCH_NAME
  51. if(!fileExists("${env.CURA_ENVIRONMENT_PATH}/${branch}")) {
  52. branch = "master"
  53. }
  54. def uranium_dir = get_workspace_dir("Ultimaker/Uranium/${branch}")
  55. try {
  56. sh """
  57. cd ..
  58. export PYTHONPATH=.:"${uranium_dir}"
  59. ${env.CURA_ENVIRONMENT_PATH}/${branch}/bin/pytest -x --verbose --full-trace --capture=no ./tests
  60. """
  61. } catch(e) {
  62. currentBuild.result = "UNSTABLE"
  63. }
  64. }
  65. else {
  66. // For Windows
  67. try {
  68. // This also does code style checks.
  69. bat 'ctest -V'
  70. } catch(e) {
  71. currentBuild.result = "UNSTABLE"
  72. }
  73. }
  74. }
  75. stage('Code Style') {
  76. if (isUnix()) {
  77. // For Linux to show everything
  78. def branch = env.BRANCH_NAME
  79. if(!fileExists("${env.CURA_ENVIRONMENT_PATH}/${branch}")) {
  80. branch = "master"
  81. }
  82. def uranium_dir = get_workspace_dir("Ultimaker/Uranium/${branch}")
  83. try {
  84. sh """
  85. cd ..
  86. export PYTHONPATH=.:"${uranium_dir}"
  87. ${env.CURA_ENVIRONMENT_PATH}/${branch}/bin/python3 run_mypy.py
  88. """
  89. } catch(e) {
  90. currentBuild.result = "UNSTABLE"
  91. }
  92. }
  93. }
  94. }
  95. }
  96. // Perform any post-build actions like notification and publishing of unit tests.
  97. stage('Finalize') {
  98. // Publish the test results to Jenkins.
  99. junit allowEmptyResults: true, testResults: 'build/junit*.xml'
  100. notify_build_result(env.CURA_EMAIL_RECIPIENTS, '#cura-dev', ['master', '2.'])
  101. }
  102. }
  103. }