-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
scripts: add build-matrix script to ease matching ci
problem: we have good scripts for running in our images locally, but not always with all the same flags as in CI solution: add a script, build-matrix, that takes a name from the actions build matrix and runs docker_run_checks with the same flags as that matrix entry
- Loading branch information
Showing
1 changed file
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import argparse | ||
from pprint import pprint | ||
import json | ||
import os | ||
from pathlib import Path | ||
from re import L | ||
import platform | ||
import subprocess as sp | ||
import shlex | ||
import sys | ||
|
||
p = argparse.ArgumentParser() | ||
p.add_argument("-p","--platform", default=platform.machine()) | ||
p.add_argument("--interactive", action="store_true") | ||
p.add_argument("name") | ||
args = p.parse_args() | ||
|
||
my_path = Path(__file__).absolute() | ||
generate_matrix = my_path.parent.parent.joinpath("src/test/generate-matrix.py") | ||
docker_run_checks = my_path.parent.parent.joinpath("src/test/docker/docker-run-checks.sh") | ||
includes = json.loads(sp.check_output([generate_matrix], env={ | ||
"GITHUB_REF": "refs/heads/master" | ||
}).decode())["include"] | ||
matrix = {} | ||
for b in includes: | ||
matrix[b['name']] = b | ||
|
||
plt = args.platform | ||
if plt in ('x86_64', 'amd64'): | ||
plt = 'test-install' | ||
elif plt == 'aarch64': | ||
plt = 'arm64' | ||
suffix = plt | ||
suffix = f" - {suffix}" | ||
|
||
def usage(): | ||
print("specify the name of a matrix entry as the first argument, from this list:") | ||
for tgt in matrix.keys(): | ||
print(tgt) | ||
|
||
tgt = None | ||
if args.name in matrix: | ||
tgt = matrix[args.name] | ||
else: | ||
tgt = matrix.get(f"{args.name}{suffix}", None) | ||
|
||
if tgt is None: | ||
usage() | ||
sys.exit(1) | ||
|
||
|
||
cmd_arr = shlex.split(tgt['command']) | ||
brk = cmd_arr.index("--") | ||
if args.interactive: | ||
cmd_arr.insert(brk, f"--interactive") | ||
cmd_arr.insert(brk, "-D") | ||
cmd_arr.insert(brk+1, f"build/{tgt['image']}") | ||
print(f"running {cmd_arr} with env={tgt['env']}") | ||
base_env = dict(os.environ) | ||
base_env.update(tgt['env']) | ||
sp.call(cmd_arr, env=base_env) | ||
|