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

CI code improvements #123

Merged
merged 1 commit into from
Mar 5, 2020
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
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so if I understand this correctly, we got rid of the -f $my_dir/ci_test.sh because the test_list was constructed to have only directories containing a ci_test.sh. The only other change I see here is ${dir::-1} to ${dir}, which makes sense because if "dir" is an empty string or undefined then how did it get into test_list? it's hard to see if there are other changes here because of the indentation change, but I think that's all, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is exactly what I wanted to 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