@@ -23,20 +23,13 @@ phases:
23
23
build :
24
24
commands :
25
25
# install
26
- - pip3 install -U -e .
27
26
- pip3 install -U -e .[test]
28
27
29
28
# run flake8
30
29
- tox -e flake8,twine
31
30
32
- # run unit tests
33
- - tox -e py36,py27 test/unit
34
-
35
- # Create pip archive
36
31
- root_dir=$(pwd)
37
32
- build_id="$(echo $CODEBUILD_BUILD_ID | sed -e 's/:/-/g')"
38
- - python3 setup.py sdist
39
- - tar_name=$(ls dist)
40
33
41
34
# Find build artifacts
42
35
- build_artifacts=$root_dir/docker/build_artifacts
@@ -48,48 +41,54 @@ phases:
48
41
49
42
# prepare build context
50
43
- build_dir="$root_dir/docker/$FRAMEWORK_VERSION/py2"
51
- - cp $root_dir/dist/$tar_name $build_dir
52
44
- cp $build_artifacts/*.py $build_dir/
53
45
- cd $build_dir
54
46
55
47
# build cpu image
56
48
- prod_tag="$FRAMEWORK_VERSION-cpu-py2"
57
49
- CPU_TAG_PY2="$prod_tag-$build_id"
58
50
- docker pull $PROD_IMAGE:$prod_tag
59
- - docker build --cache-from $PROD_IMAGE:$prod_tag -f $CPU_DOCKERFILE -t $PREPROD_IMAGE:$CPU_TAG_PY2 .
51
+ - build_cmd="docker build --cache-from $PROD_IMAGE:$prod_tag -f $CPU_DOCKERFILE -t $PREPROD_IMAGE:$CPU_TAG_PY2 . "
52
+ - execute-command-if-has-matching-changes "$build_cmd" "test/" "docker/*" "buildspec.yml"
60
53
61
54
# build gpu image
62
55
- prod_tag="$FRAMEWORK_VERSION-gpu-py2"
63
56
- GPU_TAG_PY2="$prod_tag-$build_id"
64
57
- docker pull $PROD_IMAGE:$prod_tag
65
- - docker build --cache-from $PROD_IMAGE:$prod_tag -f $GPU_DOCKERFILE -t $PREPROD_IMAGE:$GPU_TAG_PY2 .
58
+ - build_cmd="docker build --cache-from $PROD_IMAGE:$prod_tag -f $GPU_DOCKERFILE -t $PREPROD_IMAGE:$GPU_TAG_PY2 . "
59
+ - execute-command-if-has-matching-changes "$build_cmd" "test/" "docker/*" "buildspec.yml"
66
60
67
61
# build py3 images
68
62
69
63
# prepare build context
70
64
- build_dir="$root_dir/docker/$FRAMEWORK_VERSION/py3"
71
- - cp $root_dir/dist/$tar_name $build_dir
72
65
- cp $build_artifacts/*.py $build_dir/
73
66
- cd $build_dir
74
67
75
68
# build cpu image
76
69
- prod_tag="$FRAMEWORK_VERSION-cpu-py3"
77
70
- CPU_TAG_PY3="$prod_tag-$build_id"
78
71
- docker pull $PROD_IMAGE:$prod_tag
79
- - docker build --cache-from $PROD_IMAGE:$prod_tag -f $CPU_DOCKERFILE -t $PREPROD_IMAGE:$CPU_TAG_PY3 .
72
+ - build_cmd="docker build --cache-from $PROD_IMAGE:$prod_tag -f $CPU_DOCKERFILE -t $PREPROD_IMAGE:$CPU_TAG_PY3 . "
73
+ - execute-command-if-has-matching-changes "$build_cmd" "test/" "docker/*" "buildspec.yml"
80
74
81
75
# build gpu image
82
76
- prod_tag="$FRAMEWORK_VERSION-gpu-py3"
83
77
- GPU_TAG_PY3="$prod_tag-$build_id"
84
78
- docker pull $PROD_IMAGE:$prod_tag
85
- - docker build --cache-from $PROD_IMAGE:$prod_tag -f $GPU_DOCKERFILE -t $PREPROD_IMAGE:$GPU_TAG_PY3 .
79
+ - build_cmd="docker build --cache-from $PROD_IMAGE:$prod_tag -f $GPU_DOCKERFILE -t $PREPROD_IMAGE:$GPU_TAG_PY3 . "
80
+ - execute-command-if-has-matching-changes "$build_cmd" "test/" "docker/*" "buildspec.yml"
86
81
87
82
# push images to ecr
88
83
- $(aws ecr get-login --registry-ids $ACCOUNT --no-include-email --region $AWS_DEFAULT_REGION)
89
84
- docker push $PREPROD_IMAGE:$CPU_TAG_PY2
85
+ - execute-command-if-has-matching-changes "$push_cmd" "test/" "docker/*" "buildspec.yml"
90
86
- docker push $PREPROD_IMAGE:$GPU_TAG_PY2
87
+ - execute-command-if-has-matching-changes "$push_cmd" "test/" "docker/*" "buildspec.yml"
91
88
- docker push $PREPROD_IMAGE:$CPU_TAG_PY3
89
+ - execute-command-if-has-matching-changes "$push_cmd" "test/" "docker/*" "buildspec.yml"
92
90
- docker push $PREPROD_IMAGE:$GPU_TAG_PY3
91
+ - execute-command-if-has-matching-changes "$push_cmd" "test/" "docker/*" "buildspec.yml"
93
92
94
93
# launch remote gpu instance
95
94
- instance_type='p2.xlarge'
@@ -98,37 +97,41 @@ phases:
98
97
99
98
# run cpu integration tests
100
99
- py3_cmd="IGNORE_COVERAGE=- tox -e py36 -- test/integration/local --region $AWS_DEFAULT_REGION --docker-base-name $PREPROD_IMAGE --tag $CPU_TAG_PY3 --framework-version $FRAMEWORK_VERSION --py-version 3 --processor cpu --durations 10"
101
- - execute-command-if-has-matching-changes "$py3_cmd" "test/" "src/*.py" "setup.py" " docker/*" "buildspec.yml"
100
+ - execute-command-if-has-matching-changes "$py3_cmd" "test/" "docker/*" "buildspec.yml"
102
101
- py2_cmd="IGNORE_COVERAGE=- tox -e py27 -- test/integration/local --region $AWS_DEFAULT_REGION --docker-base-name $PREPROD_IMAGE --tag $CPU_TAG_PY2 --framework-version $FRAMEWORK_VERSION --py-version 2 --processor cpu --durations 10"
103
- - execute-command-if-has-matching-changes "$py2_cmd" "test/" "src/*.py" "setup.py" " docker/*" "buildspec.yml"
102
+ - execute-command-if-has-matching-changes "$py2_cmd" "test/" "docker/*" "buildspec.yml"
104
103
105
104
# run gpu integration tests
106
105
- printf "$SETUP_CMDS" > $SETUP_FILE
107
106
- cmd="IGNORE_COVERAGE=- tox -e py36 -- test/integration/local -n 4 --region $AWS_DEFAULT_REGION --docker-base-name $PREPROD_IMAGE --tag $GPU_TAG_PY3 --framework-version $FRAMEWORK_VERSION --py-version 3 --processor gpu --durations 10"
108
107
- py3_cmd="remote-test --github-repo $GITHUB_REPO --test-cmd \"$cmd\" --setup-file $SETUP_FILE --pr-number \"$PR_NUM\""
109
- - execute-command-if-has-matching-changes "$py3_cmd" "test/" "src/*.py" "setup.py" " docker/*" "buildspec.yml"
108
+ - execute-command-if-has-matching-changes "$py3_cmd" "test/" "docker/*" "buildspec.yml"
110
109
111
110
- cmd="IGNORE_COVERAGE=- tox -e py27 -- test/integration/local -n 4 --region $AWS_DEFAULT_REGION --docker-base-name $PREPROD_IMAGE --tag $GPU_TAG_PY2 --framework-version $FRAMEWORK_VERSION --py-version 2 --processor gpu --durations 10"
112
111
- py2_cmd="remote-test --github-repo $GITHUB_REPO --test-cmd \"$cmd\" --setup-file $SETUP_FILE --pr-number \"$PR_NUM\" --skip-setup"
113
- - execute-command-if-has-matching-changes "$py2_cmd" "test/" "src/*.py" "setup.py" " docker/*" "buildspec.yml"
112
+ - execute-command-if-has-matching-changes "$py2_cmd" "test/" "docker/*" "buildspec.yml"
114
113
115
114
# run sagemaker tests
116
115
- test_cmd="IGNORE_COVERAGE=- tox -e py36 -- test/integration/sagemaker -n 8 --region $AWS_DEFAULT_REGION --docker-base-name $ECR_REPO --account-id $ACCOUNT --tag $CPU_TAG_PY3 --py-version 3 --processor cpu --durations 10"
117
- - execute-command-if-has-matching-changes "$test_cmd" "test/" "src/*.py" "setup.py" " docker/*" "buildspec.yml"
116
+ - execute-command-if-has-matching-changes "$test_cmd" "test/" "docker/*" "buildspec.yml"
118
117
- test_cmd="IGNORE_COVERAGE=- tox -e py36 -- test/integration/sagemaker -n 8 --region $AWS_DEFAULT_REGION --docker-base-name $ECR_REPO --account-id $ACCOUNT --tag $GPU_TAG_PY3 --py-version 3 --processor gpu --durations 10"
119
- - execute-command-if-has-matching-changes "$test_cmd" "test/" "src/*.py" "setup.py" " docker/*" "buildspec.yml"
118
+ - execute-command-if-has-matching-changes "$test_cmd" "test/" "docker/*" "buildspec.yml"
120
119
- test_cmd="IGNORE_COVERAGE=- tox -e py27 -- test/integration/sagemaker -n 8 --region $AWS_DEFAULT_REGION --docker-base-name $ECR_REPO --account-id $ACCOUNT --tag $CPU_TAG_PY2 --py-version 2 --processor cpu --durations 10"
121
- - execute-command-if-has-matching-changes "$test_cmd" "test/" "src/*.py" "setup.py" " docker/*" "buildspec.yml"
120
+ - execute-command-if-has-matching-changes "$test_cmd" "test/" "docker/*" "buildspec.yml"
122
121
- test_cmd="IGNORE_COVERAGE=- tox -e py27 -- test/integration/sagemaker -n 8 --region $AWS_DEFAULT_REGION --docker-base-name $ECR_REPO --account-id $ACCOUNT --tag $GPU_TAG_PY2 --py-version 2 --processor gpu --durations 10"
123
- - execute-command-if-has-matching-changes "$test_cmd" "test/" "src/*.py" "setup.py" " docker/*" "buildspec.yml"
122
+ - execute-command-if-has-matching-changes "$test_cmd" "test/" "docker/*" "buildspec.yml"
124
123
125
124
finally :
126
125
# shut down remote gpu instance
127
126
- cleanup-gpu-instances
128
127
- cleanup-key-pairs
129
128
130
129
# remove ecr image
131
- - aws ecr batch-delete-image --repository-name $ECR_REPO --region $AWS_DEFAULT_REGION --image-ids imageTag=$CPU_TAG_PY2
132
- - aws ecr batch-delete-image --repository-name $ECR_REPO --region $AWS_DEFAULT_REGION --image-ids imageTag=$GPU_TAG_PY2
133
- - aws ecr batch-delete-image --repository-name $ECR_REPO --region $AWS_DEFAULT_REGION --image-ids imageTag=$CPU_TAG_PY3
134
- - aws ecr batch-delete-image --repository-name $ECR_REPO --region $AWS_DEFAULT_REGION --image-ids imageTag=$GPU_TAG_PY3
130
+ - delete_cmd="aws ecr batch-delete-image --repository-name $ECR_REPO --region $AWS_DEFAULT_REGION --image-ids imageTag=$CPU_TAG_PY2"
131
+ - execute-command-if-has-matching-changes "$delete_cmd" "test/" "docker/*" "buildspec.yml"
132
+ - delete_cmd="aws ecr batch-delete-image --repository-name $ECR_REPO --region $AWS_DEFAULT_REGION --image-ids imageTag=$GPU_TAG_PY2"
133
+ - execute-command-if-has-matching-changes "$delete_cmd" "test/" "docker/*" "buildspec.yml"
134
+ - delete_cmd="aws ecr batch-delete-image --repository-name $ECR_REPO --region $AWS_DEFAULT_REGION --image-ids imageTag=$CPU_TAG_PY3"
135
+ - execute-command-if-has-matching-changes "$delete_cmd" "test/" "docker/*" "buildspec.yml"
136
+ - delete_cmd="aws ecr batch-delete-image --repository-name $ECR_REPO --region $AWS_DEFAULT_REGION --image-ids imageTag=$GPU_TAG_PY3"
137
+ - execute-command-if-has-matching-changes "$delete_cmd" "test/" "docker/*" "buildspec.yml"
0 commit comments