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 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
68 changes: 50 additions & 18 deletions buildspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,44 +10,76 @@ 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

- IGNORE_COVERAGE=-

# local mode tests
- start_time=`date +%s`
- |
if has-matching-changes "tests/" "src/*.py" "setup.py" "setup.cfg" "buildspec.yml"; then
IGNORE_COVERAGE=- tox -e py36 -- tests/integ -m local_mode --durations 50
IGNORE_COVERAGE=- tox -e py27 -- tests/integ -m local_mode --durations 50
else
echo "skipping integration tests"
tox -e py36 -- tests/integ -m local_mode --durations 50
fi

- ./ci-scripts/displaytime.sh 'py36 local mode' $start_time

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

# run integration tests
- start_time=`date +%s`
- |
if has-matching-changes "tests/" "src/*.py" "setup.py" "setup.cfg" "buildspec.yml"; then
python3 -u ci-scripts/queue_build.py
IGNORE_COVERAGE=- tox -e py36 -- tests/integ -m "not local_mode" -n 48 --reruns 3 --reruns-delay 5 --durations 50
IGNORE_COVERAGE=- tox -e py27 -- tests/integ -m "not local_mode" -n 48 --reruns 3 --reruns-delay 5 --durations 50
else
echo "skipping integration tests"
fi
- ./ci-scripts/displaytime.sh 'build queue' $start_time

- start_time=`date +%s`
- |
if has-matching-changes "tests/" "src/*.py" "setup.py" "setup.cfg" "buildspec.yml"; then
tox -e py36 -- tests/integ -m "not local_mode" -n 48 --reruns 3 --reruns-delay 5 --durations 50
fi
- ./ci-scripts/displaytime.sh 'py36 tests/integ' $start_time

- start_time=`date +%s`
- |
if has-matching-changes "tests/" "src/*.py" "setup.py" "setup.cfg" "buildspec.yml"; then
tox -e py27 -- tests/integ -m "not local_mode" -n 48 --reruns 3 --reruns-delay 5 --durations 50
fi
- ./ci-scripts/displaytime.sh 'py27 tests/integ' $start_time

# run notebook test
- echo "running notebook test"
- start_time=`date +%s`
- |
if has-matching-changes "src/*.py" "setup.py" "setup.cfg" "buildspec.yml"; then
echo "running notebook test"
if has-matching-changes "src/*.py" "setup.py" "setup.cfg"; then
./tests/scripts/run-notebook-test.sh
else
echo "skipping notebook test"
fi
fi
- ./ci-scripts/displaytime.sh 'notebook test' $start_time

post_build:
finally:
- FILENAME=$(ls ci-lock/)
- ACCOUNT=$(aws sts get-caller-identity --output text | awk '{print $1}')
- S3_BUCKET_DIR=s3://sagemaker-us-west-2-${ACCOUNT}/ci-lock/
- aws s3 rm ${S3_BUCKET_DIR}${FILENAME}
- |
if [ -d "ci-lock" ]; then
FILENAME=$(ls ci-lock/ || true)
ACCOUNT=$(aws sts get-caller-identity --output text | awk '{print $1}')
S3_BUCKET_DIR=s3://sagemaker-us-west-2-${ACCOUNT}/ci-lock/
aws s3 rm ${S3_BUCKET_DIR}${FILENAME}
fi

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