unit-test.yml 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. ---
  2. name: unit-test
  3. # FIXME: This should be a reusable workflow
  4. on:
  5. push:
  6. paths:
  7. - 'plugins/**'
  8. - 'resources/**'
  9. - 'cura/**'
  10. - 'icons/**'
  11. - 'tests/**'
  12. - 'packaging/**'
  13. - '.github/workflows/conan-*.yml'
  14. - '.github/workflows/unit-test.yml'
  15. - '.github/workflows/notify.yml'
  16. - '.github/workflows/requirements-conan-package.txt'
  17. - 'requirements*.txt'
  18. - 'conanfile.py'
  19. - 'conandata.yml'
  20. - 'GitVersion.yml'
  21. - '*.jinja'
  22. branches:
  23. - main
  24. - 'CURA-*'
  25. - '[1-9]+.[0-9]+'
  26. tags:
  27. - '[0-9]+.[0-9]+.[0-9]+'
  28. - '[0-9]+.[0-9]+-beta'
  29. pull_request:
  30. paths:
  31. - 'plugins/**'
  32. - 'resources/**'
  33. - 'cura/**'
  34. - 'icons/**'
  35. - 'tests/**'
  36. - 'packaging/**'
  37. - '.github/workflows/conan-*.yml'
  38. - '.github/workflows/unit-test.yml'
  39. - '.github/workflows/notify.yml'
  40. - '.github/workflows/requirements-conan-package.txt'
  41. - 'requirements*.txt'
  42. - 'conanfile.py'
  43. - 'conandata.yml'
  44. - 'GitVersion.yml'
  45. - '*.jinja'
  46. branches:
  47. - main
  48. - '[1-9]+.[0-9]+'
  49. tags:
  50. - '[0-9]+.[0-9]+.[0-9]+'
  51. - '[0-9]+.[0-9]+-beta'
  52. env:
  53. CONAN_LOGIN_USERNAME_CURA: ${{ secrets.CONAN_USER }}
  54. CONAN_PASSWORD_CURA: ${{ secrets.CONAN_PASS }}
  55. CONAN_LOGIN_USERNAME_CURA_CE: ${{ secrets.CONAN_USER }}
  56. CONAN_PASSWORD_CURA_CE: ${{ secrets.CONAN_PASS }}
  57. CONAN_LOG_RUN_TO_OUTPUT: 1
  58. CONAN_LOGGING_LEVEL: info
  59. CONAN_NON_INTERACTIVE: 1
  60. jobs:
  61. conan-recipe-version:
  62. uses: ultimaker/cura/.github/workflows/conan-recipe-version.yml@main
  63. with:
  64. project_name: cura
  65. testing:
  66. runs-on: ubuntu-20.04
  67. needs: [ conan-recipe-version ]
  68. steps:
  69. - name: Checkout
  70. uses: actions/checkout@v3
  71. - name: Setup Python and pip
  72. uses: actions/setup-python@v4
  73. with:
  74. python-version: '3.10.x'
  75. architecture: 'x64'
  76. cache: 'pip'
  77. cache-dependency-path: .github/workflows/requirements-conan-package.txt
  78. - name: Install Python requirements and Create default Conan profile
  79. run: |
  80. pip install -r requirements-conan-package.txt
  81. conan profile new default --detect
  82. working-directory: .github/workflows/
  83. - name: Use Conan download cache (Bash)
  84. if: ${{ runner.os != 'Windows' }}
  85. run: conan config set storage.download_cache="$HOME/.conan/conan_download_cache"
  86. - name: Cache Conan local repository packages (Bash)
  87. uses: actions/cache@v3
  88. if: ${{ runner.os != 'Windows' }}
  89. with:
  90. path: |
  91. $HOME/.conan/data
  92. $HOME/.conan/conan_download_cache
  93. key: conan-${{ runner.os }}-${{ runner.arch }}-unit-cache
  94. - name: Install Linux system requirements
  95. if: ${{ runner.os == 'Linux' }}
  96. run: |
  97. sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
  98. sudo apt update
  99. sudo apt upgrade
  100. sudo apt install build-essential checkinstall libegl-dev zlib1g-dev libssl-dev ninja-build autoconf libx11-dev libx11-xcb-dev libfontenc-dev libice-dev libsm-dev libxau-dev libxaw7-dev libxcomposite-dev libxcursor-dev libxdamage-dev libxdmcp-dev libxext-dev libxfixes-dev libxi-dev libxinerama-dev libxkbfile-dev libxmu-dev libxmuu-dev libxpm-dev libxrandr-dev libxrender-dev libxres-dev libxss-dev libxt-dev libxtst-dev libxv-dev libxvmc-dev libxxf86vm-dev xtrans-dev libxcb-render0-dev libxcb-render-util0-dev libxcb-xkb-dev libxcb-icccm4-dev libxcb-image0-dev libxcb-keysyms1-dev libxcb-randr0-dev libxcb-shape0-dev libxcb-sync-dev libxcb-xfixes0-dev libxcb-xinerama0-dev xkb-data libxcb-dri3-dev uuid-dev libxcb-util-dev libxkbcommon-x11-dev pkg-config -y
  101. - name: Install GCC-12 on ubuntu-22.04
  102. if: ${{ startsWith(inputs.runs_on, 'ubuntu-22.04') }}
  103. run: |
  104. sudo apt install g++-12 gcc-12 -y
  105. sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 12
  106. sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 12
  107. - name: Get Conan configuration
  108. run: conan config install https://github.com/Ultimaker/conan-config.git
  109. - name: Install dependencies
  110. run: conan install . ${{ needs.conan-recipe-version.outputs.recipe_id_full }} --build=missing --update -o cura:devtools=True -g VirtualPythonEnv -if venv
  111. - name: Upload the Dependency package(s)
  112. run: conan upload "*" -r cura --all -c
  113. - name: Set Environment variables for Cura (bash)
  114. if: ${{ runner.os != 'Windows' }}
  115. run: |
  116. . ./venv/bin/activate_github_actions_env.sh
  117. - name: Run Unit Test
  118. id: run-test
  119. run: |
  120. pytest --junitxml=junit_cura.xml
  121. working-directory: tests
  122. - name: Upload Test Results
  123. if: always()
  124. uses: actions/upload-artifact@v3
  125. with:
  126. name: Test Results
  127. path: "tests/**/*.xml"
  128. publish-test-results:
  129. runs-on: ubuntu-20.04
  130. needs: [ testing ]
  131. if: success() || failure()
  132. steps:
  133. - name: Checkout
  134. uses: actions/checkout@v3
  135. - name: Setup Python and pip
  136. uses: actions/setup-python@v4
  137. with:
  138. python-version: '3.10.x'
  139. architecture: 'x64'
  140. cache: 'pip'
  141. cache-dependency-path: .github/workflows/requirements-conan-package.txt
  142. - name: Download Artifacts
  143. uses: actions/download-artifact@v3
  144. with:
  145. path: artifacts
  146. - name: Publish Unit Test Results
  147. id: test-results
  148. uses: EnricoMi/publish-unit-test-result-action@v1
  149. with:
  150. files: "artifacts/**/*.xml"
  151. - name: Conclusion
  152. run: echo "Conclusion is ${{ fromJSON( steps.test-results.outputs.json ).conclusion }}"