Skip to content
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

Circle 1->2 #42

Merged
merged 19 commits into from Jul 6, 2018
2 changes: 1 addition & 1 deletion .bumpversion.cfg
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.6.0
current_version = 1.6.1
commit = False
tag = False

Expand Down
179 changes: 179 additions & 0 deletions .circleci/config.yml
@@ -0,0 +1,179 @@
#
# Globality autogenerated CircleCI configuration
#
# This file is auto generated with globality-build.
# You should not make any changes to this file manually
#
# Any changes made to this file will be overwritten in the
# next version of the build.
#
# See: http://github.com/globality-corp/globality-buid
#
#

defaults: &defaults
working_directory: ~/repo
docker:
- image: ${AWS_ECR_DOMAIN}/globality-build:stable
aws_auth:
aws_access_key_id: ${AWS_ACCESS_KEY_ID}
aws_secret_access_key: ${AWS_SECRET_ACCESS_KEY}
environment:
EXTRA_INDEX_URL: "InjectedDuringRuntime"
AWS_ECR_DOMAIN: "InjectedDuringRuntime"
JFROG_AUTH: "InjectedDuringRuntime"
PYPI_USERNAME: "InjectedDuringRuntime"
PYPI_PASSWORD: "InjectedDuringRuntime"

deploy_defaults: &deploy_defaults
working_directory: ~/repo
docker:
- image: ${AWS_ECR_DOMAIN}/globality-build:stable
aws_auth:
aws_access_key_id: ${AWS_ACCESS_KEY_ID}
aws_secret_access_key: ${AWS_SECRET_ACCESS_KEY}
environment:
EXTRA_INDEX_URL: "InjectedDuringRuntime"
AWS_ECR_DOMAIN: "InjectedDuringRuntime"
JFROG_AUTH: "InjectedDuringRuntime"
PYPI_USERNAME: "InjectedDuringRuntime"
PYPI_PASSWORD: "InjectedDuringRuntime"

whitelist: &whitelist
paths:
.

version: 2

jobs:
checkout:
<<: *defaults

steps:
- checkout

- persist_to_workspace:
root: ~/repo
<<: *whitelist

build_base_docker:
<<: *defaults

steps:
- attach_workspace:
at: ~/repo

- setup_remote_docker

- run:
name: Build Base Docker
# install dependencies for loading ecs task definitions
command: |
eval $(aws ecr get-login --no-include-email)
sudo pip install --upgrade elcaminoreal
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I know I know. but I have to do one manual merge of something so I can know that the deploy flow works correctly before I can merge globality build.

sudo pip install --extra-index-url $EXTRA_INDEX_URL globality-build==2018.23.1rc5
python -m middlefield globality build build-gen --config .globality/build.json
python -m middlefield globality build docker-base --repo microcosm-postgres
python -m middlefield globality build docker --repo microcosm-postgres

test:
<<: *defaults

steps:
- attach_workspace:
at: ~/repo

- setup_remote_docker

- run:
name: pull and run database
command: |
docker pull postgres
docker run -d --name microcosm_postgres_db -e POSTGRES_DB=example_test_db -e POSTGRES_USER=example postgres
- run:
name: Test code
command: |
docker create -v /src/microcosm_postgres/tests/ --name service_tests alpine:3.4 /bin/true
docker cp $(pwd)/microcosm_postgres/tests service_tests:/src/microcosm_postgres/
eval $(aws ecr get-login --no-include-email)
docker pull ${AWS_ECR_DOMAIN}/microcosm-postgres:${CIRCLE_SHA1}
docker run -it --link microcosm_postgres_db:postgres -e EXAMPLE__POSTGRES__HOST=postgres --volumes-from service_tests ${AWS_ECR_DOMAIN}/microcosm-postgres:${CIRCLE_SHA1} test

lint:
<<: *defaults

steps:
- attach_workspace:
at: ~/repo

- setup_remote_docker

- run:
name: Run Lint
command: |
docker create -v /src/microcosm-postgres/tests/ --name service_tests alpine:3.4 /bin/true
docker cp $(pwd)/microcosm_postgres/tests service_tests:/src/microcosm_postgres/
eval $(aws ecr get-login --no-include-email)
docker pull ${AWS_ECR_DOMAIN}/microcosm-postgres:${CIRCLE_SHA1}
docker run -it --volumes-from service_tests ${AWS_ECR_DOMAIN}/microcosm-postgres:${CIRCLE_SHA1} lint


deploy:
<<: *defaults
steps:
- attach_workspace:
at: ~/repo
- run:
name: Deploy
command: |
echo "[distutils]" > ~/.pypirc
echo "index-servers =" >> ~/.pypirc
echo " pypi" >> ~/.pypirc
echo >> ~/.pypirc
echo "[pypi]" >> ~/.pypirc
echo "username:$PYPI_USERNAME" >> ~/.pypirc
echo "password:$PYPI_PASSWORD" >> ~/.pypirc
echo >> ~/.pypirc
python setup.py register -r pypi
python setup.py sdist upload -r pypi

workflows:
version: 2

build-and-release:
jobs:
- checkout:
filters:
# run for all branches and tags
tags:
only: /.*/
- build_base_docker:
requires:
- checkout
filters:
# run for all branches and tags
tags:
only: /.*/
- lint:
requires:
- build_base_docker
filters:
# run for all branches and tags
tags:
only: /.*/
- test:
requires:
- build_base_docker
filters:
# run for all branches and tags
tags:
only: /.*/
- deploy:
requires:
- test
- lint
filters:
branches:
ignore: /.*/
tags:
only: /^[0-9]+(\.[0-9]+)*/
5 changes: 5 additions & 0 deletions .gitignore
Expand Up @@ -92,3 +92,8 @@ docs/_build/

# PyBuilder
target/

/.dockerignore
/Dockerfile.template
/build.*/
/entrypoint.sh
8 changes: 8 additions & 0 deletions .globality/build.json
@@ -0,0 +1,8 @@
{
"type": "python-library",
"params": {
"name": "microcosm-postgres",
"app_name": "example",
"database": "postgres"
}
}
Empty file added MANIFEST.in
Empty file.
40 changes: 0 additions & 40 deletions circle.yml

This file was deleted.

9 changes: 8 additions & 1 deletion microcosm_postgres/tests/factories/test_engine.py
Expand Up @@ -7,6 +7,8 @@
equal_to,
instance_of,
is_,
starts_with,
ends_with,
)

from microcosm.api import create_object_graph
Expand All @@ -26,7 +28,12 @@ def test_configure_engine():
# engine has expected configuration
assert_that(
str(engine.url),
is_(equal_to("postgresql://example:@localhost:5432/example_test_db")),
starts_with("postgresql://example:@"),
)

assert_that(
str(engine.url),
ends_with(":5432/example_test_db"),
)

# engine supports connections
Expand Down
7 changes: 6 additions & 1 deletion microcosm_postgres/tests/test_employee_data_store.py
Expand Up @@ -8,6 +8,8 @@
is_,
)

from os import environ

from microcosm.api import create_object_graph, load_from_dict
from microcosm_postgres.context import SessionContext, transaction
from microcosm_postgres.tests.fixtures import Company, Employee, EmployeeData
Expand All @@ -19,9 +21,12 @@ def setup(self):
self.loader = load_from_dict(
secret=dict(
postgres=dict(
host="127.0.0.1",
host=environ["EXAMPLE__POSTGRES__HOST"],
),
),
postgres=dict(
host=environ["EXAMPLE__POSTGRES__HOST"],
),
sessionmaker=dict(
engine_routing_strategy="model_engine_routing_strategy",
),
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -2,7 +2,7 @@
from setuptools import find_packages, setup

project = "microcosm-postgres"
version = "1.6.0"
version = "1.6.1"

setup(
name=project,
Expand Down