Skip to content

Commit 9e203f1

Browse files
committed
Install dependencies in the cloned dir rather than the dir where the tests
are set up from. Also, make sure that dependencies are cleaned between branch tests since there are cases when pip doesn't downgrade correctly, which can lead to tests failing when they shouldn't.
1 parent a98c04e commit 9e203f1

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

tests/ci_runner.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import datetime
33
import os
44
import secrets
5+
import shutil
56
import subprocess
67
import sys
78
from contextlib import contextmanager
@@ -99,8 +100,14 @@ def install_deps(branch: str, dir: Path) -> None:
99100
reqpath = dir / 'code' / 'requirements-tests.txt'
100101
if not reqpath.exists():
101102
return
103+
104+
destpath = dir / 'code' / '.packages'
105+
# there have been cases when pip failed to leave a consistent
106+
# installation after a downgrade, so best to start clean
107+
if destpath.exists():
108+
shutil.rmtree(str(destpath))
102109
if MODE == 'plain':
103-
run(get_pip(), 'install', '--target', '.packages', '--upgrade', '-r', str(reqpath))
110+
run(get_pip(), 'install', '--target', str(destpath), '--upgrade', '-r', str(reqpath))
104111
else:
105112
run(get_pip(), 'install', '--upgrade', '-r', str(reqpath))
106113

@@ -138,7 +145,7 @@ def run_branch_tests(conf: Dict[str, str], dir: Path, run_id: str, clone: bool =
138145

139146
cwd = (dir / 'code') if clone else Path('.')
140147
env = dict(os.environ)
141-
env['PYTHONPATH'] = str(Path('.').resolve() / '.packages') \
148+
env['PYTHONPATH'] = str(cwd.resolve() / '.packages') \
142149
+ ':' + str(cwd.resolve() / 'src') \
143150
+ (':' + env['PYTHONPATH'] if 'PYTHONPATH' in env else '')
144151
subprocess.run(args, cwd=cwd.resolve(), env=env)

0 commit comments

Comments
 (0)