Skip to content

change: print build execution time #890

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

Merged
merged 9 commits into from
Jun 29, 2019
Merged
Show file tree
Hide file tree
Changes from 3 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
25 changes: 25 additions & 0 deletions buildspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,51 @@ phases:
# run linters
- TOX_PARALLEL_NO_SPINNER=1
- PY_COLORS=0
- start_time=`date +%s`
- tox -e flake8,pylint,twine,black-check --parallel all
- ./ci-scripts/displaytime.sh 'flake8,pylint,twine,black-check' $start_time

- start_time=`date +%s`
- tox -e sphinx
- ./ci-scripts/displaytime.sh 'sphinx' $start_time

# run unit tests
- start_time=`date +%s`
- AWS_ACCESS_KEY_ID= AWS_SECRET_ACCESS_KEY= AWS_SESSION_TOKEN=
AWS_CONTAINER_CREDENTIALS_RELATIVE_URI= AWS_DEFAULT_REGION=
tox -e py36,py27 --parallel all -- tests/unit
- ./ci-scripts/displaytime.sh 'py36,py27 unit' $start_time

# local mode tests
- |
if has-matching-changes "tests/" "src/*.py" "setup.py" "setup.cfg" "buildspec.yml"; then
start_time=`date +%s`
IGNORE_COVERAGE=- tox -e py36 -- tests/integ -m local_mode --durations 50
./ci-scripts/displaytime.sh 'py36 local mode' $start_time

start_time=`date +%s`
IGNORE_COVERAGE=- tox -e py27 -- tests/integ -m local_mode --durations 50
./ci-scripts/displaytime.sh 'py27 local mode' $start_time

else
echo "skipping integration tests"
fi

# run integration tests
- |
if has-matching-changes "tests/" "src/*.py" "setup.py" "setup.cfg" "buildspec.yml"; then
start_time=`date +%s`
python3 -u ci-scripts/queue_build.py
./ci-scripts/displaytime.sh 'build queue' $start_time

start_time=`date +%s`
IGNORE_COVERAGE=- tox -e py36 -- tests/integ -m "not local_mode" -n 48 --reruns 3 --reruns-delay 5 --durations 50
./ci-scripts/displaytime.sh 'py36 tests/integ' $start_time

start_time=`date +%s`
IGNORE_COVERAGE=- tox -e py27 -- tests/integ -m "not local_mode" -n 48 --reruns 3 --reruns-delay 5 --durations 50
./ci-scripts/displaytime.sh 'py27 tests/integ' $start_time

else
echo "skipping integration tests"
fi
Expand All @@ -41,7 +63,10 @@ phases:
- |
if has-matching-changes "src/*.py" "setup.py" "setup.cfg" "buildspec.yml"; then
echo "running notebook test"
start_time=`date +%s`
./tests/scripts/run-notebook-test.sh
./ci-scripts/displaytime.sh 'notebook test' $start_time

else
echo "skipping notebook test"
fi
Expand Down
29 changes: 29 additions & 0 deletions ci-scripts/displaytime.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
# Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.

set -euo pipefail

echo =================== $1 execution time ===================

start_time=$2
end_time=`date +%s`
total_time=$(expr $end_time - $start_time)
hours=$((total_time/60/60%24))
minutes=$((total_time/60%60))
secs=$((total_time%60))

(( $hours > 0 )) && printf '%d hours ' $hours
(( $minutes > 0 )) && printf '%d minutes ' $minutes
(( $hours > 0 || $minutes > 0 )) && printf 'and '
printf '%d seconds\n\n' $secs