diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index 11fa614..b2c18a9 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -1,3 +1,3 @@ --- -# see https://github.com/ansible/devtools -_extends: ansible/devtools +# see https://github.com/ansible/team-devtools +_extends: ansible/team-devtools diff --git a/.github/workflows/ack.yml b/.github/workflows/ack.yml index 5e7b9f5..ff4f050 100644 --- a/.github/workflows/ack.yml +++ b/.github/workflows/ack.yml @@ -1,5 +1,5 @@ --- -# See https://github.com/ansible/devtools/blob/main/.github/workflows/ack.yml +# See https://github.com/ansible/team-devtools/blob/main/.github/workflows/ack.yml name: ack on: pull_request_target: @@ -7,4 +7,4 @@ on: jobs: ack: - uses: ansible/devtools/.github/workflows/ack.yml@main + uses: ansible/team-devtools/.github/workflows/ack.yml@main diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 1a01af8..029b3a8 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -1,5 +1,5 @@ --- -# See https://github.com/ansible/devtools/blob/main/.github/workflows/push.yml +# See https://github.com/ansible/team-devtools/blob/main/.github/workflows/push.yml name: push on: push: @@ -10,4 +10,4 @@ on: jobs: ack: - uses: ansible/devtools/.github/workflows/push.yml@main + uses: ansible/team-devtools/.github/workflows/push.yml@main diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3b98fc7..5715dc9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,7 +19,7 @@ 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 @@ -27,7 +27,7 @@ jobs: 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 diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index 6ae91ec..4512f6f 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -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 @@ -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 }} @@ -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') }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fa0c9c0..99b3626 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,16 +5,16 @@ exclude: | ) repos: - repo: https://github.com/PyCQA/isort - rev: 5.12.0 + rev: 5.13.2 hooks: - id: isort - repo: https://github.com/psf/black - rev: 23.1.0 + rev: 24.4.2 hooks: - id: black language_version: python3 - repo: https://github.com/pre-commit/pre-commit-hooks.git - rev: v4.4.0 + rev: v4.6.0 hooks: - id: end-of-file-fixer - id: trailing-whitespace @@ -25,7 +25,7 @@ repos: - id: debug-statements language_version: python3 - repo: https://github.com/pycqa/flake8.git - rev: 6.0.0 + rev: 7.0.0 hooks: - id: flake8 additional_dependencies: @@ -35,14 +35,14 @@ repos: - pydocstyle>=5.1.1 language_version: python3 - repo: https://github.com/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://github.com/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 @@ -53,7 +53,7 @@ repos: - pytest>=6.1.2 - enrich>=1.2.5 - repo: https://github.com/PyCQA/pylint - rev: v2.17.0 + rev: v3.2.3 hooks: - id: pylint additional_dependencies: diff --git a/Dockerfile b/Dockerfile index 27fd8f5..3abbbc6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 74c8557..1cec493 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -2,7 +2,7 @@ dependency: name: galaxy driver: - name: delegated + name: default platforms: - name: instance provisioner: diff --git a/readthedocs.yml b/readthedocs.yml index e0ccd25..f312df3 100644 --- a/readthedocs.yml +++ b/readthedocs.yml @@ -9,7 +9,6 @@ build: python: "3.11" python: - system_packages: false install: - method: pip path: . diff --git a/src/subprocess_tee/__init__.py b/src/subprocess_tee/__init__.py index 365b77b..2c7f796 100644 --- a/src/subprocess_tee/__init__.py +++ b/src/subprocess_tee/__init__.py @@ -1,4 +1,5 @@ """tee like run implementation.""" + import asyncio import os import platform diff --git a/test/test_func.py b/test/test_func.py index c630aa3..ecfb8b1 100644 --- a/test/test_func.py +++ b/test/test_func.py @@ -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( diff --git a/test/test_rich.py b/test/test_rich.py index 2b2c7ce..9e530ed 100644 --- a/test/test_rich.py +++ b/test/test_rich.py @@ -1,4 +1,5 @@ """Tests for rich module.""" + import sys import pytest diff --git a/test/test_unit.py b/test/test_unit.py index 1dd4d2f..5f173a1 100644 --- a/test/test_unit.py +++ b/test/test_unit.py @@ -1,5 +1,7 @@ """Unittests.""" + import subprocess +import sys from typing import Dict import pytest @@ -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, @@ -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, @@ -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" diff --git a/tox.ini b/tox.ini index 93b2569..adef027 100644 --- a/tox.ini +++ b/tox.ini @@ -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 =