Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

ci(verify): per-suite environment in suites.json

Richie McIlroybec869e7a638
diff --git a/scripts/verify/plan.py b/scripts/verify/plan.py
index 121e8c4f8..d0483b042 100755
--- a/scripts/verify/plan.py
+++ b/scripts/verify/plan.py
@@ -103,6 +103,22 @@ def cmd_select(args):
print(",".join(skips))
+def cmd_env(args):
+ """Shell `export` lines for the env of the selected suites (suites.json
+ `env`: {"KEY": "value"} or {"KEY": {"<platform>": "value"}}). Variables
+ already set in the environment win."""
+ import shlex
+ config = load_config()
+ names = [n for n in (args.suites or "").split(",") if n]
+ for suite in select(config, args.tier, args.platform, names or None, args.local):
+ for key, value in suite.get("env", {}).items():
+ if isinstance(value, dict):
+ value = value.get(args.platform)
+ if value is None or key in os.environ:
+ continue
+ print(f"export {key}={shlex.quote(str(value))}")
+
+
def workspace_graph(metadata):
"""Package dirs and reverse dependencies (normal, dev and build)."""
dirs, deps = {}, {}
@@ -274,6 +290,12 @@ def main():
p.add_argument("--suites")
p.add_argument("--local", action="store_true")
p.set_defaults(func=cmd_select)
+ p = sub.add_parser("env")
+ p.add_argument("--tier", choices=["fast", "full"], required=True)
+ p.add_argument("--platform", choices=PLATFORMS, required=True)
+ p.add_argument("--suites")
+ p.add_argument("--local", action="store_true")
+ p.set_defaults(func=cmd_env)
p = sub.add_parser("changes")
p.add_argument("--tier", choices=["fast", "full"], required=True)
p.add_argument("--files")
diff --git a/scripts/verify/run.sh b/scripts/verify/run.sh
index 4e0249346..4b9471c8a 100755
--- a/scripts/verify/run.sh
+++ b/scripts/verify/run.sh
@@ -63,6 +63,7 @@ suite_names="$(sed -n 1p <<<"$plan")"
read -r -a cargo_args <<<"$(sed -n 2p <<<"$plan")"
filter="$(sed -n 3p <<<"$plan")"
skip="$(sed -n 4p <<<"$plan")"
+eval "$("$py" scripts/verify/plan.py env --tier "$tier" --platform "$platform" ${suites:+--suites "$suites"} $local_flag)"
if [[ -n "$skip" ]]; then
export CAP_VERIFY_SKIP="${CAP_VERIFY_SKIP:+$CAP_VERIFY_SKIP,}$skip"
fi