unit-test.yml 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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 add-apt-repository ppa:ubuntu-toolchain-r/test -y
  100. sudo apt update
  101. sudo apt upgrade
  102. 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
  103. - name: Install GCC-12 on ubuntu-22.04
  104. if: ${{ startsWith(inputs.runs_on, 'ubuntu-22.04') }}
  105. run: |
  106. sudo apt install g++-12 gcc-12 -y
  107. sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 12
  108. sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 12
  109. - name: Get Conan configuration
  110. run: conan config install https://github.com/Ultimaker/conan-config.git
  111. - name: Install dependencies
  112. run: conan install . ${{ needs.conan-recipe-version.outputs.recipe_id_full }} --build=missing --update -o cura:devtools=True -g VirtualPythonEnv -if venv
  113. - name: Upload the Dependency package(s)
  114. run: conan upload "*" -r cura --all -c
  115. - name: Set Environment variables for Cura (bash)
  116. if: ${{ runner.os != 'Windows' }}
  117. run: |
  118. . ./venv/bin/activate_github_actions_env.sh
  119. - name: Run Unit Test
  120. id: run-test
  121. run: |
  122. pytest --junitxml=junit_cura.xml
  123. working-directory: tests
  124. - name: Upload Test Results
  125. if: always()
  126. uses: actions/upload-artifact@v3
  127. with:
  128. name: Test Results
  129. path: "tests/**/*.xml"
  130. publish-test-results:
  131. permissions:
  132. contents: read # to fetch code (actions/checkout)
  133. checks: write
  134. pull-requests: write # to comment on pull request
  135. runs-on: ubuntu-20.04
  136. needs: [ testing ]
  137. if: success() || failure()
  138. steps:
  139. - name: Checkout
  140. uses: actions/checkout@v3
  141. - name: Setup Python and pip
  142. uses: actions/setup-python@v4
  143. with:
  144. python-version: '3.10.x'
  145. architecture: 'x64'
  146. cache: 'pip'
  147. cache-dependency-path: .github/workflows/requirements-conan-package.txt
  148. - name: Download Artifacts
  149. uses: actions/download-artifact@v3
  150. with:
  151. path: artifacts
  152. - name: Publish Unit Test Results
  153. id: test-results
  154. uses: EnricoMi/publish-unit-test-result-action@v1
  155. with:
  156. files: "artifacts/**/*.xml"
  157. - name: Conclusion
  158. run: echo "Conclusion is ${{ fromJSON( steps.test-results.outputs.json ).conclusion }}"