Skip to content
Snippets Groups Projects
Commit 8bcf9251 authored by Vaclav Sraier's avatar Vaclav Sraier
Browse files

manager packaging tests: added a test checking existance of dependencies

parent af75e074
No related branches found
No related tags found
1 merge request!1248manager: packaging
......@@ -5,9 +5,9 @@ stages:
# pkgbuild {{{
.pkgbuild: &pkgbuild
stage: pkgbuild
tags:
- lxc
- amd64
# tags:
# - lxc
# - amd64
before_script:
- git config --global user.name CI
- git config --global user.email ci@nic
......
{# Test that all packages are installed #}
Tests: dependencies.py
Tests-Directory: manager/tests/packaging/
{# Test that kresctl command exists and is in $PATH #}
Tests: kresctl.sh
Tests-Directory: manager/tests/packaging
......
# pylint: skip-file
# flake8: noqa
# throws nice syntax error on old Python versions:
0_0 # Python >= 3.6 required
......
#!/usr/bin/python3
import importlib
import importlib.util
import sys
from types import ModuleType
import pkg_resources
# replace imports with mocks
dummy = ModuleType("dummy")
dummy.__dict__["setup"] = lambda *args, **kwargs: None
dummy.__dict__["build"] = lambda *args, **kwargs: None
sys.modules["setuptools"] = dummy
sys.modules["build"] = dummy
# load install_requires array from setup.py
spec = importlib.util.spec_from_file_location("setup", "manager/setup.py")
mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mod)
install_requires = mod.install_requires
# stip version codes
deps = set((x[: x.index(">")].lower() for x in install_requires))
# find out which packages are missing
installed = {pkg.key for pkg in pkg_resources.working_set}
missing = deps - installed
# fail if there are some missing
if len(missing) > 0:
print(f"Some required packages are missing: {missing}", file=sys.stderr)
exit(1)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment