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

CI: use sudo, assume docker present, use diff-{quality,cover}, bump EL 7 test to EL 8 as EL 7 is EOL #314

Merged
merged 2 commits into from
Aug 22, 2024
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
10 changes: 10 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[run]
branch = true
source_pkgs =
oz

[paths]
# this mapping is for the containers; the source tree is in /oz in the containers
source =
oz/
/oz/oz
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[flake8]
max-line-length = 200
40 changes: 20 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,31 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install make and docker
run: apt-get install make docker docker.io
- name: Install required packages
run: sudo apt-get install make flake8 pylint
# it's not in Ubuntu 22.04, was added in 23.04
- name: Install diff-cover from pip
run: pip install diff-cover
- name: Run the tests
run: make container-unittests-fedora
unittests-el7:
run: sudo make container-unittests-fedora
- name: Run diff-cover
run: diff-cover coverage.xml --compare-branch=origin/$GITHUB_BASE_REF --fail-under=90
- name: Run diff-quality (pylint)
# we want to run this regardless of whether previous lint steps failed
if: success() || failure()
run: diff-quality --compare-branch=origin/$GITHUB_BASE_REF --violations=pylint --fail-under=90
- name: Run diff-quality (flake8)
# we want to run this regardless of whether previous lint steps failed
if: success() || failure()
run: diff-quality --compare-branch=origin/$GITHUB_BASE_REF --violations=flake8 --fail-under=90
unittests-el8:
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install make and docker
run: apt-get install make docker
- name: Install make
run: sudo apt-get install make
- name: Run the tests
run: make container-unittests-el7
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install make, pylint and flake8
run: apt-get install make pylint flake8
- name: Run pylint
run: make pylint
- name: Run flake8
run: make flake8
run: sudo make container-unittests-el8
25 changes: 25 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[MESSAGES CONTROL]
disable=C0325,C0103

[REPORTS]
reports=yes

[TYPECHECK]

[FORMAT]
max-line-length=200
max-module-lines=2000

[VARIABLES]
dummy-variables-rgx=.*_unused$

[BASIC]
module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9_]+))$

[DESIGN]
max-args=20
max-locals=30
max-branches=30
max-statements=100
max-attributes=30
min-public-methods=0
16 changes: 0 additions & 16 deletions Containerfile.tests.el7

This file was deleted.

18 changes: 18 additions & 0 deletions Containerfile.tests.el8
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# this container definition is intended *only* for running the oz test suite, it is not
# a general-purpose oz container definition!

FROM quay.io/almalinuxorg/8-base:latest
RUN set -exo pipefail \
&& dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm \
&& dnf install -y --setopt install_weak_deps=false --nodocs \
python3-requests python3-cryptography python3-setuptools python3-libvirt python3-lxml python3-libguestfs python3-pytest python3-coverage python3-monotonic \
libvirt-daemon libvirt-daemon-kvm libvirt-daemon-driver-qemu libvirt-daemon-config-network systemd \
&& dnf clean all \
&& rm -rf /var/cache/* /var/log/dnf*

COPY ./ /oz
# the XML generation tests are inherently unreliable before Python 3.8,
# as there was no consistent ordering of XML element attributes. See
# https://docs.python.org/3/library/xml.etree.elementtree.html#xml.etree.ElementTree.tostring
RUN printf "#!/bin/sh\n/usr/sbin/libvirtd -d\ncd /oz\npython3 -m pytest -vv -k 'not test_xml_generation and not modify_libvirt_xml_for_serial' tests/" > /usr/local/bin/runtests.sh && chmod ugo+x /usr/local/bin/runtests.sh
CMD /usr/local/bin/runtests.sh
4 changes: 2 additions & 2 deletions Containerfile.tests.fedora
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
FROM quay.io/fedora/fedora:latest
RUN set -exo pipefail \
&& dnf install -y --setopt install_weak_deps=false --nodocs \
python3-requests python3-cryptography python3-setuptools python3-libvirt python3-lxml python3-libguestfs python3-pytest python3-monotonic \
python3-requests python3-cryptography python3-setuptools python3-libvirt python3-lxml python3-libguestfs python3-pytest python3-coverage python3-monotonic \
libvirt-daemon libvirt-daemon-kvm libvirt-daemon-qemu libvirt-daemon-config-network systemd \
&& dnf clean all \
&& rm -rf /var/cache/* /var/log/dnf*

COPY ./ /oz
RUN printf "#!/bin/sh\n/usr/sbin/libvirtd -d\ncd /oz\npy.test -vv tests/" > /usr/local/bin/runtests.sh && chmod ugo+x /usr/local/bin/runtests.sh
RUN printf "#!/bin/sh\n/usr/sbin/libvirtd -d\ncd /oz\npython3 -m coverage run -m pytest -vv tests/\ncoverage xml\ncoverage report" > /usr/local/bin/runtests.sh && chmod ugo+x /usr/local/bin/runtests.sh
CMD /usr/local/bin/runtests.sh
21 changes: 11 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,31 +50,32 @@ container-unittests-fedora:
docker rm -f oz-tests-fedora
docker build -f Containerfile.tests.fedora -t oz-tests-fedora-image .
docker run --name oz-tests-fedora oz-tests-fedora-image
docker cp oz-tests-fedora:/oz/coverage.xml .

container-unittests-el7:
docker rm -f oz-tests-el7
docker build -f Containerfile.tests.el7 -t oz-tests-el7-image .
docker run --name oz-tests-el7 oz-tests-el7-image
container-unittests-el8:
docker rm -f oz-tests-el8
docker build -f Containerfile.tests.el8 -t oz-tests-el8-image .
docker run --name oz-tests-el8 oz-tests-el8-image

container-unittests: container-unittests-fedora container-unittests-el7
container-unittests: container-unittests-fedora container-unittests-el8

test-coverage:
python-coverage run --source oz /usr/bin/py.test --verbose tests
python-coverage html
xdg-open htmlcov/index.html

pylint:
pylint --rcfile=pylint.conf oz oz-install oz-customize oz-cleanup-cache oz-generate-icicle
pylint oz oz-install oz-customize oz-cleanup-cache oz-generate-icicle

flake8:
flake8 --ignore=E501 oz
flake8 oz oz-install oz-customize oz-cleanup-cache oz-generate-icicle

container-clean:
docker rm -f oz-tests-fedora
docker rm -f oz-tests-el7
docker image rm -f -i oz-tests-fedora-image oz-tests-el7-image
docker rm -f oz-tests-el8
docker image rm -f -i oz-tests-fedora-image oz-tests-el8-image

clean:
rm -rf MANIFEST build dist usr *~ oz.spec *.pyc oz/*~ oz/*.pyc examples/*~ oz/auto/*~ man/*~ docs/*~ man/*.html $(VENV_DIR) tests/tdl/*~ tests/factory/*~ tests/results.xml htmlcov

.PHONY: sdist oz.spec signed-tarball signed-rpm rpm srpm deb release man2html virtualenv unittests container-unittests-fedora container-unittests-el7 container-unittests tests test-coverage pylint clean container-clean
.PHONY: sdist oz.spec signed-tarball signed-rpm rpm srpm deb release man2html virtualenv unittests container-unittests-fedora container-unittests-el8 container-unittests tests test-coverage pylint clean container-clean
Loading