Last active
September 9, 2020 15:25
-
-
Save SpainTrain/28fe7da692f5b9bf3266 to your computer and use it in GitHub Desktop.
Relevant config files for a python GAE app using CircleCI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[nosetests] | |
verbosity=3 | |
with-coverage=1 | |
cover-branches=1 | |
cover-xml=1 | |
cover-xml-file=./coverage.xml | |
cover-min-percentage=66 | |
with-profile=1 | |
profile-restrict=.05 | |
profile-stats-file=./profile-stats.prof | |
with-xunit=1 | |
with-ferris=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
"""CLI app that bumps app.yaml and prints new version""" | |
import vendor | |
vendor.add('vendor') | |
import click # noqa | |
import semver # noqa | |
import yaml # noqa | |
SEMVER_FN_MAP = { | |
'patch': semver.bump_patch, | |
'minor': semver.bump_minor, | |
'major': semver.bump_major | |
} | |
@click.command() | |
@click.argument('bump_type') | |
def bump(bump_type): | |
"""Simple program that bumps app.yaml version.""" | |
with file('./app.yaml') as yaml_stream: | |
app_yaml = yaml.load(yaml_stream) | |
current_semver = app_yaml['version'].replace('-', '.') | |
bumped_semver = SEMVER_FN_MAP[bump_type](current_semver) | |
app_yaml['version'] = bumped_semver.replace('.', '-') | |
with file('./app.yaml', 'w') as yaml_stream: | |
yaml.dump(app_yaml, yaml_stream, default_flow_style=False, indent=4) | |
click.echo(app_yaml['version']) | |
if __name__ == '__main__': | |
bump() # pylint: disable=bad-option-value,no-value-for-parameter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
machine: | |
python: | |
version: 2.7 | |
environment: | |
APPENGINE_SDK_PATH: "${HOME}/google_appengine" | |
CLOUDSDK_CORE_DISABLE_PROMPTS: 1 | |
general: | |
artifacts: | |
- "nosetests.xml" | |
- "coverage.xml" | |
- "profile-stats.prof" | |
dependencies: | |
pre: | |
- pip install --upgrade pip setuptools logilab-common webapp2 jinja2 | |
- python -V | |
- pip -V | |
override: | |
- make install | |
- make install-gae-sdk | |
test: | |
override: | |
- mkdir -p ${CIRCLE_TEST_REPORTS}/nose | |
- NOSE_XUNIT_FILE="${CIRCLE_TEST_REPORTS}/nose/${CIRCLE_PROJECT_REPONAME}.xml" make test | |
deployment: | |
master: | |
branch: master | |
commands: | |
- make deploy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -ex | |
APPCFG="${HOME}/google_appengine/appcfg.py" | |
REFRESH_TOK_SW="--oauth2_refresh_token=${APPCFG_OAUTH2_REFRESH_TOKEN}" | |
git config --global user.email "[email protected]" | |
git config --global user.name "CircleCI" | |
git config --global push.default simple | |
LAST_COMMIT_MSG="$(git log -1 --pretty=%B)" | |
SEMVER_BUMP_TYPE="$(echo ${LAST_COMMIT_MSG} | sed -n 's/^.*[rR]elease v+\([a-z]\+\).*$/\1/p')" | |
if [ -n "${SEMVER_BUMP_TYPE}" ]; then | |
# Bump version in app.yaml | |
HBUD_NEW_VERSION=$(./bump.py ${SEMVER_BUMP_TYPE}) | |
# Release to GAE sandbox | |
${APPCFG} update . ${REFRESH_TOK_SW} \ | |
-E SMARTY_STREETS_AUTH_ID:${SMARTY_STREETS_AUTH_ID} \ | |
-E SMARTY_STREETS_AUTH_TOKEN:${SMARTY_STREETS_AUTH_TOKEN} \ | |
-E HELLOSIGN_API_KEY:${HELLOSIGN_API_KEY} \ | |
-E HELLOSIGN_TEST_MODE:${HELLOSIGN_TEST_MODE_ON} \ | |
-E MANDRILL_API_KEY:${MANDRILL_API_KEY_TEST} \ | |
-E AUTHY_API_HOSTNAME:${AUTHY_API_HOSTNAME_SANDBOX} \ | |
-E AUTHY_API_KEY:${AUTHY_API_KEY_SANDBOX} | |
${APPCFG} migrate_traffic . ${REFRESH_TOK_SW} | |
# Release to GAE prod | |
${APPCFG} update . ${REFRESH_TOK_SW} -A homebuddy-apis \ | |
-E SMARTY_STREETS_AUTH_ID:${SMARTY_STREETS_AUTH_ID} \ | |
-E SMARTY_STREETS_AUTH_TOKEN:${SMARTY_STREETS_AUTH_TOKEN} \ | |
-E HELLOSIGN_API_KEY:${HELLOSIGN_API_KEY} \ | |
-E HELLOSIGN_TEST_MODE:${HELLOSIGN_TEST_MODE_OFF} \ | |
-E MANDRILL_API_KEY:${MANDRILL_API_KEY} \ | |
-E AUTHY_API_HOSTNAME:${AUTHY_API_HOSTNAME} \ | |
-E AUTHY_API_KEY:${AUTHY_API_KEY} | |
# Release succeeded, commit, tag, and push to github | |
git tag -am "${HBUD_NEW_VERSION}" ${HBUD_NEW_VERSION} | |
git add app.yaml | |
git commit -m "CircleCI: Releasing ${HBUD_NEW_VERSION}" | |
git push | |
git push --tags | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
all: install test | |
i: install | |
install: | |
rm -rf ./vendor/ | |
pip install -t vendor -r requirements.txt | |
ln -s ${HOME}/google_appengine/google vendor/google | |
tst: test | |
test: lint | |
PYTHONPATH="${PYTHONPATH}:./vendor" python ./vendor/nose -c ./.noserc ./ | |
lint: | |
# TODO: Better way to specify targets to linters | |
PYTHONPATH="${PYTHONPATH}:./vendor:./" python ./vendor/pylint --rcfile=./.pylintrc ./*.py app hbud_utils --load-plugins gae_pylint_plugin | |
PYTHONPATH="${PYTHONPATH}:./vendor" python ./vendor/pep8.pyc ./*.py app hbud_utils | |
dev: | |
~/google_appengine/dev_appserver.py app.yaml | |
install-gae-sdk: | |
mkdir -p /tmp/deps | |
wget -nv -P /tmp/deps https://storage.googleapis.com/appengine-sdks/featured/google_appengine_1.9.24.zip | |
unzip -qo -d ${HOME} /tmp/deps/google_appengine_1.9.24.zip | |
mkdir -p vendor | |
ln -s ${HOME}/google_appengine/google vendor/google | |
curl https://sdk.cloud.google.com | bash | |
~/google-cloud-sdk/bin/gcloud components update app-engine-python | |
echo "To use GAE CLI tools, add '~/google_appengine' to your PATH" | |
deploy: install test | |
./do-release.sh | |
echo "TODO: Deploy to GAE" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ferris==3.0.0a10 | |
click>3,<5 | |
pyaml>14,<16 | |
semver>1,<3 | |
nose>0,<2 | |
ferrisnose | |
coverage | |
pylint | |
pep8 | |
astroid |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment