Skip to content

Commit

Permalink
Make jenkins/runlocal platform independent (#3474)
Browse files Browse the repository at this point in the history
Also, make containerbuild support ubi9 variants
  • Loading branch information
webbnh committed Jul 3, 2023
1 parent 3b8bf2f commit 8d54280
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 29 deletions.
46 changes: 18 additions & 28 deletions jenkins/runlocal
@@ -1,52 +1,42 @@
#!/bin/bash -e

#
# Build the Pbench Server RPM and container, and run functional tests locally.
# Requires a Fedora, CentOS, or RHEL environment to run.

#
# NOTE WELL: By default, when the functional tests are run, the infrastructure
# pod and Pbench Server container are left running by default. Add the switch,
# `--cleanup` to direct `jenkins/run-server-func-tests` to cleanup when
# finished (success or failure).
#
# Also NOTE: This relies on the incremental build capabilities of Make -- if
# you wish to build from source you should first issue the following commands:
#
# WORKSPACE_TMP=${WORKSPACE_TMP:-${HOME}} jenkins/run make -C server/rpm distclean
# WORKSPACE_TMP=${WORKSPACE_TMP:-${HOME}} jenkins/run make -C dashboard clean
#

# Build the pbench-server RPM locally, then build the containers locally, and
# then run the functional tests against the locally built CI container image.
export PB_SERVER_IMAGE_NAME=pbench-server

# We use the current user name as the tag to avoid any conflict with what the CI
# environment does.
export PB_CONTAINER_REG=images.paas.redhat.com/pbench
export PB_SERVER_IMAGE_TAG=${USER}

# We use the image pull policy of `never` here to ensure our locally built image
# is used by the pod.
export PB_SERVER_IMAGE_PULL_POLICY=never

# Create an RPM from the current source tree and double check it exists.
make -C server/rpm clean rpm
export RPM_PATH=${HOME}/rpmbuild/RPMS/noarch/pbench-server-*.rpm
# Set the workspace to the home directory so that the RPM built inside the
# container will be available after it exits.
export WORKSPACE_TMP=${WORKSPACE_TMP:-${HOME}}
jenkins/run make -C server/rpm ci
export RPM_PATH=${WORKSPACE_TMP}/rpmbuild/RPMS/noarch/'pbench-server-*.rpm'
# _Don't_ quote the expansion of ${RPM_PATH}: we _want_ it to be globbed!
# shellcheck disable=SC2086
ls -ld ${RPM_PATH}

# Create a Pbench Dashboard deployment
WORKSPACE_TMP=${WORKSPACE_TMP:-${HOME}} jenkins/run make -C dashboard clean build

source /etc/os-release

if [[ -z ${BASE_IMAGE} ]]; then
major=${VERSION_ID%%.*}
if [[ ${ID} == "fedora" ]]; then
# Any Fedora is okay.
BASE_IMAGE=${ID}:${major}
elif [[ ${ID} == "centos" && "${major}" == "9" ]]; then
# Only CentOS 9 is supported
BASE_IMAGE=${ID}:stream${major}
elif [[ ${ID} == "rhel" && "${major}" == "9" ]]; then
# Only RHEL 9 is supported
BASE_IMAGE=ubi${major}:latest
else
echo "Unsupported local OS, ${ID}:${VERSION_ID}" >&2
exit 1
fi
export BASE_IMAGE
fi
jenkins/run make -C dashboard build

# Build the canned Pbench Server container from the RPM built above.
server/pbenchinacan/container-build.sh
Expand Down
2 changes: 1 addition & 1 deletion server/pbenchinacan/container-build.sh
Expand Up @@ -50,7 +50,7 @@ buildah config \

buildah copy $container ${RPM_PATH} /tmp/pbench-server.rpm
buildah run $container dnf update -y
if [[ "${BASE_IMAGE}" == *"ubi9:latest" || "${BASE_IMAGE}" == *"centos:stream9" ]]; then
if [[ "${BASE_IMAGE}" == *"ubi9:"* || "${BASE_IMAGE}" == *"centos:stream9" ]]; then
buildah run $container dnf install -y --nodocs \
https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
fi
Expand Down

0 comments on commit 8d54280

Please sign in to comment.