in report/firefox_code_coverage/codecoverage.py [0:0]
def download_grcov():
local_path = os.path.join(os.getcwd(), "grcov")
local_version = os.path.join(os.getcwd(), "grcov_ver")
dest = tempfile.mkdtemp(suffix="grcov")
archive = os.path.join(dest, "grcov.tar.zst")
index = taskcluster.get_service("index")
url = index.buildUrl("findArtifactFromTask", GRCOV_INDEX, GRCOV_ARTIFACT)
download_binary(url, archive)
# Extract archive in temp
dctx = zstandard.ZstdDecompressor()
with open(archive, "rb") as f:
with dctx.stream_reader(f) as reader:
with tarfile.open(mode="r|", fileobj=reader) as tar:
tar.extractall(dest)
os.remove(archive)
# Get version from grcov binary
grcov = os.path.join(dest, "grcov", "grcov")
assert os.path.exists(grcov), "Missing grcov binary"
assert os.path.isfile(grcov), "grcov should be a file"
version = subprocess.check_output([grcov, "--version"]).decode("utf-8")
# Compare version with currently available
if os.path.exists(local_path) and os.path.exists(local_version):
with open(local_version, "r") as f:
installed_ver = f.read()
if installed_ver == version:
return local_path
# Promote downloaded version to installed one
shutil.move(grcov, local_path)
shutil.rmtree(dest)
with open(local_version, "w") as f:
f.write(version)
return local_path