ci.yml 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. # badge: https://github.com/borgbackup/borg/workflows/CI/badge.svg?branch=master
  2. name: CI
  3. on:
  4. push:
  5. branches: [ master ]
  6. paths:
  7. - '**.py'
  8. - '**.pyx'
  9. - '**.c'
  10. - '**.h'
  11. - '**.yml'
  12. - '**.toml'
  13. - '**.cfg'
  14. - '**.ini'
  15. - 'requirements.d/*'
  16. - '!docs/**'
  17. pull_request:
  18. branches: [ master ]
  19. paths:
  20. - '**.py'
  21. - '**.pyx'
  22. - '**.c'
  23. - '**.h'
  24. - '**.yml'
  25. - '**.toml'
  26. - '**.cfg'
  27. - '**.ini'
  28. - 'requirements.d/*'
  29. - '!docs/**'
  30. jobs:
  31. lint:
  32. runs-on: ubuntu-22.04
  33. timeout-minutes: 5
  34. steps:
  35. - uses: actions/checkout@v4
  36. - uses: chartboost/ruff-action@v1
  37. security:
  38. runs-on: ubuntu-24.04
  39. timeout-minutes: 5
  40. steps:
  41. - uses: actions/checkout@v4
  42. - name: Set up Python
  43. uses: actions/setup-python@v5
  44. with:
  45. python-version: '3.10'
  46. - name: Install dependencies
  47. run: |
  48. python -m pip install --upgrade pip
  49. pip install bandit[toml]
  50. - name: Run Bandit
  51. run: |
  52. bandit -r src/borg -c pyproject.toml
  53. linux:
  54. needs: [lint, security]
  55. strategy:
  56. fail-fast: true
  57. matrix:
  58. include:
  59. - os: ubuntu-22.04
  60. python-version: '3.10'
  61. toxenv: mypy
  62. - os: ubuntu-22.04
  63. python-version: '3.11'
  64. toxenv: docs
  65. - os: ubuntu-22.04
  66. python-version: '3.10'
  67. toxenv: py310-fuse2
  68. - os: ubuntu-22.04
  69. python-version: '3.11'
  70. toxenv: py311-fuse3
  71. - os: ubuntu-24.04
  72. python-version: '3.12'
  73. toxenv: py312-fuse3
  74. - os: ubuntu-24.04
  75. python-version: '3.13'
  76. toxenv: py313-fuse3
  77. env:
  78. TOXENV: ${{ matrix.toxenv }}
  79. runs-on: ${{ matrix.os }}
  80. timeout-minutes: 120
  81. steps:
  82. - uses: actions/checkout@v4
  83. with:
  84. # just fetching 1 commit is not enough for setuptools-scm, so we fetch all
  85. fetch-depth: 0
  86. - name: Set up Python ${{ matrix.python-version }}
  87. uses: actions/setup-python@v5
  88. with:
  89. python-version: ${{ matrix.python-version }}
  90. - name: Cache pip
  91. uses: actions/cache@v4
  92. with:
  93. path: ~/.cache/pip
  94. key: ${{ runner.os }}-pip-${{ hashFiles('requirements.d/development.txt') }}
  95. restore-keys: |
  96. ${{ runner.os }}-pip-
  97. ${{ runner.os }}-
  98. - name: Install Linux packages
  99. run: |
  100. sudo apt-get update
  101. sudo apt-get install -y pkg-config build-essential
  102. sudo apt-get install -y libssl-dev libacl1-dev libxxhash-dev liblz4-dev libzstd-dev
  103. sudo apt-get install -y libfuse-dev fuse || true # Required for Python llfuse module
  104. sudo apt-get install -y libfuse3-dev fuse3 || true # Required for Python pyfuse3 module
  105. sudo apt-get install -y bash zsh fish # for shell completion tests
  106. - name: Install Python requirements
  107. run: |
  108. python -m pip install --upgrade pip setuptools wheel
  109. pip install -r requirements.d/development.txt
  110. - name: Install borgbackup
  111. run: |
  112. pip install -e .
  113. - name: run tox env
  114. env:
  115. XDISTN: "4"
  116. run: |
  117. # do not use fakeroot, but run as root. avoids the dreaded EISDIR sporadic failures. see #2482.
  118. #sudo -E bash -c "tox -e py"
  119. tox --skip-missing-interpreters
  120. - name: Upload coverage to Codecov
  121. uses: codecov/codecov-action@v4
  122. env:
  123. OS: ${{ runner.os }}
  124. python: ${{ matrix.python-version }}
  125. with:
  126. token: ${{ secrets.CODECOV_TOKEN }}
  127. env_vars: OS, python
  128. macOS:
  129. needs: linux
  130. strategy:
  131. fail-fast: true
  132. matrix:
  133. include:
  134. - os: macos-14
  135. python-version: '3.11'
  136. toxenv: py311-none # note: no fuse testing, due to #6099, see also #6196.
  137. env:
  138. # Configure pkg-config to use OpenSSL from Homebrew
  139. PKG_CONFIG_PATH: "/opt/homebrew/opt/openssl@3.0/lib/pkgconfig:$PKG_CONFIG_PATH"
  140. TOXENV: ${{ matrix.toxenv }}
  141. runs-on: ${{ matrix.os }}
  142. timeout-minutes: 180
  143. steps:
  144. - uses: actions/checkout@v4
  145. with:
  146. # just fetching 1 commit is not enough for setuptools-scm, so we fetch all
  147. fetch-depth: 0
  148. - name: Set up Python ${{ matrix.python-version }}
  149. uses: actions/setup-python@v5
  150. with:
  151. python-version: ${{ matrix.python-version }}
  152. - name: Cache pip
  153. uses: actions/cache@v4
  154. with:
  155. path: ~/.cache/pip
  156. key: ${{ runner.os }}-pip-${{ hashFiles('requirements.d/development.txt') }}
  157. restore-keys: |
  158. ${{ runner.os }}-pip-
  159. ${{ runner.os }}-
  160. - name: Install macOS packages
  161. run: |
  162. brew unlink pkg-config@0.29.2 || true
  163. brew bundle install
  164. - name: Install Python requirements
  165. run: |
  166. python -m pip install --upgrade pip setuptools wheel
  167. pip install -r requirements.d/development.txt
  168. - name: Install borgbackup
  169. env:
  170. # we already have that in the global env, but something is broken and overwrites that.
  171. # so, set it here, again.
  172. PKG_CONFIG_PATH: "/opt/homebrew/opt/openssl@3.0/lib/pkgconfig:$PKG_CONFIG_PATH"
  173. run: |
  174. pip install -ve .
  175. - name: run tox env
  176. env:
  177. # we already have that in the global env, but something is broken and overwrites that.
  178. # so, set it here, again.
  179. PKG_CONFIG_PATH: "/opt/homebrew/opt/openssl@3.0/lib/pkgconfig:$PKG_CONFIG_PATH"
  180. XDISTN: "6"
  181. run: |
  182. # do not use fakeroot, but run as root. avoids the dreaded EISDIR sporadic failures. see #2482.
  183. #sudo -E bash -c "tox -e py"
  184. tox --skip-missing-interpreters
  185. - name: Upload coverage to Codecov
  186. uses: codecov/codecov-action@v4
  187. env:
  188. OS: ${{ runner.os }}
  189. python: ${{ matrix.python-version }}
  190. with:
  191. token: ${{ secrets.CODECOV_TOKEN }}
  192. env_vars: OS, python
  193. windows:
  194. if: false # can be used to temporary disable build
  195. runs-on: windows-latest
  196. timeout-minutes: 120
  197. needs: linux
  198. env:
  199. PY_COLORS: 1
  200. defaults:
  201. run:
  202. shell: msys2 {0}
  203. steps:
  204. - uses: actions/checkout@v4
  205. with:
  206. fetch-depth: 0
  207. - uses: msys2/setup-msys2@v2
  208. with:
  209. msystem: UCRT64
  210. update: true
  211. - name: Install system packages
  212. run: ./scripts/msys2-install-deps development
  213. - name: Build python venv
  214. run: |
  215. # building cffi / argon2-cffi in the venv fails, so we try to use the system packages
  216. python -m venv --system-site-packages env
  217. . env/bin/activate
  218. # python -m pip install --upgrade pip
  219. # pip install --upgrade setuptools build wheel
  220. pip install pyinstaller==6.11.1
  221. - name: Build
  222. run: |
  223. # build borg.exe
  224. . env/bin/activate
  225. pip install -e .
  226. pyinstaller -y scripts/borg.exe.spec
  227. # build sdist and wheel in dist/...
  228. python -m build
  229. - uses: actions/upload-artifact@v4
  230. with:
  231. name: borg-windows
  232. path: dist/borg.exe
  233. - name: Run tests
  234. run: |
  235. ./dist/borg.exe -V
  236. . env/bin/activate
  237. borg -V
  238. python -m pytest -n4 --benchmark-skip -vv -rs -k "not remote"
  239. - name: Upload coverage to Codecov
  240. uses: codecov/codecov-action@v4
  241. env:
  242. OS: ${{ runner.os }}
  243. python: '3.11'
  244. with:
  245. token: ${{ secrets.CODECOV_TOKEN }}
  246. env_vars: OS, python