unit-test.yml 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. ---
  2. name: unit-test
  3. on:
  4. push:
  5. paths:
  6. - 'plugins/**'
  7. - 'resources/**'
  8. - 'cura/**'
  9. - 'icons/**'
  10. - 'tests/**'
  11. - 'packaging/**'
  12. - '.github/workflows/conan-*.yml'
  13. - '.github/workflows/unit-test.yml'
  14. - '.github/workflows/notify.yml'
  15. - '.github/workflows/requirements-conan-package.txt'
  16. - 'requirements*.txt'
  17. - 'conanfile.py'
  18. - 'conandata.yml'
  19. - 'GitVersion.yml'
  20. - '*.jinja'
  21. branches:
  22. - main
  23. - 'CURA-*'
  24. - '[1-9]+.[0-9]+'
  25. tags:
  26. - '[0-9]+.[0-9]+.[0-9]+'
  27. - '[0-9]+.[0-9]+-beta'
  28. pull_request:
  29. paths:
  30. - 'plugins/**'
  31. - 'resources/**'
  32. - 'cura/**'
  33. - 'icons/**'
  34. - 'tests/**'
  35. - 'packaging/**'
  36. - '.github/workflows/conan-*.yml'
  37. - '.github/workflows/unit-test.yml'
  38. - '.github/workflows/notify.yml'
  39. - '.github/workflows/requirements-conan-package.txt'
  40. - 'requirements*.txt'
  41. - 'conanfile.py'
  42. - 'conandata.yml'
  43. - 'GitVersion.yml'
  44. - '*.jinja'
  45. branches:
  46. - main
  47. - '[1-9]+.[0-9]+'
  48. tags:
  49. - '[0-9]+.[0-9]+.[0-9]+'
  50. - '[0-9]+.[0-9]+-beta'
  51. env:
  52. CONAN_LOGIN_USERNAME_CURA: ${{ secrets.CONAN_USER }}
  53. CONAN_PASSWORD_CURA: ${{ secrets.CONAN_PASS }}
  54. CONAN_LOGIN_USERNAME_CURA_CE: ${{ secrets.CONAN_USER }}
  55. CONAN_PASSWORD_CURA_CE: ${{ secrets.CONAN_PASS }}
  56. CONAN_LOG_RUN_TO_OUTPUT: 1
  57. CONAN_LOGGING_LEVEL: info
  58. CONAN_NON_INTERACTIVE: 1
  59. permissions:
  60. contents: read
  61. jobs:
  62. conan-recipe-version:
  63. uses: ultimaker/cura/.github/workflows/conan-recipe-version.yml@main
  64. with:
  65. project_name: cura
  66. testing:
  67. runs-on: ubuntu-22.04
  68. needs: [ conan-recipe-version ]
  69. steps:
  70. - name: Checkout
  71. uses: actions/checkout@v3
  72. with:
  73. fetch-depth: 2
  74. - name: Setup Python and pip
  75. uses: actions/setup-python@v4
  76. with:
  77. python-version: '3.11.x'
  78. architecture: 'x64'
  79. cache: 'pip'
  80. cache-dependency-path: .github/workflows/requirements-conan-package.txt
  81. - name: Install Python requirements and Create default Conan profile
  82. run: pip install -r requirements-conan-package.txt
  83. working-directory: .github/workflows/
  84. - name: Use Conan download cache (Bash)
  85. if: ${{ runner.os != 'Windows' }}
  86. run: conan config set storage.download_cache="$HOME/.conan/conan_download_cache"
  87. - name: Cache Conan local repository packages (Bash)
  88. uses: actions/cache@v3
  89. if: ${{ runner.os != 'Windows' }}
  90. with:
  91. path: |
  92. $HOME/.conan/data
  93. $HOME/.conan/conan_download_cache
  94. key: conan-${{ runner.os }}-${{ runner.arch }}-unit-cache
  95. # NOTE: Due to what are probably github issues, we have to remove the cache and reconfigure before the rest.
  96. # This is maybe because grub caches the disk it uses last time, which is recreated each time.
  97. - name: Install Linux system requirements
  98. if: ${{ runner.os == 'Linux' }}
  99. run: |
  100. sudo rm /var/cache/debconf/config.dat
  101. sudo dpkg --configure -a
  102. sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
  103. sudo apt update
  104. sudo apt upgrade
  105. 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
  106. - name: Install GCC-13
  107. run: |
  108. sudo apt install g++-13 gcc-13 -y
  109. sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 13
  110. sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 13
  111. - name: Get Conan configuration
  112. run: |
  113. conan config install https://github.com/Ultimaker/conan-config.git
  114. conan config install https://github.com/Ultimaker/conan-config.git -a "-b runner/${{ runner.os }}/${{ runner.arch }}"
  115. - name: Get Conan profile
  116. run: conan profile new default --detect --force
  117. - name: Install dependencies
  118. run: conan install . ${{ needs.conan-recipe-version.outputs.recipe_id_full }} --build=missing --update -o cura:devtools=True -g VirtualPythonEnv -if venv
  119. - name: Upload the Dependency package(s)
  120. run: conan upload "*" -r cura --all -c
  121. - name: Set Environment variables for Cura (bash)
  122. if: ${{ runner.os != 'Windows' }}
  123. run: |
  124. . ./venv/bin/activate_github_actions_env.sh
  125. - name: Run Unit Test
  126. id: run-test
  127. run: |
  128. pytest --junitxml=junit_cura.xml
  129. working-directory: tests
  130. - name: Save PR metadata
  131. if: always()
  132. run: |
  133. echo ${{ github.event.number }} > pr-id.txt
  134. echo ${{ github.event.pull_request.head.repo.full_name }} > pr-head-repo.txt
  135. echo ${{ github.event.pull_request.head.ref }} > pr-head-ref.txt
  136. working-directory: tests
  137. - name: Upload Test Results
  138. if: always()
  139. uses: actions/upload-artifact@v3
  140. with:
  141. name: test-result
  142. path: |
  143. tests/**/*.xml
  144. tests/pr-id.txt
  145. tests/pr-head-repo.txt
  146. tests/pr-head-ref.txt