mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-09 16:00:22 +00:00
ci: use cached image for ci-job-validation
Pull the ceph-csi:test image from the local (internal to CI) registry. Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
parent
a9014ce2ce
commit
d32319ae4e
7
Makefile
7
Makefile
@ -20,6 +20,7 @@ CPUS?=$(shell nproc --ignore=1)
|
||||
CPUSET?=--cpuset-cpus=0-${CPUS}
|
||||
|
||||
CSI_IMAGE_NAME=$(if $(ENV_CSI_IMAGE_NAME),$(ENV_CSI_IMAGE_NAME),quay.io/cephcsi/cephcsi)
|
||||
USE_PULLED_IMAGE ?= no
|
||||
|
||||
# passing TARGET=static-check on the 'make containerized-test' commandline will
|
||||
# run the selected target instead of 'make test' in the container. Obviously
|
||||
@ -69,11 +70,17 @@ containerized-test: REBASE ?= 0
|
||||
containerized-test: .test-container-id
|
||||
$(CONTAINER_CMD) run --rm -v $(PWD):/go/src/github.com/ceph/ceph-csi$(SELINUX_VOL_FLAG) $(CSI_IMAGE_NAME):test make $(TARGET) GIT_SINCE=$(GIT_SINCE) REBASE=$(REBASE)
|
||||
|
||||
ifeq ($(USE_PULLED_IMAGE),no)
|
||||
# create a (cached) container image with dependencies for testing the CI jobs
|
||||
.test-container-id: scripts/Dockerfile.test
|
||||
[ ! -f .test-container-id ] || $(CONTAINER_CMD) rmi $(CSI_IMAGE_NAME):test
|
||||
$(CONTAINER_CMD) build $(CPUSET) -t $(CSI_IMAGE_NAME):test -f ./scripts/Dockerfile.test .
|
||||
$(CONTAINER_CMD) inspect -f '{{.Id}}' $(CSI_IMAGE_NAME):test > .test-container-id
|
||||
else
|
||||
# use the pulled image, just create .test-container-id
|
||||
.test-container-id:
|
||||
$(CONTAINER_CMD) inspect -f '{{.Id}}' $(CSI_IMAGE_NAME):test > .test-container-id
|
||||
endif
|
||||
|
||||
clean:
|
||||
[ ! -f .test-container-id ] || $(CONTAINER_CMD) rmi $(CSI_IMAGE_NAME):test
|
||||
|
@ -7,6 +7,8 @@ def ref = 'ci/centos'
|
||||
def git_since = 'ci/centos'
|
||||
def base = ''
|
||||
def doc_change = 0
|
||||
// private, internal container image repository
|
||||
def cached_image = 'registry-ceph-csi.apps.ocp.ci.centos.org/ceph-csi'
|
||||
|
||||
node('cico-workspace') {
|
||||
stage('checkout ci repository') {
|
||||
@ -64,8 +66,25 @@ node('cico-workspace') {
|
||||
sh 'scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ./prepare.sh root@${CICO_NODE}:'
|
||||
sh "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@${CICO_NODE} ./prepare.sh --workdir=/opt/build/go/src/github.com/ceph/ceph-csi --gitrepo=${ci_git_repo} --ref=${ref} ${base}"
|
||||
}
|
||||
|
||||
// - check if the PR modifies the container image files
|
||||
// - pull the container image from the repository of no
|
||||
// modifications are detected
|
||||
stage('pull container image') {
|
||||
def rebuild_container = sh(
|
||||
script: "cd ~/build/ceph-csi && \${OLDPWD}/scripts/container-needs-rebuild.sh test origin/${git_since}",
|
||||
returnStatus: true)
|
||||
if (rebuild_container == 10) {
|
||||
// container needs rebuild, don't pull
|
||||
return
|
||||
}
|
||||
|
||||
withCredentials([usernamePassword(credentialsId: 'container-registry-auth', usernameVariable: 'CREDS_USER', passwordVariable: 'CREDS_PASSWD')]) {
|
||||
sh "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@${CICO_NODE} 'podman pull --creds=${CREDS_USER}:${CREDS_PASSWD} ${cached_image}:test'"
|
||||
}
|
||||
}
|
||||
stage('test') {
|
||||
sh 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@${CICO_NODE} "cd /opt/build/go/src/github.com/ceph/ceph-csi && make"'
|
||||
sh "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@${CICO_NODE} 'cd /opt/build/go/src/github.com/ceph/ceph-csi && make ENV_CSI_IMAGE_NAME=${cached_image} USE_PULLED_IMAGE=yes'"
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user