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

MULTIARCH-3440: refine multiarch support for test-unit and test-e2e using dockerfile and add ppc64le build to Makefile #624

Merged
merged 6 commits into from
Jun 8, 2023
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
3 changes: 3 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ builds:
- linux
goarch:
- amd64
- ppc64le
- s390x
- arm64
env:
- CGO_ENABLED=1
flags:
Expand Down
15 changes: 12 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,28 @@ ARG DNF_LIST="\
git \
gpgme-devel \
libassuan-devel \
wget \
pigz \
"

#################################################################################
# Build UBI8 Builder
# Build UBI8 Builder with multi-arch support
RUN set -ex \
&& ARCH=$(arch | sed 's|x86_64|amd64|g' | sed 's|aarch64|arm64|g') \
&& dnf install -y --nodocs --setopt=install_weak_deps=false ${DNF_LIST} \
&& dnf clean all -y \
&& GO_VERSION=go1.19.5 \
&& curl -sL https://golang.org/dl/${GO_VERSION}.linux-amd64.tar.gz \
&& GO_VERSION=go1.19.5 \
&& curl -sL https://golang.org/dl/${GO_VERSION}.linux-${ARCH}.tar.gz \
| tar xzvf - --directory /usr/local/ \
&& /usr/local/go/bin/go version \
&& ln -f /usr/local/go/bin/go /usr/bin/go

#################################################################################
# Link gcc to /usr/bin/s390x-linux-gnu-gcc as go requires it on s390x
RUN [ "$(arch)" == "s390x" ] \
&& ln /usr/bin/gcc /usr/bin/s390x-linux-gnu-gcc \
|| echo "Not running on s390x, skip linking gcc binary"

WORKDIR /build
ENTRYPOINT ["make"]
CMD []
Expand Down
24 changes: 18 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,19 @@ cross-build-linux-amd64:
+@GOOS=linux GOARCH=amd64 $(MAKE) "$(GO_BUILD_FLAGS)" --no-print-directory build GO_BUILD_BINDIR=$(GO_BUILD_BINDIR)/linux-amd64
.PHONY: cross-build-linux-amd64

cross-build: cross-build-linux-amd64
cross-build-linux-ppc64le:
+@GOOS=linux GOARCH=ppc64le $(MAKE) "$(GO_BUILD_FLAGS)" --no-print-directory build GO_BUILD_BINDIR=$(GO_BUILD_BINDIR)/linux-ppc64le
.PHONY: cross-build-linux-ppc64le

cross-build-linux-s390x:
+@GOOS=linux GOARCH=s390x $(MAKE) "$(GO_BUILD_FLAGS)" --no-print-directory build GO_BUILD_BINDIR=$(GO_BUILD_BINDIR)/linux-s390x
.PHONY: cross-build-linux-s390x

cross-build-linux-arm64:
+@GOOS=linux GOARCH=arm64 $(MAKE) "$(GO_BUILD_FLAGS)" --no-print-directory build GO_BUILD_BINDIR=$(GO_BUILD_BINDIR)/linux-arm64
.PHONY: cross-build-linux-arm64

cross-build: cross-build-linux-amd64 cross-build-linux-ppc64le cross-build-linux-s390x cross-build-linux-arm64
.PHONY: cross-build

hack-build: clean
Expand Down Expand Up @@ -71,12 +83,12 @@ publish-catalog:
@cd test/operator && make
.PHONY: publish-catalog

format:
format:
$(GO) fmt ./pkg/...
$(GO) fmt ./cmd/...
.PHONY: format

vet:
$(GO) vet $(GO_BUILD_FLAGS) ./pkg/...
$(GO) vet $(GO_BUILD_FLAGS) ./cmd/...
.PHONY: vet
vet:
$(GO) vet $(GO_BUILD_FLAGS) ./pkg/...
$(GO) vet $(GO_BUILD_FLAGS) ./cmd/...
.PHONY: vet
6 changes: 5 additions & 1 deletion test/e2e/e2e-simple.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@ METADATA_OCI_CATALOG="oci://${DIR}/artifacts/rhop-ctlg-oci"
TARGET_CATALOG_NAME="target-name"
TARGET_CATALOG_TAG="target-tag"


GOBIN=$HOME/go/bin
# Check if this is running with a different location
if [ ! -d $GOBIN ]
then
GOBIN=/usr/local/go/bin/
fi
PATH=$PATH:$GOBIN

mkdir -p $DATA_TMP
Expand Down
50 changes: 38 additions & 12 deletions test/e2e/lib/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,44 @@ function cleanup_conn() {

# install_deps will install crane and registry2 in go bin dir
function install_deps() {
pushd ${DATA_TMP}
GOFLAGS=-mod=mod go install github.com/google/go-containerregistry/cmd/crane@latest
popd
crane export registry:2 registry2.tar
tar xvf registry2.tar bin/registry
mv bin/registry $GOBIN
crane export quay.io/operator-framework/opm@sha256:d31c6ea5c50be93d6eb94d2b508f0208e84a308c011c6454ebf291d48b37df19 opm.tar
tar xvf opm.tar bin/opm
mv bin/opm $GOBIN
rm -f registry2.tar opm.tar
wget -O $GOBIN/jq https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64
chmod +x $GOBIN/jq
if [ "$(arch)" == "x86_64" ]
then
pushd ${DATA_TMP}
GOFLAGS=-mod=mod go install github.com/google/go-containerregistry/cmd/crane@latest
popd
crane export registry:2 registry2.tar
tar xvf registry2.tar bin/registry
mv bin/registry $GOBIN
crane export quay.io/operator-framework/opm@sha256:d31c6ea5c50be93d6eb94d2b508f0208e84a308c011c6454ebf291d48b37df19 opm.tar
tar xvf opm.tar bin/opm
mv bin/opm $GOBIN
rm -f registry2.tar opm.tar
wget -O $GOBIN/jq https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64
chmod +x $GOBIN/jq
else
# non-x86_64 flow
pushd ${DATA_TMP}

# For ppc64le, this is compiled with Power9 compatibility (does not run on Power8)
ARCH=$(arch | sed 's|aarch64|arm64|g')
curl -o $GOBIN/opm -L https://github.com/operator-framework/operator-registry/releases/download/v1.27.1/linux-${ARCH}-opm
chmod +x $GOBIN/opm

GOFLAGS=-mod=mod go install github.com/google/go-containerregistry/cmd/crane@latest
mv ~/go/bin/crane $GOBIN/

if [ "${ARCH}" == "arm64" ]
then
crane export --platform linux/arm64/v8 registry:2 registry2.tar
else
crane export ${ARCH}/registry:2 registry2.tar
fi
tar xvf registry2.tar bin/registry
mv bin/registry $GOBIN
rm registry2.tar

popd
fi
}

# setup_reg will configure and start registry2 processes
Expand Down