Skip to content

chore: Add validation to test release codebuild spec #326

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 5 commits into from
Mar 26, 2021
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
32 changes: 22 additions & 10 deletions codebuild/release/prod-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,33 @@ env:

phases:
install:
commands:
- pip install tox
- pip install --upgrade pip
runtime-versions:
python: latest
pre_build:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the functional difference between build and pre_build?

Copy link
Contributor Author

@farleyb-amazon farleyb-amazon Mar 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest I haven't found a clear description of any functional differences. The docs provide some examples of what you could do in each one, but there doesn't seem to be anything concrete. My grouping here is fairly arbitrary, so I'm open to suggestions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine, it looks like pre_build/build/post_build are really just to help organize the phases, and this seems to fit well.

commands:
- git checkout $COMMIT_ID
- FOUND_VERSION=$(sed -n 's/__version__ = "\(.*\)"/\1/p' src/aws_encryption_sdk/identifiers.py)
- |
if expr ${FOUND_VERSION} != ${VERSION}; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming VERSION has to be provided manually when executing this build? Is there a good place to document a repository's available build commands and how to call them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, and good question. There is a spot for environment variables, but it looks like they do require you pass a value, and I didn't want to provide a default for the version. Worst case we could add comments, but let me look a bit more to see if there are other options.

echo "identifiers.py version (${FOUND_VERSION}) does not match expected version (${VERSION}), stopping"
exit 1;
fi
build:
commands:
- pip install tox
- git checkout $BRANCH
- tox -e park
- tox -e release
- git clone https://github.com/aws-samples/busy-engineers-document-bucket.git
- cd busy-engineers-document-bucket/exercises/python/encryption-context-complete
- sed -i "s/aws_encryption_sdk/aws_encryption_sdk==$VERSION/" requirements-dev.txt
- tox -e test


batch:
fast-fail: false
build-list:
- identifier: prod_release
fast-fail: true
build-graph:
- identifier: release_to_prod
- identifier: validate_prod_release
depend-on:
- release_to_prod
buildspec: codebuild/release/validate.yml
env:
variables:
PIP_INDEX_URL: https://pypi.python.org/simple/
28 changes: 23 additions & 5 deletions codebuild/release/test-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,35 @@ env:

phases:
install:
commands:
- pip install tox
- pip install --upgrade pip
runtime-versions:
python: latest
pre_build:
commands:
- git checkout $COMMIT_ID
- FOUND_VERSION=$(sed -n 's/__version__ = "\(.*\)"/\1/p' src/aws_encryption_sdk/identifiers.py)
- |
if expr ${FOUND_VERSION} != ${VERSION}; then
echo "identifiers.py version (${FOUND_VERSION}) does not match expected version (${VERSION}), stopping"
exit 1;
fi
build:
commands:
- pip install tox
- git checkout $BRANCH
- tox -e park
- tox -e test-release


batch:
fast-fail: false
build-list:
- identifier: test_release
fast-fail: true
build-graph:
- identifier: release_to_staging
- identifier: validate_staging_release
depend-on:
- release_to_staging
buildspec: codebuild/release/validate.yml
env:
variables:
PIP_INDEX_URL: https://test.pypi.org/simple/
PIP_EXTRA_INDEX_URL: https://pypi.python.org/simple/
16 changes: 16 additions & 0 deletions codebuild/release/validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: 0.2

phases:
install:
commands:
- pip install tox
runtime-versions:
python: latest
pre_build:
commands:
- git clone https://github.com/aws-samples/busy-engineers-document-bucket.git
- cd busy-engineers-document-bucket/exercises/python/encryption-context-complete
- sed -i "s/aws_encryption_sdk/aws_encryption_sdk==$VERSION/" requirements-dev.txt
build:
commands:
- tox -e test