diff --git a/SConstruct b/SConstruct index f4a3de32a9..933a540020 100644 --- a/SConstruct +++ b/SConstruct @@ -1,4 +1,5 @@ import os +import shutil import subprocess import sys import platform @@ -161,10 +162,19 @@ env = Environment( ) if os.environ.get('SCONS_CACHE'): - if QCOM_REPLAY: - CacheDir('/tmp/scons_cache_qcom_replay') - else: - CacheDir('/tmp/scons_cache') + cache_dir = '/tmp/scons_cache' + + if os.getenv('CI'): + branch = os.getenv('GIT_BRANCH') + + if QCOM_REPLAY: + cache_dir = '/tmp/scons_cache_qcom_replay' + elif branch is not None and branch != 'master': + cache_dir_branch = '/tmp/scons_cache_' + branch + if not os.path.isdir(cache_dir_branch) and os.path.isdir(cache_dir): + shutil.copytree(cache_dir, cache_dir_branch) + cache_dir = cache_dir_branch + CacheDir(cache_dir) node_interval = 5 node_count = 0 diff --git a/selfdrive/test/phone_ci.py b/selfdrive/test/phone_ci.py index 1c84b9a50d..3d2e6f0672 100755 --- a/selfdrive/test/phone_ci.py +++ b/selfdrive/test/phone_ci.py @@ -44,7 +44,7 @@ def run_on_phone(test_cmd): # pass in all environment variables prefixed with 'CI_' for k, v in os.environ.items(): - if k.startswith("CI_"): + if k.startswith("CI_") or k in ["GIT_BRANCH", "GIT_COMMIT"]: conn.send(f"export {k}='{v}'\n") conn.send("export CI=1\n")