ci.yml 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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. - os: ubuntu-24.04
  78. python-version: '3.14-dev'
  79. toxenv: py314-fuse3
  80. env:
  81. TOXENV: ${{ matrix.toxenv }}
  82. runs-on: ${{ matrix.os }}
  83. timeout-minutes: 120
  84. steps:
  85. - uses: actions/checkout@v4
  86. with:
  87. # just fetching 1 commit is not enough for setuptools-scm, so we fetch all
  88. fetch-depth: 0
  89. - name: Set up Python ${{ matrix.python-version }}
  90. uses: actions/setup-python@v5
  91. with:
  92. python-version: ${{ matrix.python-version }}
  93. - name: Cache pip
  94. uses: actions/cache@v4
  95. with:
  96. path: ~/.cache/pip
  97. key: ${{ runner.os }}-pip-${{ hashFiles('requirements.d/development.txt') }}
  98. restore-keys: |
  99. ${{ runner.os }}-pip-
  100. ${{ runner.os }}-
  101. - name: Install Linux packages
  102. run: |
  103. sudo apt-get update
  104. sudo apt-get install -y pkg-config build-essential
  105. sudo apt-get install -y libssl-dev libacl1-dev libxxhash-dev liblz4-dev libzstd-dev
  106. sudo apt-get install -y libfuse-dev fuse || true # Required for Python llfuse module
  107. sudo apt-get install -y libfuse3-dev fuse3 || true # Required for Python pyfuse3 module
  108. sudo apt-get install -y bash zsh fish # for shell completion tests
  109. - name: Install Python requirements
  110. run: |
  111. python -m pip install --upgrade pip setuptools wheel
  112. pip install -r requirements.d/development.txt
  113. - name: Install borgbackup
  114. run: |
  115. pip install -e .
  116. - name: run tox env
  117. env:
  118. XDISTN: "4"
  119. run: |
  120. # do not use fakeroot, but run as root. avoids the dreaded EISDIR sporadic failures. see #2482.
  121. #sudo -E bash -c "tox -e py"
  122. tox --skip-missing-interpreters
  123. - name: Upload coverage to Codecov
  124. uses: codecov/codecov-action@v4
  125. env:
  126. OS: ${{ runner.os }}
  127. python: ${{ matrix.python-version }}
  128. with:
  129. token: ${{ secrets.CODECOV_TOKEN }}
  130. env_vars: OS, python
  131. macOS:
  132. needs: linux
  133. strategy:
  134. fail-fast: true
  135. matrix:
  136. include:
  137. - os: macos-14
  138. python-version: '3.11'
  139. toxenv: py311-none # note: no fuse testing, due to #6099, see also #6196.
  140. env:
  141. # Configure pkg-config to use OpenSSL from Homebrew
  142. PKG_CONFIG_PATH: "/opt/homebrew/opt/openssl@3.0/lib/pkgconfig:$PKG_CONFIG_PATH"
  143. TOXENV: ${{ matrix.toxenv }}
  144. runs-on: ${{ matrix.os }}
  145. timeout-minutes: 180
  146. steps:
  147. - uses: actions/checkout@v4
  148. with:
  149. # just fetching 1 commit is not enough for setuptools-scm, so we fetch all
  150. fetch-depth: 0
  151. - name: Set up Python ${{ matrix.python-version }}
  152. uses: actions/setup-python@v5
  153. with:
  154. python-version: ${{ matrix.python-version }}
  155. - name: Cache pip
  156. uses: actions/cache@v4
  157. with:
  158. path: ~/.cache/pip
  159. key: ${{ runner.os }}-pip-${{ hashFiles('requirements.d/development.txt') }}
  160. restore-keys: |
  161. ${{ runner.os }}-pip-
  162. ${{ runner.os }}-
  163. - name: Install macOS packages
  164. run: |
  165. brew unlink pkg-config@0.29.2 || true
  166. brew bundle install
  167. - name: Install Python requirements
  168. run: |
  169. python -m pip install --upgrade pip setuptools wheel
  170. pip install -r requirements.d/development.txt
  171. - name: Install borgbackup
  172. env:
  173. # we already have that in the global env, but something is broken and overwrites that.
  174. # so, set it here, again.
  175. PKG_CONFIG_PATH: "/opt/homebrew/opt/openssl@3.0/lib/pkgconfig:$PKG_CONFIG_PATH"
  176. run: |
  177. pip install -ve .
  178. - name: run tox env
  179. env:
  180. # we already have that in the global env, but something is broken and overwrites that.
  181. # so, set it here, again.
  182. PKG_CONFIG_PATH: "/opt/homebrew/opt/openssl@3.0/lib/pkgconfig:$PKG_CONFIG_PATH"
  183. XDISTN: "6"
  184. run: |
  185. # do not use fakeroot, but run as root. avoids the dreaded EISDIR sporadic failures. see #2482.
  186. #sudo -E bash -c "tox -e py"
  187. tox --skip-missing-interpreters
  188. - name: Upload coverage to Codecov
  189. uses: codecov/codecov-action@v4
  190. env:
  191. OS: ${{ runner.os }}
  192. python: ${{ matrix.python-version }}
  193. with:
  194. token: ${{ secrets.CODECOV_TOKEN }}
  195. env_vars: OS, python
  196. windows:
  197. if: false # can be used to temporary disable build
  198. runs-on: windows-latest
  199. timeout-minutes: 120
  200. needs: linux
  201. env:
  202. PY_COLORS: 1
  203. defaults:
  204. run:
  205. shell: msys2 {0}
  206. steps:
  207. - uses: actions/checkout@v4
  208. with:
  209. fetch-depth: 0
  210. - uses: msys2/setup-msys2@v2
  211. with:
  212. msystem: UCRT64
  213. update: true
  214. - name: Install system packages
  215. run: ./scripts/msys2-install-deps development
  216. - name: Build python venv
  217. run: |
  218. # building cffi / argon2-cffi in the venv fails, so we try to use the system packages
  219. python -m venv --system-site-packages env
  220. . env/bin/activate
  221. # python -m pip install --upgrade pip
  222. # pip install --upgrade setuptools build wheel
  223. pip install pyinstaller==6.11.1
  224. - name: Build
  225. run: |
  226. # build borg.exe
  227. . env/bin/activate
  228. pip install -e .
  229. pyinstaller -y scripts/borg.exe.spec
  230. # build sdist and wheel in dist/...
  231. python -m build
  232. - uses: actions/upload-artifact@v4
  233. with:
  234. name: borg-windows
  235. path: dist/borg.exe
  236. - name: Run tests
  237. run: |
  238. ./dist/borg.exe -V
  239. . env/bin/activate
  240. borg -V
  241. python -m pytest -n4 --benchmark-skip -vv -rs -k "not remote"
  242. - name: Upload coverage to Codecov
  243. uses: codecov/codecov-action@v4
  244. env:
  245. OS: ${{ runner.os }}
  246. python: '3.11'
  247. with:
  248. token: ${{ secrets.CODECOV_TOKEN }}
  249. env_vars: OS, python