diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6c9a415..35ed6fd 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -35,6 +35,40 @@ variables: # using -n auto (untouched by this var). PYTEST_XDIST_AUTO_NUM_WORKERS: "4" +# ---------------------------------------------------------------------- +# Shared venv-warmup steps. +# +# gitlab-runner rotates between build directories +# (builds/RUNNER_ID/0, /1, /3, ...). We cache `.venv/` to skip +# reinstalling deps on every push — but an editable install +# (`pip install -e .`) bakes the absolute build-dir path into +# `__editable__.arborist-0.0.1.pth` and the dist-info RECORD. When +# the cached venv is restored into a different build dir, the +# embedded path is stale; the next `pip install -e` triggers an +# implicit uninstall-then-reinstall that fails with `OSError: No such +# file or directory` looking for files at the old build dir. +# +# Fix: before installing, wipe the editable-install metadata so pip +# does a fresh install at the current build dir's path. Cache stays +# warm (deps don't re-download), only the editable-install +# bookkeeping is rebuilt — costs ~1s per job. +# +# Each job's before_script references this via +# `!reference [.warm-venv-setup, before_script]` and then adds its +# own `pip install -e '...'` line (so jobs can pick different extras +# — `.[dev]` vs `.[dev,crawler]`). +# ---------------------------------------------------------------------- +.warm-venv-setup: + before_script: + - python3 --version + - test -d .venv || python3 -m venv .venv + # Wipe stale editable-install bookkeeping from a prior build dir. + - rm -rf .venv/lib/python*/site-packages/arborist-*.dist-info + - rm -f .venv/lib/python*/site-packages/__editable__.arborist*.pth + - rm -f .venv/lib/python*/site-packages/__editable___arborist*_finder.py + - rm -f .venv/bin/arborist + - .venv/bin/pip install --upgrade pip wheel + # ---------------------------------------------------------------------- # Default test job — runs the CI-scoped suite via `make test-ci`, # which is `make test` minus tests/crawler (network) and the @@ -61,9 +95,7 @@ test: - .venv/ - .pip-cache/ before_script: - - python3 --version - - test -d .venv || python3 -m venv .venv - - .venv/bin/pip install --upgrade pip wheel + - !reference [.warm-venv-setup, before_script] - .venv/bin/pip install -e '.[dev]' script: # `make test-ci` invokes pytest with --ignore=tests/crawler @@ -100,9 +132,7 @@ bench-suite: - .venv/ - .pip-cache/ before_script: - - python3 --version - - test -d .venv || python3 -m venv .venv - - .venv/bin/pip install --upgrade pip wheel + - !reference [.warm-venv-setup, before_script] - .venv/bin/pip install -e '.[dev]' script: - mkdir -p bench/results @@ -146,8 +176,7 @@ substrate-score: - .venv/ - .pip-cache/ before_script: - - test -d .venv || python3 -m venv .venv - - .venv/bin/pip install --upgrade pip wheel + - !reference [.warm-venv-setup, before_script] - .venv/bin/pip install -e '.[dev]' script: # Find this branch's bench result. @@ -188,8 +217,7 @@ test-crawler: - .venv/ - .pip-cache/ before_script: - - test -d .venv || python3 -m venv .venv - - .venv/bin/pip install --upgrade pip wheel + - !reference [.warm-venv-setup, before_script] - .venv/bin/pip install -e '.[dev,crawler]' script: - make test-crawler