瀏覽代碼

CI: rather use tox as test runner

so that pytest options are centrally managed in tox configuration.

let tox build venv and install requirements.

tox does this anyway, so we save some time if we
do not need the venv for other purposes also
(like e.g. building binaries).

Also:
- default XDISTN to "auto". XDISTN is still used by Vagrantfile.
- some other optimisations, like less package manager calls.
- use XDISTN=1 for haiku
- fix freebsd binary build condition
Thomas Waldmann 1 月之前
父節點
當前提交
b0ddb15733
共有 2 個文件被更改,包括 19 次插入32 次删除
  1. 18 31
      .github/workflows/ci.yml
  2. 1 1
      pyproject.toml

+ 18 - 31
.github/workflows/ci.yml

@@ -265,8 +265,6 @@ jobs:
         pip install -e .
 
     - name: run tox env
-      env:
-        XDISTN: "4"
       run: |
         # do not use fakeroot, but run as root. avoids the dreaded EISDIR sporadic failures. see #2482.
         #sudo -E bash -c "tox -e py"
@@ -406,9 +404,9 @@ jobs:
                 python -m pip install --upgrade pip wheel
                 pip install -r requirements.d/development.txt
                 pip install -e .
-                pytest -v -n auto --benchmark-skip
+                tox -e py311-none
 
-                if [[ "${DO_BINARIES}" == "true" && "${GITHUB_REF:-}" == refs/tags/* ]]; then
+                if [[ "${{ matrix.do_binaries }}" == "true" && "${{ startsWith(github.ref, 'refs/tags/') }}" == "true" ]]; then
                   python -m pip install 'pyinstaller==6.14.2'
                   mkdir -p dist/binary
                   pyinstaller --clean --distpath=dist/binary scripts/borg.exe.spec
@@ -440,37 +438,24 @@ jobs:
                 sudo -E pkgin -y install zstd lz4 xxhash git || true
                 sudo -E pkgin -y install rust || true
                 sudo -E pkgin -y install pkg-config || true
-                sudo -E pkgin -y install py311-pip py311-virtualenv || true
+                sudo -E pkgin -y install py311-pip py311-virtualenv py311-tox || true
                 sudo -E ln -sf /usr/pkg/bin/python3.11 /usr/pkg/bin/python3 || true
                 sudo -E ln -sf /usr/pkg/bin/pip3.11 /usr/pkg/bin/pip3 || true
                 sudo -E ln -sf /usr/pkg/bin/virtualenv-3.11 /usr/pkg/bin/virtualenv3 || true
+                sudo -E ln -sf /usr/pkg/bin/tox-3.11 /usr/pkg/bin/tox3 || true
 
-                python3 -m virtualenv .venv
-                . .venv/bin/activate
-                python -m pip install --upgrade pip
-                pip install -r requirements.d/development.txt
-                pip install -e .
-                pytest -v -n auto --benchmark-skip
+                tox3 -e py311-none
                 ;;
 
               openbsd)
                 # echo "https://ftp.eu.openbsd.org/pub/OpenBSD" | sudo tee /etc/installurl > /dev/null || true
-                sudo -E pkg_add xxhash || true
-                sudo -E pkg_add lz4 || true
-                sudo -E pkg_add zstd || true
-                sudo -E pkg_add git || true
+                sudo -E pkg_add xxhash lz4 zstd git || true
                 sudo -E pkg_add rust || true
                 sudo -E pkg_add openssl%3.4 || true
-                sudo -E pkg_add py3-pip || true
-                sudo -E pkg_add py3-virtualenv || true
+                sudo -E pkg_add py3-pip py3-virtualenv py3-tox || true
 
                 export BORG_OPENSSL_NAME=eopenssl34
-                python3 -m virtualenv .venv
-                . .venv/bin/activate
-                python -m pip install --upgrade pip
-                pip install -r requirements.d/development.txt
-                pip install -e .
-                pytest -v -n auto --benchmark-skip
+                tox -e py312-none
                 ;;
 
               haiku)
@@ -480,22 +465,24 @@ jobs:
                 pkgman install -y rust_bin || true
                 pkgman install -y python3.10 || true
                 pkgman install -y cffi || true
-                python3 -V || true
                 pkgman install -y lz4_devel zstd_devel xxhash_devel openssl3_devel libffi_devel || true
-                export PKG_CONFIG_PATH="/system/develop/lib/pkgconfig:/system/lib/pkgconfig:${PKG_CONFIG_PATH:-}"
-                export BORG_LIBLZ4_PREFIX=/system/develop
-                export BORG_LIBZSTD_PREFIX=/system/develop
-                export BORG_LIBXXHASH_PREFIX=/system/develop
-                export BORG_OPENSSL_PREFIX=/system/develop
 
+                # there is no pkgman package for tox, so we install it into a venv
                 python3 -m ensurepip --upgrade || true
                 python3 -m pip install --upgrade pip wheel
                 python3 -m venv .venv
                 . .venv/bin/activate
-                python -V
+
+                export PKG_CONFIG_PATH="/system/develop/lib/pkgconfig:/system/lib/pkgconfig:${PKG_CONFIG_PATH:-}"
+                export BORG_LIBLZ4_PREFIX=/system/develop
+                export BORG_LIBZSTD_PREFIX=/system/develop
+                export BORG_LIBXXHASH_PREFIX=/system/develop
+                export BORG_OPENSSL_PREFIX=/system/develop
                 pip install -r requirements.d/development.txt
                 pip install -e .
-                pytest -v --benchmark-skip -k "not remote and not socket"
+
+                # troubles with either tox or pytest xdist, so we run pytest manually:
+                pytest -v -rs --benchmark-skip -k "not remote and not socket"
                 ;;
             esac
 

+ 1 - 1
pyproject.toml

@@ -169,7 +169,7 @@ env_list = ["py{310,311,312,313,314}-{none,fuse2,fuse3}", "docs", "ruff", "mypy"
 [tool.tox.env_run_base]
 package = "editable-legacy"  # without this it does not find setup_docs when running under fakeroot
 deps = ["-rrequirements.d/development.txt"]
-commands = [["pytest", "-v", "-n", "{env:XDISTN:1}", "-rs", "--cov=borg", "--cov-config=pyproject.toml", "--benchmark-skip", "--pyargs", "{posargs:borg.testsuite}"]]
+commands = [["python", "-m", "pytest", "-v", "-n", "{env:XDISTN:auto}", "-rs", "--cov=borg", "--cov-config=pyproject.toml", "--benchmark-skip", "--pyargs", "{posargs:borg.testsuite}"]]
 pass_env = ["*"]  # fakeroot -u needs some env vars
 
 [tool.tox.env_pkg_base]