Skip to content

Commit

Permalink
Update CI to fail on Podman 4.0 errors
Browse files Browse the repository at this point in the history
CI has been testing against containers/podman/main to report issues.
With the release of Podman 4.0, any errors are now failures.

* Makefile target "test" and "lint" updated to use tox covering
  python 3.6, 3.8, 3.9 and 3.10.
* Added black formatting check to Makefile target "lint"
* Source code changes made to satisfy "tox -e black-format" and
  "tox -e pylint"

Signed-off-by: Jhon Honce <[email protected]>
  • Loading branch information
jwhonce authored and cdoern committed Oct 6, 2022
1 parent d5baf8a commit ff0a8a9
Show file tree
Hide file tree
Showing 36 changed files with 353 additions and 463 deletions.
1 change: 1 addition & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ test_task:

script:
- ${SCRIPT_BASE}/enable_ssh.sh
- ${SCRIPT_BASE}/build_podman.sh
- ${SCRIPT_BASE}/enable_podman.sh
- ${SCRIPT_BASE}/test.sh

Expand Down
4 changes: 3 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ ignore=CVS,docs

# Add files or directories matching the regex patterns to the blacklist. The
# regex matches against base names, not paths.
ignore-patterns=test_.*
# ignore-patterns=test_.*

ignore-paths=^podman/tests/.*$

# Python code to execute, usually for sys.path manipulation such as
# pygtk.require().
Expand Down
22 changes: 13 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,23 @@ DESTDIR ?=
EPOCH_TEST_COMMIT ?= $(shell git merge-base $${DEST_BRANCH:-main} HEAD)
HEAD ?= HEAD

export PODMAN_VERSION ?= "3.2.0"
export PODMAN_VERSION ?= "4.0.0"

.PHONY: podman
podman:
rm dist/* || :
python -m pip install --user -r requirements.txt
$(PYTHON) -m pip install --user -r requirements.txt
PODMAN_VERSION=$(PODMAN_VERSION) \
$(PYTHON) setup.py sdist bdist bdist_wheel

.PHONY: lint
lint:
$(PYTHON) -m pylint podman || exit $$(($$? % 4));
lint: tox
$(PYTHON) -m tox -e black,pylint

.PHONY: tests
tests:
python -m pip install --user -r test-requirements.txt
DEBUG=1 coverage run -m unittest discover -s podman/tests
coverage report -m --skip-covered --fail-under=80 --omit=./podman/tests/* --omit=.tox/* \
--omit=/usr/lib/* --omit=*/lib/python*
tests: tox
# see tox.ini for environment variable settings
$(PYTHON) -m tox -e pylint,coverage,py36,py38,py39,py310

.PHONY: unittest
unittest:
Expand All @@ -38,6 +36,12 @@ integration:
coverage run -m unittest discover -s podman/tests/integration
coverage report -m --skip-covered --fail-under=80 --omit=./podman/tests/* --omit=.tox/* --omit=/usr/lib/*

.PHONY: tox
tox:
-dnf install -y python3 python3.6 python3.8 python3.9
# ensure tox is available. It will take care of other testing requirements
$(PYTHON) -m pip install --user tox

.PHONY: test-release
test-release: SOURCE = $(shell find dist -regex '.*/podman-[0-9][0-9\.]*.tar.gz' -print)
test-release:
Expand Down
10 changes: 3 additions & 7 deletions contrib/cirrus/build_podman.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@

set -xeo pipefail

mkdir -p "$GOPATH/src/github.com/containers/"
cd "$GOPATH/src/github.com/containers/"
systemctl stop podman.socket || :

systemctl stop podman.socket ||:
dnf erase podman -y
git clone https://github.com/containers/podman.git
dnf copr enable rhcontainerbot/podman-next -y
dnf install podman -y

cd podman
make binaries
make install PREFIX=/usr
2 changes: 0 additions & 2 deletions contrib/cirrus/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

set -eo pipefail



make tests
7 changes: 3 additions & 4 deletions podman/api/tar_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def add_filter(info: tarfile.TarInfo) -> Optional[tarfile.TarInfo]:
return None

# Workaround https://bugs.python.org/issue32713. Fixed in Python 3.7
if info.mtime < 0 or info.mtime > 8 ** 11 - 1:
if info.mtime < 0 or info.mtime > 8**11 - 1:
info.mtime = int(info.mtime)

# do not leak client information to service
Expand All @@ -97,9 +97,8 @@ def add_filter(info: tarfile.TarInfo) -> Optional[tarfile.TarInfo]:
return info

if name is None:
name = tempfile.NamedTemporaryFile(
prefix="podman_context", suffix=".tar"
) # pylint: disable=consider-using-with
# pylint: disable=consider-using-with
name = tempfile.NamedTemporaryFile(prefix="podman_context", suffix=".tar")
else:
name = pathlib.Path(name)

Expand Down
18 changes: 2 additions & 16 deletions podman/api/typing_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,6 @@ def __new__(cls, *args, **kwds):
return collections.deque(*args, **kwds)
return _generic_new(collections.deque, cls, *args, **kwds)


else:

class Deque(
Expand Down Expand Up @@ -912,7 +911,6 @@ class ContextManager(
):
__slots__ = ()


else:

class ContextManager(typing.Generic[T_co]):
Expand Down Expand Up @@ -994,7 +992,6 @@ def __new__(cls, *args, **kwds):
return collections.defaultdict(*args, **kwds)
return _generic_new(collections.defaultdict, cls, *args, **kwds)


else:

class DefaultDict(
Expand Down Expand Up @@ -1032,7 +1029,6 @@ def __new__(cls, *args, **kwds):
return collections.OrderedDict(*args, **kwds)
return _generic_new(collections.OrderedDict, cls, *args, **kwds)


else:

class OrderedDict(
Expand Down Expand Up @@ -1073,7 +1069,6 @@ def __new__(cls, *args, **kwds):
return collections.Counter(*args, **kwds)
return _generic_new(collections.Counter, cls, *args, **kwds)


elif _geqv_defined:

class Counter(
Expand All @@ -1090,7 +1085,6 @@ def __new__(cls, *args, **kwds):
return collections.Counter(*args, **kwds)
return _generic_new(collections.Counter, cls, *args, **kwds)


else:

class Counter(
Expand Down Expand Up @@ -1353,9 +1347,7 @@ def __new__(
bases = tuple(b for b in bases if b is not Generic)
namespace.update({'__origin__': origin, '__extra__': extra})
self = super(GenericMeta, cls).__new__(cls, name, bases, namespace, _root=True)
super(GenericMeta, self).__setattr__(
'_gorg', self if not origin else _gorg(origin)
)
super(GenericMeta, self).__setattr__('_gorg', self if not origin else _gorg(origin))
self.__parameters__ = tvars
self.__args__ = (
tuple(
Expand Down Expand Up @@ -1479,9 +1471,7 @@ def __getitem__(self, params):
if not isinstance(params, tuple):
params = (params,)
if not params and _gorg(self) is not Tuple:
raise TypeError(
"Parameter list to %s[...] cannot be empty" % self.__qualname__
)
raise TypeError("Parameter list to %s[...] cannot be empty" % self.__qualname__)
msg = "Parameters to generic types must be types."
params = tuple(_type_check(p, msg) for p in params)
if self in (Generic, Protocol):
Expand Down Expand Up @@ -2108,7 +2098,6 @@ def get_type_hints(obj, globalns=None, localns=None, include_extras=False):
return hint
return {k: _strip_annotations(t) for k, t in hint.items()}


elif HAVE_ANNOTATED:

def _is_dunder(name):
Expand Down Expand Up @@ -2344,7 +2333,6 @@ def TypeAlias(self, parameters):
"""
raise TypeError("{} is not subscriptable".format(self))


elif sys.version_info[:2] >= (3, 7):

class _TypeAliasForm(typing._SpecialForm, _root=True):
Expand Down Expand Up @@ -2672,7 +2660,6 @@ def Concatenate(self, parameters):
"""
return _concatenate_getitem(self, parameters)


elif sys.version_info[:2] >= (3, 7):

class _ConcatenateForm(typing._SpecialForm, _root=True):
Expand Down Expand Up @@ -2821,7 +2808,6 @@ def is_str(val: Union[str, float]):
item = typing._type_check(parameters, '{} accepts only single type.'.format(self))
return _GenericAlias(self, (item,))


elif sys.version_info[:2] >= (3, 7):

class _TypeGuardForm(typing._SpecialForm, _root=True):
Expand Down
7 changes: 2 additions & 5 deletions podman/domain/containers_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,7 @@ def to_bytes(size: Union[int, str, None]) -> Union[int, None]:
if search:
return int(search.group(1)) * (1024 ** mapping[search.group(2)])
raise TypeError(
f"Passed string size {size} should be in format\\d+[bBkKmMgG] (e.g."
" '100m')"
f"Passed string size {size} should be in format\\d+[bBkKmMgG] (e.g. '100m')"
) from bad_size
else:
raise TypeError(
Expand Down Expand Up @@ -415,9 +414,7 @@ def to_bytes(size: Union[int, str, None]) -> Union[int, None]:
if "Config" in args["log_config"]:
params["log_configuration"]["path"] = args["log_config"]["Config"].get("path")
params["log_configuration"]["size"] = args["log_config"]["Config"].get("size")
params["log_configuration"]["options"] = args["log_config"]["Config"].get(
"options"
)
params["log_configuration"]["options"] = args["log_config"]["Config"].get("options")
args.pop("log_config")

for item in args.pop("mounts", []):
Expand Down
7 changes: 2 additions & 5 deletions podman/domain/containers_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ def exists(self, key: str) -> bool:
response = self.client.get(f"/containers/{key}/exists")
return response.ok

# pylint is flagging 'container_id' here vs. 'key' parameter in super.get()
def get(
self, container_id: str
) -> Container: # pylint: disable=arguments-differ,arguments-renamed
def get(self, key: str) -> Container:
"""Get container by name or id.
Args:
Expand All @@ -38,7 +35,7 @@ def get(
NotFound: when Container does not exist
APIError: when an error return by service
"""
container_id = urllib.parse.quote_plus(container_id)
container_id = urllib.parse.quote_plus(key)
response = self.client.get(f"/containers/{container_id}/json")
response.raise_for_status()
return self.prepare_model(attrs=response.json())
Expand Down
1 change: 1 addition & 0 deletions podman/domain/images_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def resource(self):
return Image

def exists(self, key: str) -> bool:
"""Return true when image exists."""
key = urllib.parse.quote_plus(key)
response = self.client.get(f"/images/{key}/exists")
return response.ok
Expand Down
Loading

0 comments on commit ff0a8a9

Please sign in to comment.