ci: skip containerized-tests for doc-only PRs

Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
Niels de Vos 2020-08-12 12:08:40 +02:00 committed by mergify[bot]
parent 648c3f7f77
commit 693d7b953e
2 changed files with 67 additions and 4 deletions

View File

@ -2,7 +2,11 @@ def cico_retries = 16
def cico_retry_interval = 60
def ci_git_repo = 'https://github.com/ceph/ceph-csi'
def ci_git_branch = 'ci/centos'
def git_repo = 'https://github.com/ceph/ceph-csi'
def ref = "master"
def git_since = 'master'
def workdir = '/opt/build/go/src/github.com/ceph/ceph-csi'
def doc_change = 0
node('cico-workspace') {
@ -12,6 +16,29 @@ node('cico-workspace') {
changelog: false
}
stage('checkout PR') {
if (params.ghprbPullId != null) {
ref = "pull/${ghprbPullId}/head"
}
if (params.ghprbTargetBranch != null) {
git_since = "${ghprbTargetBranch}"
}
sh "git clone --depth=1 --branch='${git_since}' '${git_repo}' ~/build/ceph-csi"
sh "cd ~/build/ceph-csi && git fetch origin ${ref} && git checkout -b ${ref} FETCH_HEAD"
}
stage('check doc-only change') {
doc_change = sh(
script: "cd ~/build/ceph-csi && \${OLDPWD}/scripts/skip-doc-change.sh origin/${git_since}",
returnStatus: true)
}
// if doc_change (return value of skip-doc-change.sh is 1, do not run the other stages
if (doc_change == 1) {
currentBuild.result = 'SUCCESS'
return
}
stage('reserve bare-metal machine') {
def firstAttempt = true
retry(30) {
@ -30,11 +57,9 @@ node('cico-workspace') {
try {
stage('prepare bare-metal machine') {
if (params.ghprbPullId != null) {
ref = "pull/${ghprbPullId}/head"
}
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}"
// TODO: already checked out the PR on the node, scp the contents?
sh "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@${CICO_NODE} ./prepare.sh --workdir=${workdir} --gitrepo=${git_repo} --ref=${ref}"
}
stage('test & build') {
parallel test: {

38
scripts/skip-doc-change.sh Executable file
View File

@ -0,0 +1,38 @@
#!/bin/bash -e
#
GIT_SINCE="${1}"
if [ -z "${GIT_SINCE}" ]; then
GIT_SINCE='origin/master'
fi
CHANGED_FILES=$(git diff --name-only "${GIT_SINCE}")
[[ -z $CHANGED_FILES ]] && exit 1
skip=0
#files to be skipped
declare -a FILES=(^docs/ .md$ ^scripts/ LICENSE .mergify.yml .github .gitignore)
function check_file_present() {
local file=$1
for FILE in "${FILES[@]}"; do
if [[ $file =~ $FILE ]]; then
if [[ $file =~ (minikube.sh|travis-functest.sh) ]]; then
continue
fi
return 0
fi
done
return 1
}
for CHANGED_FILE in $CHANGED_FILES; do
if ! check_file_present "$CHANGED_FILE"; then
skip=1
fi
done
if [ $skip -eq 0 ]; then
echo "doc change only"
exit 1
fi