Skip to content

Commit f2ad218

Browse files
authored
Merge pull request #160 from jwhonce/wip/cleanup4
Update CI to fail on Podman 4.0 errors
2 parents c4609ab + e74bd87 commit f2ad218

36 files changed

+353
-463
lines changed

.cirrus.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ test_task:
6161

6262
script:
6363
- ${SCRIPT_BASE}/enable_ssh.sh
64+
- ${SCRIPT_BASE}/build_podman.sh
6465
- ${SCRIPT_BASE}/enable_podman.sh
6566
- ${SCRIPT_BASE}/test.sh
6667

.pylintrc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ ignore=CVS,docs
1111

1212
# Add files or directories matching the regex patterns to the blacklist. The
1313
# regex matches against base names, not paths.
14-
ignore-patterns=test_.*
14+
# ignore-patterns=test_.*
15+
16+
ignore-paths=^podman/tests/.*$
1517

1618
# Python code to execute, usually for sys.path manipulation such as
1719
# pygtk.require().

Makefile

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,23 @@ DESTDIR ?=
88
EPOCH_TEST_COMMIT ?= $(shell git merge-base $${DEST_BRANCH:-main} HEAD)
99
HEAD ?= HEAD
1010

11-
export PODMAN_VERSION ?= "3.2.0"
11+
export PODMAN_VERSION ?= "4.0.0"
1212

1313
.PHONY: podman
1414
podman:
1515
rm dist/* || :
16-
python -m pip install --user -r requirements.txt
16+
$(PYTHON) -m pip install --user -r requirements.txt
1717
PODMAN_VERSION=$(PODMAN_VERSION) \
1818
$(PYTHON) setup.py sdist bdist bdist_wheel
1919

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

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

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

39+
.PHONY: tox
40+
tox:
41+
-dnf install -y python3 python3.6 python3.8 python3.9
42+
# ensure tox is available. It will take care of other testing requirements
43+
$(PYTHON) -m pip install --user tox
44+
4145
.PHONY: test-release
4246
test-release: SOURCE = $(shell find dist -regex '.*/podman-[0-9][0-9\.]*.tar.gz' -print)
4347
test-release:

contrib/cirrus/build_podman.sh

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@
22

33
set -xeo pipefail
44

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

8-
systemctl stop podman.socket ||:
97
dnf erase podman -y
10-
git clone https://github.com/containers/podman.git
8+
dnf copr enable rhcontainerbot/podman-next -y
9+
dnf install podman -y
1110

12-
cd podman
13-
make binaries
14-
make install PREFIX=/usr

contrib/cirrus/test.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@
22

33
set -eo pipefail
44

5-
6-
75
make tests

podman/api/tar_utils.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def add_filter(info: tarfile.TarInfo) -> Optional[tarfile.TarInfo]:
8484
return None
8585

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

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

9999
if name is None:
100-
name = tempfile.NamedTemporaryFile(
101-
prefix="podman_context", suffix=".tar"
102-
) # pylint: disable=consider-using-with
100+
# pylint: disable=consider-using-with
101+
name = tempfile.NamedTemporaryFile(prefix="podman_context", suffix=".tar")
103102
else:
104103
name = pathlib.Path(name)
105104

podman/api/typing_extensions.py

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,6 @@ def __new__(cls, *args, **kwds):
884884
return collections.deque(*args, **kwds)
885885
return _generic_new(collections.deque, cls, *args, **kwds)
886886

887-
888887
else:
889888

890889
class Deque(
@@ -912,7 +911,6 @@ class ContextManager(
912911
):
913912
__slots__ = ()
914913

915-
916914
else:
917915

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

997-
998995
else:
999996

1000997
class DefaultDict(
@@ -1032,7 +1029,6 @@ def __new__(cls, *args, **kwds):
10321029
return collections.OrderedDict(*args, **kwds)
10331030
return _generic_new(collections.OrderedDict, cls, *args, **kwds)
10341031

1035-
10361032
else:
10371033

10381034
class OrderedDict(
@@ -1073,7 +1069,6 @@ def __new__(cls, *args, **kwds):
10731069
return collections.Counter(*args, **kwds)
10741070
return _generic_new(collections.Counter, cls, *args, **kwds)
10751071

1076-
10771072
elif _geqv_defined:
10781073

10791074
class Counter(
@@ -1090,7 +1085,6 @@ def __new__(cls, *args, **kwds):
10901085
return collections.Counter(*args, **kwds)
10911086
return _generic_new(collections.Counter, cls, *args, **kwds)
10921087

1093-
10941088
else:
10951089

10961090
class Counter(
@@ -1353,9 +1347,7 @@ def __new__(
13531347
bases = tuple(b for b in bases if b is not Generic)
13541348
namespace.update({'__origin__': origin, '__extra__': extra})
13551349
self = super(GenericMeta, cls).__new__(cls, name, bases, namespace, _root=True)
1356-
super(GenericMeta, self).__setattr__(
1357-
'_gorg', self if not origin else _gorg(origin)
1358-
)
1350+
super(GenericMeta, self).__setattr__('_gorg', self if not origin else _gorg(origin))
13591351
self.__parameters__ = tvars
13601352
self.__args__ = (
13611353
tuple(
@@ -1479,9 +1471,7 @@ def __getitem__(self, params):
14791471
if not isinstance(params, tuple):
14801472
params = (params,)
14811473
if not params and _gorg(self) is not Tuple:
1482-
raise TypeError(
1483-
"Parameter list to %s[...] cannot be empty" % self.__qualname__
1484-
)
1474+
raise TypeError("Parameter list to %s[...] cannot be empty" % self.__qualname__)
14851475
msg = "Parameters to generic types must be types."
14861476
params = tuple(_type_check(p, msg) for p in params)
14871477
if self in (Generic, Protocol):
@@ -2108,7 +2098,6 @@ def get_type_hints(obj, globalns=None, localns=None, include_extras=False):
21082098
return hint
21092099
return {k: _strip_annotations(t) for k, t in hint.items()}
21102100

2111-
21122101
elif HAVE_ANNOTATED:
21132102

21142103
def _is_dunder(name):
@@ -2344,7 +2333,6 @@ def TypeAlias(self, parameters):
23442333
"""
23452334
raise TypeError("{} is not subscriptable".format(self))
23462335

2347-
23482336
elif sys.version_info[:2] >= (3, 7):
23492337

23502338
class _TypeAliasForm(typing._SpecialForm, _root=True):
@@ -2672,7 +2660,6 @@ def Concatenate(self, parameters):
26722660
"""
26732661
return _concatenate_getitem(self, parameters)
26742662

2675-
26762663
elif sys.version_info[:2] >= (3, 7):
26772664

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

2824-
28252811
elif sys.version_info[:2] >= (3, 7):
28262812

28272813
class _TypeGuardForm(typing._SpecialForm, _root=True):

podman/domain/containers_create.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,7 @@ def to_bytes(size: Union[int, str, None]) -> Union[int, None]:
310310
if search:
311311
return int(search.group(1)) * (1024 ** mapping[search.group(2)])
312312
raise TypeError(
313-
f"Passed string size {size} should be in format\\d+[bBkKmMgG] (e.g."
314-
" '100m')"
313+
f"Passed string size {size} should be in format\\d+[bBkKmMgG] (e.g. '100m')"
315314
) from bad_size
316315
else:
317316
raise TypeError(
@@ -415,9 +414,7 @@ def to_bytes(size: Union[int, str, None]) -> Union[int, None]:
415414
if "Config" in args["log_config"]:
416415
params["log_configuration"]["path"] = args["log_config"]["Config"].get("path")
417416
params["log_configuration"]["size"] = args["log_config"]["Config"].get("size")
418-
params["log_configuration"]["options"] = args["log_config"]["Config"].get(
419-
"options"
420-
)
417+
params["log_configuration"]["options"] = args["log_config"]["Config"].get("options")
421418
args.pop("log_config")
422419

423420
for item in args.pop("mounts", []):

podman/domain/containers_manager.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@ def exists(self, key: str) -> bool:
2525
response = self.client.get(f"/containers/{key}/exists")
2626
return response.ok
2727

28-
# pylint is flagging 'container_id' here vs. 'key' parameter in super.get()
29-
def get(
30-
self, container_id: str
31-
) -> Container: # pylint: disable=arguments-differ,arguments-renamed
28+
def get(self, key: str) -> Container:
3229
"""Get container by name or id.
3330
3431
Args:
@@ -38,7 +35,7 @@ def get(
3835
NotFound: when Container does not exist
3936
APIError: when an error return by service
4037
"""
41-
container_id = urllib.parse.quote_plus(container_id)
38+
container_id = urllib.parse.quote_plus(key)
4239
response = self.client.get(f"/containers/{container_id}/json")
4340
response.raise_for_status()
4441
return self.prepare_model(attrs=response.json())

podman/domain/images_manager.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def resource(self):
2727
return Image
2828

2929
def exists(self, key: str) -> bool:
30+
"""Return true when image exists."""
3031
key = urllib.parse.quote_plus(key)
3132
response = self.client.get(f"/images/{key}/exists")
3233
return response.ok

0 commit comments

Comments
 (0)