Skip to content

Commit dd5b81b

Browse files
committed
change: print build execution time
1 parent fe29f60 commit dd5b81b

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

buildspec.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,51 @@ phases:
1010
# run linters
1111
- TOX_PARALLEL_NO_SPINNER=1
1212
- PY_COLORS=0
13+
- start_time=`date +%s`
1314
- tox -e flake8,pylint,twine,black-check --parallel all
15+
- ./ci-scripts/displaytime.sh 'flake8,pylint,twine,black-check' $start_time
16+
17+
- start_time=`date +%s`
1418
- tox -e sphinx
19+
- ./ci-scripts/displaytime.sh 'sphinx' $start_time
1520

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

2128
# local mode tests
2229
- |
2330
if has-matching-changes "tests/" "src/*.py" "setup.py" "setup.cfg" "buildspec.yml"; then
31+
start_time=`date +%s`
2432
IGNORE_COVERAGE=- tox -e py36 -- tests/integ -m local_mode --durations 50
33+
./ci-scripts/displaytime.sh 'py36 local mode ' $start_time
34+
35+
start_time=`date +%s`
2536
IGNORE_COVERAGE=- tox -e py27 -- tests/integ -m local_mode --durations 50
37+
./ci-scripts/displaytime.sh 'py27 local mode ' $start_time
38+
2639
else
2740
echo "skipping integration tests"
2841
fi
2942
3043
# run integration tests
3144
- |
3245
if has-matching-changes "tests/" "src/*.py" "setup.py" "setup.cfg" "buildspec.yml"; then
46+
start_time=`date +%s`
3347
python3 -u ci-scripts/queue_build.py
48+
./ci-scripts/displaytime.sh 'Build queue' $start_time
49+
50+
start_time=`date +%s`
3451
IGNORE_COVERAGE=- tox -e py36 -- tests/integ -m "not local_mode" -n 48 --reruns 3 --reruns-delay 5 --durations 50
52+
./ci-scripts/displaytime.sh 'py36 tests/integ ' $start_time
53+
54+
start_time=`date +%s`
3555
IGNORE_COVERAGE=- tox -e py27 -- tests/integ -m "not local_mode" -n 48 --reruns 3 --reruns-delay 5 --durations 50
56+
./ci-scripts/displaytime.sh 'py27 tests/integ ' $start_time
57+
3658
else
3759
echo "skipping integration tests"
3860
fi
@@ -41,7 +63,10 @@ phases:
4163
- |
4264
if has-matching-changes "src/*.py" "setup.py" "setup.cfg" "buildspec.yml"; then
4365
echo "running notebook test"
66+
start_time=`date +%s`
4467
./tests/scripts/run-notebook-test.sh
68+
./ci-scripts/displaytime.sh 'notebook test ' $start_time
69+
4570
else
4671
echo "skipping notebook test"
4772
fi

ci-scripts/displaytime.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License"). You
5+
# may not use this file except in compliance with the License. A copy of
6+
# the License is located at
7+
#
8+
# http://aws.amazon.com/apache2.0/
9+
#
10+
# or in the "license" file accompanying this file. This file is
11+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
12+
# ANY KIND, either express or implied. See the License for the specific
13+
# language governing permissions and limitations under the License.
14+
15+
set -euo pipefail
16+
17+
printf '%s execution time ' $1
18+
19+
start_time=$2
20+
end_time=`date +%s`
21+
total_time=$(expr $end_time - $start_time)
22+
hours=$((total_time/60/60%24))
23+
minutes=$((total_time/60%60))
24+
secs=$((total_time%60))
25+
26+
(( $hours > 0 )) && printf '%d hours ' $hours
27+
(( $minutes > 0 )) && printf '%d minutes ' $minutes
28+
(( $hours > 0 || $minutes > 0 )) && printf 'and '
29+
printf '%d seconds\n' $secs

0 commit comments

Comments
 (0)