Skip to content

Commit 6459026

Browse files
committed
Add CircleCI configuration
1 parent 6b6902d commit 6459026

File tree

4 files changed

+106
-1
lines changed

4 files changed

+106
-1
lines changed

.circleci/config.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
version: 2
2+
workflows:
3+
version: 2
4+
test:
5+
jobs:
6+
- test-py37
7+
- test-py36
8+
- test-py35
9+
- pre-commit
10+
jobs:
11+
test-py37: &test-template
12+
docker:
13+
- image: circleci/python:3.7
14+
- &test-template-pg
15+
image: postgres:latest
16+
name: pg
17+
environment:
18+
POSTGRES_USER: user
19+
POSTGRES_PASSWORD: pass
20+
POSTGRES_DB: postgres
21+
- &test-template-redis
22+
image: redis:latest
23+
environment: &test-template-env
24+
PY_FACTOR: py37
25+
PG_HOST: pg
26+
PG_USER: user
27+
PG_PASSWORD: pass
28+
steps:
29+
- checkout
30+
- restore_cache:
31+
keys:
32+
- v1-dependencies-{{ checksum "pyproject.lock" }}-{{ checksum "tox.ini" }}
33+
- v1-dependencies-
34+
- run:
35+
name: Installing top-level dependencies
36+
command: |
37+
export PATH=~/.local/bin:$PATH
38+
pip install --user tox poetry
39+
- run:
40+
name: Waiting for Postgres to start up
41+
command: |
42+
for i in `seq 1 60`;
43+
do
44+
nc -z $PG_HOST 5432 && echo Success && exit 0
45+
echo -n .
46+
sleep 1
47+
done
48+
echo Failed waiting for Postgres && exit 1
49+
- run:
50+
name: Running tests
51+
command: |
52+
export PATH=~/.local/bin:$PATH
53+
export TOXENV=$(tox --listenvs | grep "^${PY_FACTOR}-" | tr '\n' ',')
54+
tox
55+
- save_cache:
56+
paths:
57+
- ~/.local
58+
- ./.tox
59+
key: v1-dependencies-{{ checksum "pyproject.lock" }}-{{ checksum "tox.ini" }}
60+
test-py36:
61+
<<: *test-template
62+
docker:
63+
- image: circleci/python:3.6
64+
- *test-template-pg
65+
- *test-template-redis
66+
environment:
67+
<<: *test-template-env
68+
PY_FACTOR: py36
69+
test-py35:
70+
<<: *test-template
71+
docker:
72+
- image: circleci/python:3.5
73+
- *test-template-pg
74+
- *test-template-redis
75+
environment:
76+
<<: *test-template-env
77+
PY_FACTOR: py35
78+
pre-commit:
79+
docker:
80+
- image: circleci/python:3.7
81+
steps:
82+
- checkout
83+
- restore_cache:
84+
keys:
85+
- v1-pre-commit
86+
- run:
87+
name: install pre-commit
88+
command: pip install --user pre-commit
89+
- run:
90+
name: run pre-commit
91+
command: ~/.local/bin/pre-commit run --all-files
92+
- save_cache:
93+
paths:
94+
- ~/.local
95+
- ~/.cache/pre-commit
96+
key: v1-pre-commit

testproject/settings.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,13 @@
7373

7474
# Database
7575
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
76-
7776
DATABASES = {
7877
"default": {
7978
"ENGINE": "django.db.backends.postgresql_psycopg2",
8079
"NAME": "django-pgtree-test",
80+
"HOST": os.environ.get("PG_HOST", ""),
81+
"USER": os.environ.get("PG_USER", ""),
82+
"PASSWORD": os.environ.get("PG_PASSWORD", ""),
8183
}
8284
}
8385

testproject/testapp/migrations/0001_initial.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ class Migration(migrations.Migration):
1212
dependencies = []
1313

1414
operations = [
15+
migrations.RunSQL(
16+
"CREATE EXTENSION IF NOT EXISTS ltree", migrations.RunSQL.noop
17+
),
1518
migrations.CreateModel(
1619
name="TestModel",
1720
fields=[

tox.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ deps=
1414
psycopg2-binary
1515
skip_install=true
1616
whitelist_externals=sh
17+
passenv=
18+
PG_HOST
19+
PG_USER
20+
PG_PASSWORD
1721
commands=
1822
sh -c "rm -f dist/*.whl && poetry build -f wheel && pip install dist/*.whl"
1923
pytest {posargs}

0 commit comments

Comments
 (0)