Skip to content

Commit

Permalink
Merge branch 'main' into feat/exec_mode
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea authored Jun 14, 2024
2 parents f393a12 + c6337b4 commit 8f73b5f
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 25 deletions.
4 changes: 2 additions & 2 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
# see https:/ansible/devtools
_extends: ansible/devtools
# see https:/ansible/team-devtools
_extends: ansible/team-devtools
4 changes: 2 additions & 2 deletions .github/workflows/ack.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
# See https:/ansible/devtools/blob/main/.github/workflows/ack.yml
# See https:/ansible/team-devtools/blob/main/.github/workflows/ack.yml
name: ack
on:
pull_request_target:
types: [opened, labeled, unlabeled, synchronize]

jobs:
ack:
uses: ansible/devtools/.github/workflows/ack.yml@main
uses: ansible/team-devtools/.github/workflows/ack.yml@main
4 changes: 2 additions & 2 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
# See https:/ansible/devtools/blob/main/.github/workflows/push.yml
# See https:/ansible/team-devtools/blob/main/.github/workflows/push.yml
name: push
on:
push:
Expand All @@ -10,4 +10,4 @@ on:

jobs:
ack:
uses: ansible/devtools/.github/workflows/push.yml@main
uses: ansible/team-devtools/.github/workflows/push.yml@main
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ jobs:

steps:
- name: Switch to using Python 3.8 by default
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.8

- name: Install tox
run: python3 -m pip install --user tox

- name: Check out src from Git
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0 # needed by setuptools-scm

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -49,7 +49,7 @@ jobs:
fetch-depth: 0

- name: Set up stock Python ${{ matrix.python_version }} from GitHub
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python_version }}

Expand All @@ -59,7 +59,7 @@ jobs:
which python
- name: Pip cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ env.PY_SHA256 }}-${{ hashFiles('setup.cfg') }}-${{ hashFiles('tox.ini') }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('.pre-commit-config.yaml') }}-${{ hashFiles('pytest.ini') }}
Expand Down
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ exclude: |
)
repos:
- repo: https:/PyCQA/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
- repo: https:/psf/black
rev: 23.1.0
rev: 24.4.2
hooks:
- id: black
language_version: python3
- repo: https:/pre-commit/pre-commit-hooks.git
rev: v4.4.0
rev: v4.6.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
Expand All @@ -25,7 +25,7 @@ repos:
- id: debug-statements
language_version: python3
- repo: https:/pycqa/flake8.git
rev: 6.0.0
rev: 7.0.0
hooks:
- id: flake8
additional_dependencies:
Expand All @@ -35,14 +35,14 @@ repos:
- pydocstyle>=5.1.1
language_version: python3
- repo: https:/adrienverge/yamllint.git
rev: v1.29.0
rev: v1.35.1
hooks:
- id: yamllint
files: \.(yaml|yml)$
types: [file, yaml]
entry: yamllint --strict
- repo: https:/pre-commit/mirrors-mypy
rev: v1.1.1
rev: v1.10.0
hooks:
- id: mypy
# empty args needed in order to match mypy cli behavior
Expand All @@ -53,7 +53,7 @@ repos:
- pytest>=6.1.2
- enrich>=1.2.5
- repo: https:/PyCQA/pylint
rev: v2.17.0
rev: v3.2.3
hooks:
- id: pylint
additional_dependencies:
Expand Down
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ py3-ruamel.yaml \

RUN \
apk add --update --no-cache \
${BUILD_DEPS} && \
pip3 install -U pip
${BUILD_DEPS}

COPY . /root/code/
WORKDIR /root/code/
RUN \
python3 --version && \
python3 -m venv venv && \
. venv/bin/activate && \
python3 -m pip install ".[test]" && \
python3 -m pytest
2 changes: 1 addition & 1 deletion molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
dependency:
name: galaxy
driver:
name: delegated
name: default
platforms:
- name: instance
provisioner:
Expand Down
1 change: 0 additions & 1 deletion readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ build:
python: "3.11"

python:
system_packages: false
install:
- method: pip
path: .
Expand Down
1 change: 1 addition & 0 deletions src/subprocess_tee/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""tee like run implementation."""

import asyncio
import os
import platform
Expand Down
7 changes: 7 additions & 0 deletions test/test_func.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
"""Functional tests for subprocess-tee library."""

import subprocess
import sys

import pytest


@pytest.mark.skipif(
sys.version_info < (3, 9), reason="molecule test requires python 3.9+"
)
def test_molecule() -> None:
"""Ensures molecule does display output of its subprocesses."""
result = subprocess.run(
Expand Down
1 change: 1 addition & 0 deletions test/test_rich.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for rich module."""

import sys

import pytest
Expand Down
13 changes: 11 additions & 2 deletions test/test_unit.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Unittests."""

import subprocess
import sys
from typing import Dict

import pytest
Expand Down Expand Up @@ -30,7 +32,7 @@ def test_run_list() -> None:
# NOTICE: subprocess.run() does fail to capture any output when cmd is
# a list and you specific shell=True. Still, when not mentioning shell,
# it does work.
cmd = ["python3", "--version"]
cmd = [sys.executable, "--version"]
old_result = subprocess.run(
cmd,
# shell=True,
Expand All @@ -47,7 +49,7 @@ def test_run_list() -> None:

def test_run_echo(capsys: CaptureFixture[str]) -> None:
"""Validate run call with echo dumps command."""
cmd = ["python3", "--version"]
cmd = [sys.executable, "--version"]
old_result = subprocess.run(
cmd,
# shell=True,
Expand Down Expand Up @@ -141,3 +143,10 @@ def test_run_compat() -> None:
assert ours.stdout == original.stdout
assert ours.stderr == original.stderr
assert ours.args == original.args


def test_run_waits_for_completion(tmp_path):
"""run() should always wait for the process to complete."""
tmpfile = tmp_path / "output.txt"
run(f"sleep 0.1 && echo 42 > {str(tmpfile)}")
assert tmpfile.read_text() == "42\n"
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ passenv =
TERM
setenv =
PIP_DISABLE_VERSION_CHECK=1
PYTEST_REQPASS=15
PYTEST_REQPASS=16
py38: PYTEST_REQPASS=15
PYTHONDONTWRITEBYTECODE=1
PYTHONUNBUFFERED=1
commands =
Expand Down

0 comments on commit 8f73b5f

Please sign in to comment.