Skip to content
This repository was archived by the owner on Jun 29, 2021. It is now read-only.

Commit 4273b5c

Browse files
authored
feat(tests) Add flake8 linting for python code (#91)
Fixes #8
1 parent a67d22c commit 4273b5c

6 files changed

Lines changed: 35 additions & 9 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# python virtual environments for testing
2+
venv

.travis.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
language: go
2-
go:
3-
- 1.5.1
1+
language: python
2+
python:
3+
- "2.7"
44
branches:
55
only:
66
- master
77
services:
88
- docker
99
sudo: required
10+
install:
11+
- pip install -r rootfs/dev_requirements.txt
1012
script:
11-
- make docker-build
13+
- make test docker-build

Makefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,16 @@ docker-build:
99
docker build --rm -t ${IMAGE} rootfs
1010
docker tag ${IMAGE} ${MUTABLE_IMAGE}
1111

12-
test:
12+
setup-venv:
13+
@if [ ! -d venv ]; then pyvenv venv && source venv/bin/activate; fi
14+
pip install --disable-pip-version-check -q -r rootfs/dev_requirements.txt
15+
16+
test: test-style test-functional
17+
18+
test-style:
19+
cd rootfs && flake8 --show-pep8 --show-source --config=setup.cfg .
20+
21+
test-functional:
1322
@echo "Implement functional tests in _tests directory"
1423

1524
.PHONY: all build docker-compile kube-up kube-down deploy

rootfs/deploy.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ def log(msg):
3737

3838

3939
def get_registry_name():
40-
hostname = os.getenv('DEIS_REGISTRY_HOSTNAME', "").replace("https://", "").replace("http://", "")
40+
hostname = os.getenv('DEIS_REGISTRY_HOSTNAME', "")
41+
hostname = hostname.replace("https://", "").replace("http://", "")
4142
if regsitryLocation == "off-cluster":
4243
organization = os.getenv('DEIS_REGISTRY_ORGANIZATION')
4344
regName = ""
@@ -52,9 +53,9 @@ def get_registry_name():
5253
elif regsitryLocation == "ecr":
5354
return hostname
5455
elif regsitryLocation == "gcr":
55-
return hostname+"/"+os.getenv('DEIS_REGISTRY_GCS_PROJ_ID')
56+
return hostname + "/" + os.getenv('DEIS_REGISTRY_GCS_PROJ_ID')
5657
else:
57-
return os.getenv("DEIS_REGISTRY_SERVICE_HOST") + ":" + os.getenv("DEIS_REGISTRY_SERVICE_PORT")
58+
return os.getenv("DEIS_REGISTRY_SERVICE_HOST") + ":" + os.getenv("DEIS_REGISTRY_SERVICE_PORT") # noqa: E501
5859

5960

6061
def docker_push(client, repo, tag):
@@ -80,7 +81,13 @@ def download_file(tar_path):
8081
os.putenv('BUCKET_FILE', "/tmp/objectstore/minio/builder-bucket")
8182
elif os.getenv('BUILDER_STORAGE') in ["azure", "swift"]:
8283
os.putenv('CONTAINER_FILE', "/var/run/secrets/deis/objectstore/creds/builder-container")
83-
command = ["objstorage", "--storage-type="+os.getenv('BUILDER_STORAGE'), "download", tar_path, "apptar"]
84+
command = [
85+
"objstorage",
86+
"--storage-type="+os.getenv('BUILDER_STORAGE'),
87+
"download",
88+
tar_path,
89+
"apptar"
90+
]
8491
subprocess.check_call(command)
8592

8693
tar_path = os.getenv('TAR_PATH')

rootfs/dev_requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
flake8==2.5.4
2+

rootfs/setup.cfg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[flake8]
2+
max-line-length = 99
3+
exclude = venv
4+
max-complexity = 12

0 commit comments

Comments
 (0)