Skip to content

Commit

Permalink
Add RHEL9 container for building and testing
Browse files Browse the repository at this point in the history
Adding RHEL 9 containers so we can start to test & build packages
in RHEL 9 environemnt.

Since `python3-virtualenv` package is not available in the RHEL 9 UBI,
a workaround is introduced `make install-deps-fedora`, which is used by
the testing containers. If not able to install the package, `pip install
virtualenv` is used as a fallback as this is working in the image.

The relatively recent Python version used in the container means there
is also a relative recent Pylint verision, which introduces 2+ new
checks.
  • Loading branch information
matejmatuska authored and Rezney committed Jul 18, 2024
1 parent 8701243 commit 953bfb1
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 8 deletions.
31 changes: 23 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ help:
@echo " packaging"
@echo " srpm create the SRPM"
@echo " build_container create the RPM in container"
@echo " - set BUILD_CONTAINER to el7 or el8"
@echo " - set BUILD_CONTAINER to el7, el8 or el9"
@echo " - don't run more than one build at the same time"
@echo " since containers operate on the same files!"
@echo " copr_build create the COPR build using the COPR TOKEN"
Expand Down Expand Up @@ -164,7 +164,7 @@ help:
@echo " PR=7 SUFFIX='my_additional_suffix' make <target>"
@echo " MR=6 COPR_CONFIG='path/to/the/config/copr/file' make <target>"
@echo " ACTOR=<actor> TEST_LIBS=y make test"
@echo " BUILD_CONTAINER=rhel7 make build_container"
@echo " BUILD_CONTAINER=el7 make build_container"
@echo " TEST_CONTAINER=f34 make test_container"
@echo " CONTAINER_TOOL=docker TEST_CONTAINER=rhel7 make test_container_no_lint"
@echo ""
Expand Down Expand Up @@ -258,12 +258,15 @@ build_container:
el8) \
CONT_FILE="utils/container-builds/Containerfile.ubi8"; \
;; \
el9) \
CONT_FILE="utils/container-builds/Containerfile.ubi9"; \
;; \
"") \
echo "BUILD_CONTAINER must be set"; \
exit 1; \
;; \
*) \
echo "Available containers are el7, el8"; \
echo "Available containers are el7, el8, el9"; \
exit 1; \
;; \
esac && \
Expand Down Expand Up @@ -305,12 +308,20 @@ install-deps:
$(VENVNAME)/bin/pip install -I "git+https://github.com/oamg/leapp.git@refs/pull/$(REQ_LEAPP_PR)/head"; \
fi
$(_PYTHON_VENV) utils/install_actor_deps.py --actor=$(ACTOR) --repos="$(TEST_PATHS)"
install-deps-fedora:
@# Check the necessary rpms are installed for py3 (and py2 below)
if ! rpm -q git findutils python3-virtualenv gcc; then \
if ! dnf install -y git findutils python3-virtualenv gcc; then \
if ! rpm -q git findutils gcc; then \
if ! dnf install -y git findutils gcc; then \
echo 'Please install the following rpms via the command: ' \
'sudo dnf install -y git findutils python3-virtualenv gcc'; \
'sudo dnf install -y git findutils gcc'; \
exit 1; \
fi; \
fi
if ! command -v virtualenv; then \
if ! (dnf install -y python3-virtualenv || pip install virtualenv); then \
echo 'Please install the following packages via the command: ' \
'sudo dnf install -y python3-virtualenv or pip install virtualenv'; \
exit 1; \
fi; \
fi
Expand Down Expand Up @@ -432,6 +443,10 @@ test_container:
export CONT_FILE="utils/container-tests/Containerfile.rhel8"; \
export _VENV="python3.6"; \
;; \
rhel9) \
export CONT_FILE="utils/container-tests/Containerfile.rhel9"; \
export _VENV="python3.9"; \
;; \
*) \
echo "Error: Available containers are: f34, rhel7, rhel8"; exit 1; \
;; \
Expand Down Expand Up @@ -481,7 +496,7 @@ test_container_all_no_lint:
# clean all testing and building containers and their images
clean_containers:
@for i in "leapp-repo-tests-f34" "leapp-repo-tests-rhel7" "leapp-repo-tests-rhel8" \
"leapp-repo-build-el7" "leapp-repo-build-el8"; do \
"leapp-repo-tests-rhel9" "leapp-repo-build-el7" "leapp-repo-build-el8"; do \
$(_CONTAINER_TOOL) kill "$$i-cont" || :; \
$(_CONTAINER_TOOL) rm "$$i-cont" || :; \
$(_CONTAINER_TOOL) rmi "$$i" || :; \
Expand All @@ -492,7 +507,7 @@ fast_lint:
FILES_TO_LINT="$$(git diff --name-only $(MASTER_BRANCH) --diff-filter AMR | grep '\.py$$')"; \
if [[ -n "$$FILES_TO_LINT" ]]; then \
pylint -j 0 $$FILES_TO_LINT $(PYLINT_ARGS) && \
flake8 $$FILES_TO_LINT $(FLAKE8_ARG); \
flake8 $$FILES_TO_LINT $(FLAKE8_ARGS); \
LINT_EXIT_CODE="$$?"; \
if [[ "$$LINT_EXIT_CODE" != "0" ]]; then \
exit $$LINT_EXIT_CODE; \
Expand Down
10 changes: 10 additions & 0 deletions utils/container-builds/Containerfile.ubi9
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM registry.access.redhat.com/ubi9/ubi:latest

VOLUME /repo

RUN dnf update -y && \
dnf install -y python3-devel rpm-build make git

WORKDIR /repo
ENV DIST_VERSION 9
ENTRYPOINT make _build_local
18 changes: 18 additions & 0 deletions utils/container-tests/Containerfile.rhel9
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM registry.access.redhat.com/ubi9/ubi:latest

VOLUME /repo

RUN dnf update -y && \
dnf install -y python3-setuptools python3-pip make git rsync

ENV PYTHON_VENV python3.9

COPY . /repocopy

WORKDIR /repocopy

RUN rm -rf tut*

RUN make clean && make install-deps-fedora

WORKDIR /

0 comments on commit 953bfb1

Please sign in to comment.