Separate scons cache by branch (#1836)

* separate scons cache by branch

* debug

* guess you can only call CacheDir once

* remove another call

* pass git branch and commit through

* copytree

* set CI
albatross
Adeeb Shihadeh 2020-07-07 12:36:02 -07:00 committed by GitHub
parent bb1e3fc13a
commit d8ff186545
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 5 deletions

View File

@ -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

View File

@ -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")