Skip to content

Commit

Permalink
CI code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
rsevilla87 committed Mar 3, 2020
1 parent 26a2630 commit f37d420
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 37 deletions.
12 changes: 3 additions & 9 deletions ci/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,12 @@ function update_operator_image() {
$SUDO operator-sdk build $image_spec --image-builder $image_builder

# In case we have issues uploading to quay we will retry a few times
try_count=0
while [ $try_count -le 2 ]
do
if $SUDO $image_builder push $image_spec
then
try_count=2
elif [[ $try_count -eq 2 ]]
then
for i in {1..3}; do
$SUDO ${image_builder} push ${image_spec} && break
if [[ ${i} == 3 ]]; then
echo "Could not upload image to $image_location. Exiting"
exit $NOTOK
fi
((try_count++))
done
sed -i \
"s| image: $default_operator_image| image: $image_spec # |" \
Expand Down
51 changes: 23 additions & 28 deletions ci/run_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ kubectl create namespace my-ripsaw

# Clone ripsaw so we can use it for testing
rm -rf ripsaw
git clone https://github.com/cloud-bulldozer/ripsaw.git
git clone https://github.com/cloud-bulldozer/ripsaw.git --depth 1

if [[ $ghprbPullLongDescription = *"Depends-On:"* ]]; then
ripsaw_change_id="$(echo $ghprbPullLongDescription | sed -n -e 's/^.*Depends-On: //p')"
Expand All @@ -23,10 +23,12 @@ fi


# Prep results.markdown file
echo "Results for SNAFU CI Test" > results.markdown
echo "" >> results.markdown
echo 'Test | Result | Runtime' >> results.markdown
echo '-----|--------|--------' >> results.markdown
cat > results.markdown << EOF
Results for SNAFU CI Test
Test | Result | Runtime
-----|--------|--------
EOF

diff_list=`git diff origin/master --name-only`

Expand All @@ -35,38 +37,31 @@ diff_list=`git diff origin/master --name-only`
# - anything in ci has been changed
# - anything in utils has been changed
# Else only run tests on directories that have changed
if [[ `echo $diff_list | grep -v / | wc -l` -gt 0 || `echo $diff_list | grep ci/` || `echo $diff_list | grep utils/` ]]
then
if [[ `echo ${diff_list} | grep -cv /` -gt 0 || `echo ${diff_list} | grep -E "(ci|utils|image_resources)/"` ]]; then
echo "Running full test"
test_list=`ls -d */ | grep -Ev "(utils|ci|ripsaw|image_resources)/"`
test_list=`find * -maxdepth 1 -name ci_test.sh -type f -exec dirname {} \;`
else
echo "Running specific tests"
echo $diff_list
test_list=`echo $diff_list | awk -F "/" '{print $1}' | uniq`
test_list=`echo "${diff_list}" | awk -F "/" '{print $1}' | uniq`
fi

echo "Running tests in the following directories: "$test_list
echo -e "Running tests in the following directories:\n${test_list}"
test_rc=0

for dir in `echo $test_list`
do
my_dir=${dir}
if [ -f $my_dir/ci_test.sh ]; then
start_time=`date`
figlet "CI test for "$my_dir
if $my_dir/ci_test.sh
then
end_time=`date`
duration=`date -ud@$(($(date -ud"$end_time" +%s)-$(date -ud"$start_time" +%s))) +%T`
echo ${dir::-1}" | PASS | "$duration >> results.markdown
else
end_time=`date`
duration=`date -ud@$(($(date -ud"$end_time" +%s)-$(date -ud"$start_time" +%s))) +%T`
echo ${dir::-1}" | FAIL | "$duration >> results.markdown
test_rc=1
fi
wait_clean
for dir in ${test_list}; do
start_time=`date`
figlet "CI test for ${dir}"
if $dir/ci_test.sh; then
result="PASS"
else
result="FAIL"
test_rc=1
fi
end_time=`date`
duration=`date -ud@$(($(date -ud"$end_time" +%s)-$(date -ud"$start_time" +%s))) +%T`
echo "${dir} | ${result} | ${duration}" >> results.markdown
wait_clean
done

echo "Summary of CI Test"
Expand Down

0 comments on commit f37d420

Please sign in to comment.