Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use version from zap.json to download zap #25791

Merged
merged 1 commit into from
Mar 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Use version from zap.json to download zap
  • Loading branch information
lebauce committed Mar 24, 2023
commit 538bb19809d3e2023c6660fcfdb2e3f9956b4bc9
28 changes: 14 additions & 14 deletions scripts/tools/zap/zap_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

import enum
import io
import json
import logging
import os
import re
import shlex
import shutil
import subprocess
Expand Down Expand Up @@ -141,19 +141,19 @@ def _GetZapVersionToUse(project_root):
# This heuristic may be bad at times, however then you can also override the
# version in command line parameters

match_re = re.compile(r'.*ENV\s+ZAP_VERSION=([^# ]*)')

docker_path = os.path.join(project_root, "integrations/docker/images/chip-build/Dockerfile")

with open(docker_path, 'rt') as f:
for l in f.readlines():
l = l.strip()
m = match_re.match(l)
if not m:
continue
return m.group(1)

raise Exception(f"Failed to determine version from {docker_path}")
zap_version = ""
zap_path = os.path.join(project_root, "scripts/setup/zap.json")
zap_json = json.load(open(zap_path))
for package in zap_json.get("packages", []):
for tag in package.get("tags", []):
if tag.startswith("version:2@"):
zap_version = tag.removeprefix("version:2@")
suffix_index = zap_version.rfind(".")
if suffix_index != -1:
zap_version = zap_version[:suffix_index]
return zap_version

raise Exception(f"Failed to determine version from {zap_path}")


@click.command()
Expand Down