Skip to content

Commit

Permalink
Merge pull request vmware-tanzu#243 from kaovilai/1.0-ci
Browse files Browse the repository at this point in the history
Add `make -f Makefile.prow ci` that can be run in prow
  • Loading branch information
kaovilai authored Mar 15, 2023
2 parents 6b49e3b + 47d7599 commit b0f2840
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 63 deletions.
72 changes: 9 additions & 63 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,73 +6,19 @@ go: stable

env:
global:
- IMAGE1: quay.io/konveyor/velero
- IMAGE2: quay.io/konveyor/velero-restic-restore-helper
- DEFAULT_BRANCH: konveyor-dev
- DOCKERFILE1: Dockerfile.ubi
- DOCKERFILE2: Dockerfile-velero-restic-restore-helper.ubi
- DOCKER_CLI_EXPERIMENTAL: enabled
- GOPROXY: https://goproxy.io,direct

before_install:
- |
if [ "${TRAVIS_BRANCH}" == "${DEFAULT_BRANCH}" ]; then
export TAG=latest
else
export TAG="${TRAVIS_BRANCH}"
fi
- GOFLAGS: -mod=mod

# Builds routinely fail due to download failures inside alternate arch docker containers
# Here we are downloading outside the docker container and copying the deps in
# Also use -v for downloads/builds to stop no output failures from lxd env buffering.
before_script:
- go mod vendor -v
- git clone https://github.com/konveyor/restic -b ${TRAVIS_BRANCH}
- pushd restic; go mod vendor -v; popd
- sed -i 's|-mod=mod|-mod=vendor|g' ${DOCKERFILE1}
- sed -i 's|-mod=mod|-mod=vendor|g' ${DOCKERFILE2}
- sed -i 's|go build|go build -v|g' ${DOCKERFILE1}
- sed -i 's|go build|go build -v|g' ${DOCKERFILE2}
- sed -i 's|^RUN mkdir -p \$APP_ROOT/src/github.com/restic \\$|COPY --chown=1001 restic/ $APP_ROOT/src/github.com/restic/restic|g' ${DOCKERFILE1}
- sed -i 's|&& cd \$APP_ROOT/src/github.com/restic \\$||g' ${DOCKERFILE1}
- sed -i 's|&& git clone https://github.com/konveyor/restic -b .*$||g' ${DOCKERFILE1}

script:
- docker build -t ${IMAGE1}:${TAG}-${TRAVIS_ARCH} -f ${DOCKERFILE1} .
- docker build -t ${IMAGE2}:${TAG}-${TRAVIS_ARCH} -f ${DOCKERFILE2} .
- if [ -n "${QUAY_ROBOT}" ]; then docker login quay.io -u "${QUAY_ROBOT}" -p ${QUAY_TOKEN}; fi
- if [ -n "${QUAY_ROBOT}" ]; then docker push ${IMAGE1}:${TAG}-${TRAVIS_ARCH}; fi
- if [ -n "${QUAY_ROBOT}" ]; then docker push ${IMAGE2}:${TAG}-${TRAVIS_ARCH}; fi

jobs:
include:
- stage: build images
arch: ppc64le
- arch: s390x
- arch: arm64-graviton2
virt: lxd
group: edge
- arch: amd64
- stage: push manifest
language: shell
arch: amd64
before_script: []
script:
- |
if [ -n "${QUAY_ROBOT}" ]; then
docker login quay.io -u "${QUAY_ROBOT}" -p ${QUAY_TOKEN}
docker manifest create \
${IMAGE1}:${TAG} \
${IMAGE1}:${TAG}-amd64 \
${IMAGE1}:${TAG}-ppc64le \
${IMAGE1}:${TAG}-s390x \
${IMAGE1}:${TAG}-aarch64
docker manifest create \
${IMAGE2}:${TAG} \
${IMAGE2}:${TAG}-amd64 \
${IMAGE2}:${TAG}-ppc64le \
${IMAGE2}:${TAG}-s390x \
${IMAGE2}:${TAG}-aarch64
docker manifest push ${IMAGE1}:${TAG}
docker manifest push ${IMAGE2}:${TAG}
fi
- stage: everything
# this runs everything
script: make ci
# break up ci target so we get faster feedback
- script: make verify-modules
- script: make verify
- script: make all
- script: make test
35 changes: 35 additions & 0 deletions Makefile.prow
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
GOFLAGS="-mod=mod"
# emulate as close as possible upstream ci target
# upstream ci target: verify-modules verify all test
# we skip verify for now
# we only need to modify test, all to avoid docker usage
.PHONY: ci
ci:
GOFLAGS=$(GOFLAGS) make verify-modules
make -f Makefile.prow all test

.PHONY: all
all:
GOFLAGS=$(GOFLAGS) make local
GOFLAGS=$(GOFLAGS) BIN=velero-restic-restore-helper make local

.PHONY: test
# our test is modified to avoid docker usage
test: hack-docker
@echo Using KUBEBUILDER_ASSETS=$(KUBEBUILDER_ASSETS)
KUBEBUILDER_ASSETS=$(KUBEBUILDER_ASSETS) GOFLAGS=$(GOFLAGS) hack/test.sh

.PHONY: hack-docker
# emulate docker environment from hack/build-image/Dockerfile
hack-docker: envtest

GOPATH:=$(shell go env GOPATH)
KUBEBUILDER_ASSETS:=$(shell $(GOPATH)/bin/setup-envtest use -p path)
# if KUBEBUILDER_ASSETS contains space, escape it
KUBEBUILDER_ASSETS:=$(shell echo $(KUBEBUILDER_ASSETS) | sed 's/ /\\ /g')
.PHONY: envtest
envtest: $(GOPATH)/bin/setup-envtest
$(GOPATH)/bin/setup-envtest use -p path

$(GOPATH)/bin/setup-envtest:
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest

0 comments on commit b0f2840

Please sign in to comment.