Skip to content

Commit 4409cfb

Browse files
authored
infra: properly fail build if has-matching-changes fails (#155)
1 parent 98becc7 commit 4409cfb

File tree

1 file changed

+19
-32
lines changed

1 file changed

+19
-32
lines changed

buildspec.yml

+19-32
Original file line numberDiff line numberDiff line change
@@ -74,46 +74,33 @@ phases:
7474
- create-key-pair
7575
- launch-ec2-instance --instance-type $instance_type --ami-name dlami-ubuntu
7676

77-
- HAS_MATCHING_CHANGES_OUTPUT=$(has-matching-changes "test/" "tests/" "src/*.py" "setup.py" "setup.cfg" "docker/*" "buildspec.yml")
7877

7978
# run cpu integration tests
80-
- |
81-
if [ "$HAS_MATCHING_CHANGES" = "Changes Found" ] ; then
82-
pytest test/integration/local --region $AWS_DEFAULT_REGION --docker-base-name $PREPROD_IMAGE --framework-version $FRAMEWORK_VERSION --py-version $CPU_PY3_VERSION --processor cpu --tag $CPU_PY3_TAG
83-
pytest test/integration/local --region $AWS_DEFAULT_REGION --docker-base-name $PREPROD_IMAGE --framework-version $FRAMEWORK_VERSION --py-version $CPU_PY2_VERSION --processor cpu --tag $CPU_PY2_TAG
84-
else
85-
echo "skipping cpu integration tests"
86-
fi
79+
- test_cmd="pytest test/integration/local --region $AWS_DEFAULT_REGION --docker-base-name $PREPROD_IMAGE --framework-version $FRAMEWORK_VERSION --py-version $CPU_PY3_VERSION --processor cpu --tag $CPU_PY3_TAG"
80+
- execute-command-if-has-matching-changes "$test_cmd" "test/" "tests/" "src/*.py" "setup.py" "setup.cfg" "docker/*" "buildspec.yml"
81+
- test_cmd="pytest test/integration/local --region $AWS_DEFAULT_REGION --docker-base-name $PREPROD_IMAGE --framework-version $FRAMEWORK_VERSION --py-version $CPU_PY2_VERSION --processor cpu --tag $CPU_PY2_TAG"
82+
- execute-command-if-has-matching-changes "$test_cmd" "test/" "tests/" "src/*.py" "setup.py" "setup.cfg" "docker/*" "buildspec.yml"
8783

8884
# run gpu integration tests
89-
- |
90-
if [ "$HAS_MATCHING_CHANGES" = "Changes Found" ] ; then
91-
printf "$SETUP_CMDS" > $SETUP_FILE
92-
py3_cmd="pytest test/integration/local --region $AWS_DEFAULT_REGION --docker-base-name $PREPROD_IMAGE --framework-version $FRAMEWORK_VERSION --py-version $GPU_PY3_VERSION --processor gpu --tag $GPU_PY3_TAG"
93-
py2_cmd="pytest test/integration/local --region $AWS_DEFAULT_REGION --docker-base-name $PREPROD_IMAGE --framework-version $FRAMEWORK_VERSION --py-version $GPU_PY2_VERSION --processor gpu --tag $GPU_PY2_TAG"
94-
remote-test --github-repo $GITHUB_REPO --test-cmd "$py3_cmd" --setup-file $SETUP_FILE --pr-number "$PR_NUM"
95-
remote-test --github-repo $GITHUB_REPO --test-cmd "$py2_cmd" --setup-file $SETUP_FILE --pr-number "$PR_NUM" --skip-setup
96-
else
97-
echo "skipping gpu integration tests"
98-
fi
85+
- printf "$SETUP_CMDS" > $SETUP_FILE
86+
- py3_cmd="pytest test/integration/local --region $AWS_DEFAULT_REGION --docker-base-name $PREPROD_IMAGE --framework-version $FRAMEWORK_VERSION --py-version $GPU_PY3_VERSION --processor gpu --tag $GPU_PY3_TAG"
87+
- test_cmd="remote-test --github-repo $GITHUB_REPO --test-cmd \"$py3_cmd\" --setup-file $SETUP_FILE --pr-number \"$PR_NUM\""
88+
- execute-command-if-has-matching-changes "$test_cmd" "test/" "tests/" "src/*.py" "setup.py" "setup.cfg" "docker/*" "buildspec.yml"
89+
- py2_cmd="pytest test/integration/local --region $AWS_DEFAULT_REGION --docker-base-name $PREPROD_IMAGE --framework-version $FRAMEWORK_VERSION --py-version $GPU_PY2_VERSION --processor gpu --tag $GPU_PY2_TAG"
90+
- test_cmd="remote-test --github-repo $GITHUB_REPO --test-cmd \"$py2_cmd\" --setup-file $SETUP_FILE --pr-number \"$PR_NUM\" --skip-setup"
91+
- execute-command-if-has-matching-changes "$test_cmd" "test/" "tests/" "src/*.py" "setup.py" "setup.cfg" "docker/*" "buildspec.yml"
9992

10093
# run cpu sagemaker tests
101-
- |
102-
if [ "$HAS_MATCHING_CHANGES" = "Changes Found" ] ; then
103-
pytest test/integration/sagemaker --region $AWS_DEFAULT_REGION --docker-base-name $ECR_REPO --aws-id $ACCOUNT --framework-version $FRAMEWORK_VERSION --py-version $CPU_PY3_VERSION --processor cpu --instance-type $CPU_INSTANCE_TYPE --tag $CPU_PY3_TAG
104-
pytest test/integration/sagemaker --region $AWS_DEFAULT_REGION --docker-base-name $ECR_REPO --aws-id $ACCOUNT --framework-version $FRAMEWORK_VERSION --py-version $CPU_PY2_VERSION --processor cpu --instance-type $CPU_INSTANCE_TYPE --tag $CPU_PY2_TAG
105-
else
106-
echo "skipping cpu sagemaker tests"
107-
fi
94+
- test_cmd="pytest test/integration/sagemaker --region $AWS_DEFAULT_REGION --docker-base-name $ECR_REPO --aws-id $ACCOUNT --framework-version $FRAMEWORK_VERSION --py-version $CPU_PY3_VERSION --processor cpu --instance-type $CPU_INSTANCE_TYPE --tag $CPU_PY3_TAG"
95+
- execute-command-if-has-matching-changes "$test_cmd" "test/" "tests/" "src/*.py" "setup.py" "setup.cfg" "docker/*" "buildspec.yml"
96+
- test_cmd="pytest test/integration/sagemaker --region $AWS_DEFAULT_REGION --docker-base-name $ECR_REPO --aws-id $ACCOUNT --framework-version $FRAMEWORK_VERSION --py-version $CPU_PY2_VERSION --processor cpu --instance-type $CPU_INSTANCE_TYPE --tag $CPU_PY2_TAG"
97+
- execute-command-if-has-matching-changes "$test_cmd" "test/" "tests/" "src/*.py" "setup.py" "setup.cfg" "docker/*" "buildspec.yml"
10898

10999
# run gpu sagemaker tests
110-
- |
111-
if [ "$HAS_MATCHING_CHANGES" = "Changes Found" ] ; then
112-
pytest test/integration/sagemaker --region $AWS_DEFAULT_REGION --docker-base-name $ECR_REPO --aws-id $ACCOUNT --framework-version $FRAMEWORK_VERSION --py-version $GPU_PY3_VERSION --processor gpu --instance-type $GPU_INSTANCE_TYPE --tag $GPU_PY3_TAG
113-
pytest test/integration/sagemaker --region $AWS_DEFAULT_REGION --docker-base-name $ECR_REPO --aws-id $ACCOUNT --framework-version $FRAMEWORK_VERSION --py-version $CPU_PY2_VERSION --processor cpu --instance-type $CPU_INSTANCE_TYPE --tag $GPU_PY2_TAG
114-
else
115-
echo "skipping gpu sagemaker tests"
116-
fi
100+
- test_cmd="pytest test/integration/sagemaker --region $AWS_DEFAULT_REGION --docker-base-name $ECR_REPO --aws-id $ACCOUNT --framework-version $FRAMEWORK_VERSION --py-version $GPU_PY3_VERSION --processor gpu --instance-type $GPU_INSTANCE_TYPE --tag $GPU_PY3_TAG"
101+
- execute-command-if-has-matching-changes "$test_cmd" "test/" "tests/" "src/*.py" "setup.py" "setup.cfg" "docker/*" "buildspec.yml"
102+
- test_cmd="pytest test/integration/sagemaker --region $AWS_DEFAULT_REGION --docker-base-name $ECR_REPO --aws-id $ACCOUNT --framework-version $FRAMEWORK_VERSION --py-version $CPU_PY2_VERSION --processor cpu --instance-type $CPU_INSTANCE_TYPE --tag $GPU_PY2_TAG"
103+
- execute-command-if-has-matching-changes "$test_cmd" "test/" "tests/" "src/*.py" "setup.py" "setup.cfg" "docker/*" "buildspec.yml"
117104

118105
finally:
119106
# shut down remote gpu instance

0 commit comments

Comments
 (0)