Skip to content

Commit

Permalink
[Resolve #622] Add official Python 3.7 support
Browse files Browse the repository at this point in the history
Note that this commit suppressed DeprecationWarnings due to dependencies
which have not yet updated their use of collections.abc.

Add pyenv to CI: support multiple Python versions

* Bump CI Docker image version (to 0.4)
* Add pyenv to Docker image
* Support py27, py36, py37

Fix CI interaction with moto 1.3.7. Works around getmoto/moto#1924 by
ensuring garbage defaults are set in the environment.

Update setup.py for Python3.7 support

Add package requirements for testing on python3.7/win
  • Loading branch information
Brendan Devenney authored and ngfgrant committed Jun 13, 2019
1 parent cc0052f commit d140c51
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 30 deletions.
26 changes: 20 additions & 6 deletions .circleci/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM library/alpine:3.6
FROM alpine:3.7

RUN apk add --update \
RUN apk add --update --no-cache \
patch \
git \
openssh \
Expand All @@ -18,17 +18,31 @@ RUN apk add --update \
ruby \
ruby-dev \
ruby-bundler \
ruby-json
ruby-json \
readline-dev \
openssl-dev \
sqlite-dev \
zlib-dev

RUN pip install virtualenv \
&& pip install tox \
RUN pip install --no-cache-dir virtualenv \
&& pip install --no-cache-dir tox \
&& addgroup -g 3434 circleci \
&& adduser -D -u 3434 -G circleci -s /bin/bash circleci

USER circleci

WORKDIR /home/circleci

ARG PYENV_HOME=/home/circleci/.pyenv

ENV LANG=C.UTF-8 \
HOME=/home/circleci
HOME=/home/circleci \
PATH=$PYENV_HOME/shims:$PYENV_HOME/bin:$PATH

RUN git clone --depth 1 https://github.com/pyenv/pyenv.git $PYENV_HOME \
&& rm -rfv $PYENV_HOME/.git \
&& pyenv install 2.7-dev \
&& pyenv install 3.6-dev \
&& pyenv install 3.7-dev

CMD ["/bin/sh"]
38 changes: 22 additions & 16 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
aliases:
- &docs-job
docker:
- image: cloudreach/sceptre-circleci:0.3
- image: cloudreach/sceptre-circleci:0.4
environment:
REPOSITORY_PATH: "/home/circleci/docs"
DEPLOYMENT_GIT_SSH: "[email protected]:Sceptre/docs.git"
REPOSITORY_PATH: '/home/circleci/docs'
DEPLOYMENT_GIT_SSH: '[email protected]:Sceptre/docs.git'
steps:
- add_ssh_keys:
fingerprints:
- "80:24:c0:40:28:36:f1:80:7f:fd:15:c3:09:cf:86:fc"
- '80:24:c0:40:28:36:f1:80:7f:fd:15:c3:09:cf:86:fc'
- attach_workspace:
at: /home/circleci
- run:
Expand All @@ -24,22 +24,26 @@ version: 2
jobs:
build:
docker:
- image: cloudreach/sceptre-circleci:0.3
- image: cloudreach/sceptre-circleci:0.4
steps:
- checkout
- run:
name: 'Creating Virtualenv'
command: virtualenv venv
- restore_cache:
key: sceptre-{{ .Environment.CACHE_VERSION }}-requirements-{{ arch }}-{{ checksum "requirements.txt" }}
key:
sceptre-{{ .Environment.CACHE_VERSION }}-requirements-{{ arch }}-{{
checksum "requirements.txt" }}
- run:
name: 'Installing Requirements'
command: |
. ./venv/bin/activate
pip install -r requirements.txt
pip install awscli
- save_cache:
key: sceptre-{{ .Environment.CACHE_VERSION }}-requirements-{{ arch }}-{{ checksum "requirements.txt" }}
key:
sceptre-{{ .Environment.CACHE_VERSION }}-requirements-{{ arch }}-{{
checksum "requirements.txt" }}
paths:
- venv
- run:
Expand All @@ -53,12 +57,14 @@ jobs:
- project
lint-and-unit-tests:
docker:
- image: cloudreach/sceptre-circleci:0.3
- image: cloudreach/sceptre-circleci:0.4
steps:
- attach_workspace:
at: /home/circleci
- restore_cache:
key: sceptre-{{ .Environment.CACHE_VERSION }}-tox-requirements-{{ arch }}-{{ checksum "requirements.txt" }}-{{ checksum "tox.ini" }}
key:
sceptre-{{ .Environment.CACHE_VERSION }}-tox-requirements-{{ arch
}}-{{ checksum "requirements.txt" }}-{{ checksum "tox.ini" }}
- run:
name: 'Linting'
command: |
Expand All @@ -77,13 +83,15 @@ jobs:
- store_artifacts:
path: build/pytest
- save_cache:
key: sceptre-{{ .Environment.CACHE_VERSION }}-tox-requirements-{{ arch }}-{{ checksum "requirements.txt" }}-{{ checksum "tox.ini" }}
key:
sceptre-{{ .Environment.CACHE_VERSION }}-tox-requirements-{{ arch
}}-{{ checksum "requirements.txt" }}-{{ checksum "tox.ini" }}
paths:
- .tox
integration-tests:
parallelism: 2
docker:
- image: cloudreach/sceptre-circleci:0.3
- image: cloudreach/sceptre-circleci:0.4
environment:
AWS_DEFAULT_REGION: eu-west-1
steps:
Expand All @@ -101,14 +109,12 @@ jobs:
- store_artifacts:
path: build/behave

deploy-docs-branch:
*docs-job
deploy-docs-tag:
*docs-job
deploy-docs-branch: *docs-job
deploy-docs-tag: *docs-job

deploy-pypi:
docker:
- image: cloudreach/sceptre-circleci:0.3
- image: cloudreach/sceptre-circleci:0.4
steps:
- attach_workspace:
at: /home/circleci
Expand Down
3 changes: 3 additions & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
2.7-dev
3.6-dev
3.7-dev
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ colorama==0.3.9
coverage==4.4.2
flake8==3.5.0
flake8-per-file-ignores==0.4
freezegun==0.3.9
freezegun==0.3.12
Jinja2>=2.8,<3
mock>=2.0.0,<2.1.0
moto==0.4.31
moto==1.3.8
networkx==2.1
packaging==16.8
pygments==2.2.0
Expand Down
4 changes: 4 additions & 0 deletions sceptre/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-

import logging
import warnings


__author__ = 'Cloudreach'
Expand All @@ -15,4 +16,7 @@ def emit(self, record):
pass


with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)

logging.getLogger('sceptre').addHandler(NullHandler())
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
test_requirements = [
"pytest>=3.2",
"troposphere>=2.0.0",
"moto==0.4.31",
"moto==1.3.8",
"mock==2.0.0",
"behave==1.2.5",
"freezegun==0.3.9"
"freezegun==0.3.12"
]

setup_requirements = [
Expand Down Expand Up @@ -85,6 +85,7 @@
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6"
"Programming Language :: Python :: 3.7"
],
test_suite="tests",
install_requires=install_requirements,
Expand Down
5 changes: 5 additions & 0 deletions tests/test_connection_manager.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-

import os
import pytest
from mock import Mock, patch, sentinel, ANY
from moto import mock_s3
Expand All @@ -22,6 +23,10 @@ def setup_method(self, test_method):
ConnectionManager._clients = {}
ConnectionManager._stack_keys = {}

# Temporary workaround for https://github.com/spulec/moto/issues/1924
os.environ.setdefault("AWS_ACCESS_KEY_ID", "sceptre_test_key_id")
os.environ.setdefault("AWS_SECRET_ACCESS_KEY", "sceptre_test_access_key")

self.connection_manager = ConnectionManager(
region=self.region,
stack_name=self.stack_name,
Expand Down
6 changes: 3 additions & 3 deletions tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest

from os.path import join
from os.path import join, sep

from sceptre.exceptions import PathConversionError
from sceptre.helpers import get_external_stack_name
Expand Down Expand Up @@ -30,11 +30,11 @@ def test_normalise_path_with_double_backslashes_in_path(self):

def test_normalise_path_with_leading_slash(self):
path = normalise_path("/this/is/valid")
assert path == join("/this", "is", "valid")
assert path == join("{}this".format(sep), "is", "valid")

def test_normalise_path_with_leading_backslash(self):
path = normalise_path('\\this\path\is\\valid')
assert path == join("/this", "path", "is", "valid")
assert path == join("{}this".format(sep), "path", "is", "valid")

def test_normalise_path_with_trailing_slash(self):
with pytest.raises(PathConversionError):
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py27,py36
envlist = py27,py36,py37

[testenv]
deps = -rrequirements.txt
Expand Down

0 comments on commit d140c51

Please sign in to comment.