Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to setuptools #238

Merged
merged 10 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
209 changes: 53 additions & 156 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,138 +19,50 @@ jobs:
python-version: '3.x'
- uses: actions/cache@v4
with:
path: ~/.cache/pypoetry/virtualenvs
key: poetry-${{ hashFiles('poetry.lock') }}
path: ~/.tox
key: tox-${{ hashFiles('tox.ini') }}-${{ hashFiles('setup.cfg') }}-${{ hashFiles('test-requirements.txt') }}

- run: |
pip install --upgrade poetry nox nox-poetry
nox -s format -- --check

generate_requirements:
name: Generate requirements.txt for Python 3.6 CI
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- uses: actions/cache@v4
with:
path: ~/.cache/pypoetry/virtualenvs
key: poetry-${{ hashFiles('poetry.lock') }}

- run: |
pipx install poetry
poetry export --with=dev --without-hashes > requirements.txt

- uses: actions/upload-artifact@v4
with:
name: requirements
path: requirements.txt
if-no-files-found: error

ci_36:
name: Run the integration tests for Python 3.6
runs-on: ubuntu-20.04
needs: generate_requirements

strategy:
fail-fast: false
matrix:
container_runtime: ["podman", "docker"]

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.6

- uses: actions/download-artifact@v4
with:
name: requirements
path: .

- run: pip install -r test-requirements.txt

- run: |
export CUR_USER="$(whoami)"
sudo loginctl enable-linger ${CUR_USER}

- run: |
mkdir ./tmp/
chmod 1777 ./tmp
export TMPDIR="$(pwd)/tmp"
# duplication of noxfile.py because we can't use that one with python 3.6 :-/
coverage run -m pytest -vv tests -p pytest_container -x -n auto --reruns 3 --pytest-container-log-level DEBUG
coverage run -m pytest -vv tests -p pytest_container -x --reruns 3 --pytest-container-log-level DEBUG
coverage combine
coverage report -m
coverage xml
- run: pip install tox

- name: verify that no stray containers are left
run: |
[[ $(${{ matrix.container_runtime }} ps -aq|wc -l) = "0" ]]

- name: verify that no stray volumes are left
run: |
[[ $(${{ matrix.container_runtime }} volume ls -q|wc -l) = "0" ]]

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
- run: tox -e format -- --check

ci:
name: Run the integration tests
runs-on: "ubuntu-latest"
runs-on: ${{ matrix.os_version }}
strategy:
fail-fast: false
matrix:
python_version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
python_version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
container_runtime: ["podman", "docker"]
update_runtime: [ true, false ]
without_buildah: [ false ]
os_version: ["ubuntu-latest"]

exclude:
- container_runtime: "docker"
include:
# include python 3.7 on ubuntu 22.04
- container_runtime: "podman"
python_version: "3.7"
update_runtime: true
without_buildah: false
- container_runtime: "docker"
python_version: "3.8"
update_runtime: true
without_buildah: false
- container_runtime: "docker"
python_version: "3.9"
update_runtime: true
without_buildah: false
- container_runtime: "docker"
python_version: "3.10"
update_runtime: true
without_buildah: false
os_version: "ubuntu-22.04"
- container_runtime: "docker"
python_version: "3.11"
update_runtime: true
without_buildah: false
- container_runtime: "docker"
python_version: "3.12"
update_runtime: true
without_buildah: false
- container_runtime: "docker"
python_version: "3.13"
update_runtime: true
python_version: "3.7"
without_buildah: false
os_version: "ubuntu-22.04"

include:
# also test without buildah, but only on the latest python
- python_version: "3.13"
container_runtime: "podman"
update_runtime: true
without_buildah: true
- python_version: "3.13"
os_version: "ubuntu-latest"

# and test python3.6 on ubuntu 20.04
- python_version: "3.6"
container_runtime: "podman"
update_runtime: false
without_buildah: true
without_buildah: false
os_version: "ubuntu-20.04"
- python_version: "3.6"
container_runtime: "docker"
without_buildah: false
os_version: "ubuntu-20.04"

steps:
- uses: actions/checkout@v4
Expand All @@ -160,24 +72,10 @@ jobs:

- uses: actions/cache@v4
with:
path: ~/.nox
key: nox-${{ matrix.python_version }}-${{ hashFiles('poetry.lock') }}

- run: pip install --upgrade nox poetry nox-poetry
path: ~/.tox
key: tox-${{ hashFiles('tox.ini') }}-${{ hashFiles('setup.cfg') }}-${{ hashFiles('test-requirements.txt') }}

- name: update the container runtime
if: ${{ matrix.update_runtime }}
run: |
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_$(lsb_release -rs)/Release.key \
| gpg --dearmor \
| sudo tee /etc/apt/keyrings/devel_kubic_libcontainers_unstable.gpg > /dev/null
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/devel_kubic_libcontainers_unstable.gpg]\
https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_$(lsb_release -rs)/ /" \
| sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:unstable.list > /dev/null
sudo apt-get update -qq
sudo apt-get -qq -y install podman buildah
- run: pip install tox

- name: remove buildah
if: ${{ matrix.without_buildah }}
Expand All @@ -194,15 +92,20 @@ jobs:
chmod 1777 ./tmp
export TMPDIR="$(pwd)/tmp"
export PULL_ALWAYS=0
nox -s "test-${{ matrix.python_version }}(${{ matrix.container_runtime }})" -- -x -n auto --reruns 3 --pytest-container-log-level DEBUG
export CONTAINER_RUNTIME=${{ matrix.container_runtime }}
export TOXPYTHON=$pythonLocation
tox -e py$(echo $PY_VER | tr -d . ) -- -x -n auto --reruns 3
export PULL_ALWAYS=1
nox -s "test-${{ matrix.python_version }}(${{ matrix.container_runtime }})" -- -x -n auto --reruns 3 --pytest-container-log-level DEBUG
nox -s "test-${{ matrix.python_version }}(${{ matrix.container_runtime }})" -- -x --reruns 3 --pytest-container-log-level DEBUG
nox -s coverage
tox -e py$(echo $PY_VER | tr -d . ) -- -x -n auto --reruns 3 --pytest-container-log-level DEBUG
tox -e py$(echo $PY_VER | tr -d . ) -- -x --reruns 3 --pytest-container-log-level DEBUG
unset TOXPYTHON
tox -e coverage
env:
PY_VER: ${{ matrix.python_version }}

- name: verify that no stray containers are left
run: |
[[ $(podman ps -aq|wc -l) = '0' ]] || (podman ps -aq|xargs podman inspect; exit 1)
[[ $(${{ matrix.container_runtime }} ps -aq|wc -l) = '0' ]] || (${{ matrix.container_runtime }} ps -aq|xargs ${{ matrix.container_runtime }} inspect; exit 1)

- name: verify that no stray volumes are left
run: |
Expand All @@ -222,16 +125,12 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- uses: actions/cache@v4
with:
path: ~/.cache/pypoetry/virtualenvs
key: poetry-${{ hashFiles('poetry.lock') }}

- name: install setuptools
run: pip install setuptools

- name: Run the build
run: |
pipx install poetry
poetry install
poetry build
run: python setup.py sdist bdist_wheel

- uses: actions/upload-artifact@v4
with:
Expand All @@ -247,8 +146,10 @@ jobs:
fail-fast: false
matrix:
os_version: ["ubuntu-latest"]
python_version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
python_version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
include:
- os_version: "ubuntu-22.04"
python_version: "3.7"
- os_version: "ubuntu-20.04"
python_version: "3.6"

Expand Down Expand Up @@ -279,12 +180,12 @@ jobs:
python-version: '3.x'
- uses: actions/cache@v4
with:
path: ~/.nox
key: nox-${{ hashFiles('poetry.lock') }}
path: ~/.tox
key: tox-${{ hashFiles('tox.ini') }}-${{ hashFiles('setup.cfg') }}-${{ hashFiles('test-requirements.txt') }}

- run: pip install --upgrade nox poetry nox-poetry
- run: pip install tox

- run: nox -s doc
- run: tox -e doc

- name: upload the build directory
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -321,22 +222,18 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
# FIXME: temporary fix to python 3.11 to avoid a:
# AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'?
# when launching pylint with python 3.12
python-version: '3.11'

python-version: "3.x"
- uses: actions/cache@v4
with:
path: ~/.nox
key: nox-${{ hashFiles('poetry.lock') }}
path: ~/.tox
key: tox-${{ hashFiles('tox.ini') }}-${{ hashFiles('setup.cfg') }}-${{ hashFiles('test-requirements.txt') }}

- run: pip install --upgrade nox poetry nox-poetry
- run: pip install tox

# grab the previously built wheel for checking with twine
- uses: actions/download-artifact@v4
with:
name: wheel
path: dist

- run: nox -s lint
- run: tox -e lint
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ jobs:
with:
python-version: "3.x"

- name: install setuptools
run: pip install setuptools

- name: Install dependencies & build wheel
run: |
pipx install poetry
poetry install
poetry build
run: python setup.py sdist bdist_wheel

- name: Check the wheel
run: |
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ Next Release

Breaking changes:

- Remove intermediate dataclass ``runtime._OciRuntimeBase`` (`gh#238
<https://github.com/dcermak/pytest_container/pull/238>`_)

- :py:class:`~pytest_container.runtime.PodmanRuntime` and
:py:class:`~pytest_container.runtime.DockerRuntime` now raise exceptions if
the runtime is not functional (`gh#238
<https://github.com/dcermak/pytest_container/pull/238>`_)

Improvements and new features:

Expand All @@ -12,6 +19,8 @@ Documentation:

Internal changes:

- Drop poetry as the build system and fallback to setuptools


0.4.3 (December 4 2024)
-----------------------
Expand Down
14 changes: 7 additions & 7 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ Contributing
You will need the following tools to start contributing code:

- Python 3.6 or later
- `poetry <https://python-poetry.org/>`_
- `nox <https://nox.thea.codes/en/stable/index.html>`_
- `nox-poetry <https://nox-poetry.readthedocs.io/>`_
- `tox <https://pypi.org/project/tox/>`_
- `podman <https://podman.io/>`_ or `docker <https://docs.docker.com/engine/>`_

Before submitting your changes, please ensure that:

- your code is properly formatted via :command:`nox -s format`
- it passes the test suite (:command:`nox -s test`)
- the documentation can be build (:command:`nox -s doc`)
- it passes the mypy and pylint checks (:command:`nox -s lint`)
- your code is properly formatted via :command:`tox -e format`
- it passes the test suite (:command:`tox -e py312`, or any other python
version)
- the documentation can be build (:command:`tox -e doc`)
- it passes the mypy, pylint, twine and ruff checks (:command:`tox -e lint`)
14 changes: 14 additions & 0 deletions format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

set -o pipefail

if [ "$1" = "--check" ]; then
ruff format --check --diff
format_ret=$?

ruff check --diff
exit $([ $? -eq 0 ] && [ $format_ret -eq 0 ])
else
ruff format
ruff check --fix
fi
Loading
Loading