Skip to content

Commit

Permalink
CI code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
rsevilla87 committed Jan 28, 2020
1 parent e6ffde0 commit b9a3d49
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 38 deletions.
14 changes: 4 additions & 10 deletions ci/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,12 @@ function update_operator_image() {
operator-sdk build quay.io/rht_perf_ci/benchmark-operator:$tag_name --image-builder podman

# In case we have issues uploading to quay we will retry a few times
try_count=0
while [ $try_count -le 2 ]
do
if podman push quay.io/rht_perf_ci/benchmark-operator:$tag_name
then
try_count=2
elif [[ $try_count -eq 2 ]]
then
echo "Could not upload image to quay. Exiting"
for i in {1..3}; do
podman push quay.io/rht_perf_ci/benchmark-operator:${tag_name} && break
if [[ ${i} == 3 ]]; then
echo "Could not upload image to registry. Exiting"
exit 1
fi
((try_count++))
done
sed -i "s| image: quay.io/benchmark-operator/benchmark-operator:master*| image: quay.io/rht_perf_ci/benchmark-operator:$tag_name # |" resources/operator.yaml
}
Expand Down
52 changes: 24 additions & 28 deletions ci/run_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@ 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

# Disable metadata collection to save time
sed -i 's/metadata_collection: true/metadata_collection: false/g' ripsaw/tests/test_crs/*

# 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 @@ -28,38 +30,32 @@ 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 -v utils/ | grep -v ci/ | grep -v ripsaw/`
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
end_time=`date`
duration=`date -ud@$(($(date -ud"$end_time" +%s)-$(date -ud"$start_time" +%s))) +%T`
echo "${dir} | PASS | ${duration}" >> results.markdown
else
end_time=`date`
duration=`date -ud@$(($(date -ud"$end_time" +%s)-$(date -ud"$start_time" +%s))) +%T`
echo "${dir} | FAIL | ${duration}" >> results.markdown
test_rc=1
fi
wait_clean
done

echo "Summary of CI Test"
Expand Down

0 comments on commit b9a3d49

Please sign in to comment.