unit-test.yml 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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. permissions:
  61. contents: read
  62. jobs:
  63. conan-recipe-version:
  64. uses: ultimaker/cura/.github/workflows/conan-recipe-version.yml@main
  65. with:
  66. project_name: cura
  67. testing:
  68. runs-on: ubuntu-20.04
  69. needs: [ conan-recipe-version ]
  70. steps:
  71. - name: Checkout
  72. uses: actions/checkout@v3
  73. - name: Setup Python and pip
  74. uses: actions/setup-python@v4
  75. with:
  76. python-version: '3.10.x'
  77. architecture: 'x64'
  78. cache: 'pip'
  79. cache-dependency-path: .github/workflows/requirements-conan-package.txt
  80. - name: Install Python requirements and Create default Conan profile
  81. run: |
  82. pip install -r requirements-conan-package.txt
  83. conan profile new default --detect
  84. working-directory: .github/workflows/
  85. - name: Use Conan download cache (Bash)
  86. if: ${{ runner.os != 'Windows' }}
  87. run: conan config set storage.download_cache="$HOME/.conan/conan_download_cache"
  88. - name: Cache Conan local repository packages (Bash)
  89. uses: actions/cache@v3
  90. if: ${{ runner.os != 'Windows' }}
  91. with:
  92. path: |
  93. $HOME/.conan/data
  94. $HOME/.conan/conan_download_cache
  95. key: conan-${{ runner.os }}-${{ runner.arch }}-unit-cache
  96. - name: Install Linux system requirements
  97. if: ${{ runner.os == 'Linux' }}
  98. run: |
  99. sudo apt update
  100. sudo apt upgrade
  101. 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
  102. - name: Use GCC-10 on ubuntu-20.04
  103. run: |
  104. sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 10
  105. sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 10
  106. - name: Get Conan configuration
  107. run: conan config install https://github.com/Ultimaker/conan-config.git
  108. - name: Install dependencies
  109. run: conan install . ${{ needs.conan-recipe-version.outputs.recipe_id_full }} --build=missing --update -o cura:devtools=True -g VirtualPythonEnv -if venv
  110. - name: Upload the Dependency package(s)
  111. run: conan upload "*" -r cura --all -c
  112. - name: Set Environment variables for Cura (bash)
  113. if: ${{ runner.os != 'Windows' }}
  114. run: |
  115. . ./venv/bin/activate_github_actions_env.sh
  116. - name: Run Unit Test
  117. id: run-test
  118. run: |
  119. pytest --junitxml=junit_cura.xml
  120. working-directory: tests
  121. - name: Upload Test Results
  122. if: always()
  123. uses: actions/upload-artifact@v3
  124. with:
  125. name: Test Results
  126. path: "tests/**/*.xml"
  127. publish-test-results:
  128. permissions:
  129. contents: read # to fetch code (actions/checkout)
  130. checks: write
  131. pull-requests: write # to comment on pull request
  132. runs-on: ubuntu-20.04
  133. needs: [ testing ]
  134. if: success() || failure()
  135. steps:
  136. - name: Checkout
  137. uses: actions/checkout@v3
  138. - name: Setup Python and pip
  139. uses: actions/setup-python@v4
  140. with:
  141. python-version: '3.10.x'
  142. architecture: 'x64'
  143. cache: 'pip'
  144. cache-dependency-path: .github/workflows/requirements-conan-package.txt
  145. - name: Download Artifacts
  146. uses: actions/download-artifact@v3
  147. with:
  148. path: artifacts
  149. - name: Publish Unit Test Results
  150. id: test-results
  151. uses: EnricoMi/publish-unit-test-result-action@v1
  152. with:
  153. files: "artifacts/**/*.xml"
  154. - name: Conclusion
  155. run: echo "Conclusion is ${{ fromJSON( steps.test-results.outputs.json ).conclusion }}"