Skip to content

Commit 64aa936

Browse files
authored
change: print build execution time (#890)
1 parent 8a95d68 commit 64aa936

File tree

2 files changed

+79
-18
lines changed

2 files changed

+79
-18
lines changed

buildspec.yml

+50-18
Original file line numberDiff line numberDiff line change
@@ -10,44 +10,76 @@ 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
27+
28+
- IGNORE_COVERAGE=-
2029

2130
# local mode tests
31+
- start_time=`date +%s`
2232
- |
2333
if has-matching-changes "tests/" "src/*.py" "setup.py" "setup.cfg" "buildspec.yml"; then
24-
IGNORE_COVERAGE=- tox -e py36 -- tests/integ -m local_mode --durations 50
25-
IGNORE_COVERAGE=- tox -e py27 -- tests/integ -m local_mode --durations 50
26-
else
27-
echo "skipping integration tests"
34+
tox -e py36 -- tests/integ -m local_mode --durations 50
2835
fi
29-
36+
- ./ci-scripts/displaytime.sh 'py36 local mode' $start_time
37+
38+
- start_time=`date +%s`
39+
- |
40+
if has-matching-changes "tests/" "src/*.py" "setup.py" "setup.cfg" "buildspec.yml"; then
41+
tox -e py27 -- tests/integ -m local_mode --durations 50
42+
fi
43+
- ./ci-scripts/displaytime.sh 'py27 local mode' $start_time
44+
3045
# run integration tests
46+
- start_time=`date +%s`
3147
- |
3248
if has-matching-changes "tests/" "src/*.py" "setup.py" "setup.cfg" "buildspec.yml"; then
3349
python3 -u ci-scripts/queue_build.py
34-
IGNORE_COVERAGE=- tox -e py36 -- tests/integ -m "not local_mode" -n 48 --reruns 3 --reruns-delay 5 --durations 50
35-
IGNORE_COVERAGE=- tox -e py27 -- tests/integ -m "not local_mode" -n 48 --reruns 3 --reruns-delay 5 --durations 50
36-
else
37-
echo "skipping integration tests"
3850
fi
51+
- ./ci-scripts/displaytime.sh 'build queue' $start_time
52+
53+
- start_time=`date +%s`
54+
- |
55+
if has-matching-changes "tests/" "src/*.py" "setup.py" "setup.cfg" "buildspec.yml"; then
56+
tox -e py36 -- tests/integ -m "not local_mode" -n 48 --reruns 3 --reruns-delay 5 --durations 50
57+
fi
58+
- ./ci-scripts/displaytime.sh 'py36 tests/integ' $start_time
59+
60+
- start_time=`date +%s`
61+
- |
62+
if has-matching-changes "tests/" "src/*.py" "setup.py" "setup.cfg" "buildspec.yml"; then
63+
tox -e py27 -- tests/integ -m "not local_mode" -n 48 --reruns 3 --reruns-delay 5 --durations 50
64+
fi
65+
- ./ci-scripts/displaytime.sh 'py27 tests/integ' $start_time
3966

4067
# run notebook test
68+
- echo "running notebook test"
69+
- start_time=`date +%s`
4170
- |
42-
if has-matching-changes "src/*.py" "setup.py" "setup.cfg" "buildspec.yml"; then
43-
echo "running notebook test"
71+
if has-matching-changes "src/*.py" "setup.py" "setup.cfg"; then
4472
./tests/scripts/run-notebook-test.sh
45-
else
46-
echo "skipping notebook test"
47-
fi
73+
fi
74+
- ./ci-scripts/displaytime.sh 'notebook test' $start_time
75+
4876
post_build:
4977
finally:
50-
- FILENAME=$(ls ci-lock/)
51-
- ACCOUNT=$(aws sts get-caller-identity --output text | awk '{print $1}')
52-
- S3_BUCKET_DIR=s3://sagemaker-us-west-2-${ACCOUNT}/ci-lock/
53-
- aws s3 rm ${S3_BUCKET_DIR}${FILENAME}
78+
- |
79+
if [ -d "ci-lock" ]; then
80+
FILENAME=$(ls ci-lock/ || true)
81+
ACCOUNT=$(aws sts get-caller-identity --output text | awk '{print $1}')
82+
S3_BUCKET_DIR=s3://sagemaker-us-west-2-${ACCOUNT}/ci-lock/
83+
aws s3 rm ${S3_BUCKET_DIR}${FILENAME}
84+
fi
85+

ci-scripts/displaytime.sh

+29
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+
echo =================== $1 execution time ===================
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\n' $secs

0 commit comments

Comments
 (0)