Jenkinsfile 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. make('test')
  68. }
  69. }
  70. stage('Code Style') {
  71. if (isUnix()) {
  72. // For Linux to show everything
  73. def branch = env.BRANCH_NAME
  74. if(!fileExists("${env.CURA_ENVIRONMENT_PATH}/${branch}")) {
  75. branch = "master"
  76. }
  77. def uranium_dir = get_workspace_dir("Ultimaker/Uranium/${branch}")
  78. try {
  79. sh """
  80. cd ..
  81. export PYTHONPATH=.:"${uranium_dir}"
  82. ${env.CURA_ENVIRONMENT_PATH}/${branch}/bin/python3 run_mypy.py
  83. """
  84. } catch(e) {
  85. currentBuild.result = "UNSTABLE"
  86. }
  87. }
  88. }
  89. }
  90. }
  91. // Perform any post-build actions like notification and publishing of unit tests.
  92. stage('Finalize') {
  93. // Publish the test results to Jenkins.
  94. junit allowEmptyResults: true, testResults: 'build/junit*.xml'
  95. notify_build_result(env.CURA_EMAIL_RECIPIENTS, '#cura-dev', ['master', '2.'])
  96. }
  97. }
  98. }