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

feat(ci): Build container images without python deps #2572

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ COPY . .
RUN if [ -f "${BUILD_IMAGE_CUSTOMIZATION}" ]; then "${BUILD_IMAGE_CUSTOMIZATION}"; fi

RUN if [ -e "/activation-key/org" ]; then unlink /etc/rhsm-host; subscription-manager register --force --org $(cat "/activation-key/org") --activationkey $(cat "/activation-key/activationkey"); fi
RUN python3 -m ensurepip
ENV GO=${GO}
RUN make build-hiveutil

Expand All @@ -29,7 +28,6 @@ RUN if [ -f "${BUILD_IMAGE_CUSTOMIZATION}" ]; then "${BUILD_IMAGE_CUSTOMIZATION}

ENV SMDEV_CONTAINER_OFF=${CONTAINER_SUB_MANAGER_OFF}
RUN if [ -e "/activation-key/org" ]; then unlink /etc/rhsm-host; subscription-manager register --force --org $(cat "/activation-key/org") --activationkey $(cat "/activation-key/activationkey"); fi
RUN python3 -m ensurepip
ENV GO=${GO}
RUN make build-hiveadmission build-manager build-operator && \
make build-hiveutil
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ endif
# we don't tag versions. Override using the same versioning we apply to OperatorHub builds:
# v{major}.{minor}.{commitcount}-{sha}
# Note that building against a local commit may result in {major}.{minor} being rendered as
# `UnknownBranch`. However, the {commitcount} and {sha} should still be accurate.
SOURCE_GIT_TAG := $(shell export HOME=$(HOME); python3 -m ensurepip >&2; python3 -mpip --no-cache install --user gitpython pyyaml >&2; hack/version2.py)
# 0.0.x-y if it is an `UnknownBranch`. However, the {commitcount} and {sha}
# should still be accurate.
SOURCE_GIT_TAG := $(shell hack/version2.sh)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this. It was super annoying waiting for pip every time the Makefile loaded up.

However, this may have been the only thing ensuring that pyyaml was installed when running generate-saas-template.py. I'm going to look into porting that to bash/yq as well, but in the meantime, can we add the ensurepip and pyyaml business inside that rule? (At least then it will only run when that rule is invoked.)


BINDATA_INPUTS :=./config/sharded_controllers/... ./config/hiveadmission/... ./config/controllers/... ./config/rbac/... ./config/configmaps/...
$(call add-bindata,operator,$(BINDATA_INPUTS),,assets,pkg/operator/assets/bindata.go)
Expand Down
3 changes: 1 addition & 2 deletions hack/ubi-build-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
dnf install -y \
git \
golang \
make \
python3
make

# Since go 1.23.x is not available in ubi8, let's go upstream
go install golang.org/dl/go1.23.6@latest
Expand Down
25 changes: 25 additions & 0 deletions hack/version2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
declare -r UNKNOWN_BRANCH_PREFIX="0.0"
declare -r MASTER_BRANCH_PREFIX="1.2"

function prefix_from_branch() {
declare -r branch_name="$1"

if [[ "$branch_name" =~ ^([^/]+/)?mce-([[:digit:]]+.[[:digit:]]+) ]]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've asked and ACM/MCE don't seem to be using bundle-gen anymore. Given that, and the fact that we don't build OperatorHub bundles for MCE branches anymore, we should be able to eliminate this condition.

echo "${BASH_REMATCH[2]}"
elif [[ "$branch_name" =~ ^([^/]+/)?master$ ]]; then
echo "$MASTER_BRANCH_PREFIX"
else
echo "$UNKNOWN_BRANCH_PREFIX"
fi
}

function commit_count() {
git rev-list --count "$(git rev-list --max-parents=0 HEAD)..HEAD"
}

function short_sha() {
git rev-parse --short HEAD
}

echo "$(prefix_from_branch "$(git rev-parse --abbrev-ref HEAD)").$(commit_count)-$(short_sha)"