Skip to content

Commit

Permalink
Make it easy to use different versions of Fedora for static checks
Browse files Browse the repository at this point in the history
Fedora 33 is the last Fedora version that works on RHEL 7 (see
https://bugzilla.redhat.com/show_bug.cgi?id=1962080 for details),
but if people have newer container runtimes, they can use Fedora
34, 35 or whatever future brings. Let's just make that easy.
  • Loading branch information
vpodzime committed Nov 25, 2021
1 parent befec31 commit 028f425
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
3 changes: 3 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ destroy-vms:
static-check:
tests/static-check/run.sh

static-check-f%:
STATIC_CHECKS_FEDORA_VERSION=$* tests/static-check/run.sh

#
# Get everything removed down to where rebuilding requires:
# "make; make install"
Expand Down
20 changes: 15 additions & 5 deletions tests/static-check/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,31 @@
set -e
trap "echo FAILURE" ERR

set -x
BASE_IMG="fedora:33"
if [ -z "$STATIC_CHECKS_FEDORA_VERSION" ]; then
# Fedora 33 is the default because it works with old container runtimes
# (see https://bugzilla.redhat.com/show_bug.cgi?id=1962080 and linked bugs for
# details)
echo "No Fedora version for static checks specified, using the default (Fedora 33)"
BASE_IMG="fedora:33"
STATIC_CHECKS_FEDORA_VERSION="33"
else
BASE_IMG="fedora:$STATIC_CHECKS_FEDORA_VERSION"
fi

function create_image() {
local c=$(buildah from -q $BASE_IMG)
buildah run $c -- dnf -q -y install "@C Development Tools and Libraries" clang cppcheck which >/dev/null 2>&1
buildah run $c -- dnf -q -y install pcre-devel openssl-devel libxml2-devel pam-devel lmdb-devel libacl-devel libyaml-devel curl-devel libvirt-devel >/dev/null 2>&1
buildah run $c -- dnf clean all >/dev/null 2>&1
buildah commit $c cfengine-static-checker >/dev/null 2>&1
buildah commit $c cfengine-static-checker-f$STATIC_CHECKS_FEDORA_VERSION >/dev/null 2>&1
echo $c
}

set -x

# TODO: check how old the image is and recreate if it's too old
if buildah inspect cfengine-static-checker >/dev/null 2>&1; then
c=$(buildah from cfengine-static-checker)
if buildah inspect cfengine-static-checker-f$STATIC_CHECKS_FEDORA_VERSION >/dev/null 2>&1; then
c=$(buildah from cfengine-static-checker-f$STATIC_CHECKS_FEDORA_VERSION)
else
c=$(create_image)
fi
Expand Down

0 comments on commit 028f425

Please sign in to comment.