Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
bwoodsend committed Nov 13, 2024
1 parent 6293a0d commit 657adf1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ jobs:
- python: 3.8.12 # Test https://docs.python.org/3/library/tarfile.html#supporting-older-python-versions
docker: podman
suite:
- tests/test_mirror.py tests/test_docker.py tests/test_project.py tests/test_desktopfile.py tests/test_docs.py
# - tests/test_mirror.py tests/test_docker.py tests/test_project.py tests/test_desktopfile.py tests/test_docs.py
- tests/test_alpine.py tests/test_completion.py
- tests/test_arch.py tests/test_configuration.py
- tests/test_manjaro.py
# - tests/test_manjaro.py
- tests/test_fedora.py
- tests/test_void.py
- tests/test_debian.py
- tests/test_ubuntu.py
# - tests/test_void.py
# - tests/test_debian.py
# - tests/test_ubuntu.py
fail-fast: false

runs-on: ubuntu-latest
Expand Down
12 changes: 12 additions & 0 deletions polycotylus/_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def __init__(self, base, command=None, *flags, volumes=(), check=True,
interactive=False, tty=False, root=True, post_mortem=False,
architecture=machine(), verbosity=None):
tty = tty and sys.stdin.isatty()
github_actions = os.environ.get("GITHUB_ACTIONS")
if interactive:
verbosity = 2
if verbosity is None:
Expand Down Expand Up @@ -96,6 +97,8 @@ def __init__(self, base, command=None, *flags, volumes=(), check=True,
arguments += command
human_friendly = f"$ {docker} run --rm " + shlex.join(arguments)
if verbosity >= 1:
if verbosity >= 2 and github_actions:
print("::group::", end="")
print(termcolor.colored(human_friendly, "blue"), flush=True)

p = _run([docker, "create"] + arguments, stdout=PIPE, stderr=PIPE)
Expand All @@ -105,8 +108,12 @@ def __init__(self, base, command=None, *flags, volumes=(), check=True,
p = _run([docker, "container", "start", "-ia" if interactive else "-a", self.id],
stdout=None if verbosity >= 2 else DEVNULL,
stderr=STDOUT if verbosity >= 2 else PIPE)

if verbosity >= 2 and github_actions:
print("::endgroup::", end="")
if verbosity >= 2 and self.output:
print(flush=True)

self.returncode = p.returncode
if check and self.returncode:
if post_mortem and globals()["post_mortem"]:
Expand Down Expand Up @@ -195,13 +202,18 @@ def build(dockerfile, root, *flags, target=None, architecture=machine(), verbosi
command = [docker, "build", "-f", str(dockerfile), "--network=host", "."]
if verbosity is None:
verbosity = _verbosity()
github_actions = os.environ.get("GITHUB_ACTIONS")
if target:
command += ["--target", target]
command += ["--pull", "--platform=linux/" + architecture, *flags]
if verbosity >= 1:
if verbosity >= 2 and github_actions:
print("::group::", end="")
print(termcolor.colored("$ " + shlex.join(command), "blue"))
returncode, output = _tee_run(command, verbosity, cwd=root,
env={"DOCKER_SCAN_SUGGEST": "false", **os.environ})
if verbosity >= 2 and github_actions:
print("::endgroup::", flush=True)
if returncode:
raise Error("$ " + shlex.join(command), output)
return _audit_image(_parse_build_output(output))
Expand Down

0 comments on commit 657adf1

Please sign in to comment.