Skip to content

Commit 5e1cf22

Browse files
committed
Github actions for tests
1 parent 757f163 commit 5e1cf22

16 files changed

+87
-173
lines changed

Diff for: .github/workflows/test.yml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Django timescaledb - Test basic project setup
2+
on:
3+
push:
4+
branches: [main]
5+
6+
jobs:
7+
setup-example-project:
8+
runs-on: ubuntu-latest
9+
env:
10+
DB_NAME: test
11+
DB_USER: postgres
12+
DB_PORT: 5433
13+
14+
steps:
15+
- uses: actions/checkout@v1
16+
- name: Set up Python 3.7
17+
uses: actions/setup-python@v1
18+
with:
19+
python-version: 3.7
20+
21+
- name: Checkout code
22+
uses: actions/checkout@v2
23+
24+
- name: Install dependencies
25+
run: |-
26+
cd example
27+
pip install -r requirements.txt
28+
29+
# Start timescaledb
30+
docker run -d --name timescaledb -p 5433:5432 -e POSTGRES_PASSWORD=password -e POSTGRES_DB=test timescale/timescaledb:2.1.1-pg13
31+
32+
# Wait for db to be ready
33+
sleep 4
34+
35+
# Migrate
36+
PYTHONPATH=../ python3 manage.py migrate
37+
38+
- name: Run tests
39+
run: |-
40+
cd example
41+
PYTHONPATH=../ python3 manage.py test
42+
43+
- name: Test alter field
44+
run: |-
45+
cd example
46+
sed -i -e 's/1 day/2 days/g' metrics/models.py
47+
PYTHONPATH=../ python3 manage.py makemigrations
48+
PYTHONPATH=../ python3 manage.py migrate

Diff for: README.md

+10-12
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
# Django timescaledb
22

3-
4-
53
[![PyPI version fury.io](https://badge.fury.io/py/django-timescaledb.svg)](https://pypi.python.org/pypi/django-timescaledb/)
64

7-
8-
5+
![Workflow](https://github.com/schlunsen/django-timescaledb/actions/workflows/test.yml/badge.svg)
96

107
A database backend and tooling for Timescaledb.
118

@@ -55,8 +52,8 @@ TIMESCALE_DB_BACKEND_BASE = "django.contrib.gis.db.backends.postgis"
5552

5653
class TimescaleModel(models.Model):
5754
"""
58-
A helper class for using Timescale within Django, has the TimescaleManager and
59-
TimescaleDateTimeField already present. This is an abstract class it should
55+
A helper class for using Timescale within Django, has the TimescaleManager and
56+
TimescaleDateTimeField already present. This is an abstract class it should
6057
be inheritted by another class for use.
6158
"""
6259
time = TimescaleDateTimeField(interval="1 day")
@@ -75,7 +72,7 @@ from timescale.db.models.models import TimescaleModel
7572

7673
class Metric(TimescaleModel):
7774
temperature = models.FloatField()
78-
75+
7976

8077
```
8178

@@ -93,6 +90,7 @@ class Metric(models.Model):
9390
```
9491

9592
The name of the field is important as Timescale specific feratures require this as a property of their functions.
93+
9694
### Reading Data
9795

9896
"TimescaleDB hypertables are designed to behave in the same manner as PostgreSQL database tables for reading data, using standard SQL commands."
@@ -144,14 +142,14 @@ As such the use of the Django's ORM is perfectally suited to this type of data.
144142
.values('device')
145143
.histogram(field='temperature', min_value=50.0, max_value=55.0, num_of_buckets=10)
146144
.annotate(Count('device')))
147-
145+
148146
# expected output
149147

150148
<TimescaleQuerySet [{'histogram': [0, 0, 0, 87, 93, 125, 99, 59, 0, 0, 0, 0], 'device__count': 463}]>
151149
```
152150

153151
## Contributors
154-
155-
* [Ben Cleary](https://github.com/bencleary)
156-
* [Jonathan Sundqvist](https://github.com/jonathan-s)
157-
* [Harsh Bhikadia](https://github.com/daadu)
152+
- [Rasmus Schlünsen](https://github.com/schlunsen)
153+
- [Ben Cleary](https://github.com/bencleary)
154+
- [Jonathan Sundqvist](https://github.com/jonathan-s)
155+
- [Harsh Bhikadia](https://github.com/daadu)

Diff for: example/iot_example_app/.env

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
DB_DATABASE=sample_app
2-
DB_USERNAME=username_here
3-
DB_PASSWORD=password_here
4-
DB_HOST=127.0.0.1
1+
DB_DATABASE=test
2+
DB_USERNAME=postgres
3+
DB_PASSWORD=password
4+
DB_HOST=127.0.0.1
5+
DB_PORT=5433

Diff for: example/iot_example_app/settings.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@
8686
'NAME': os.getenv('DB_DATABASE'),
8787
'USER': os.getenv('DB_USERNAME'),
8888
'PASSWORD': os.getenv('DB_PASSWORD'),
89-
'HOST': os.getenv('DB_HOST')
89+
'HOST': os.getenv('DB_HOST'),
90+
'PORT': os.getenv('DB_PORT'),
9091
}
9192
}
9293

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Generated by Django 3.2 on 2021-04-20 19:57
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('metrics', '0004_metric_device'),
10+
]
11+
12+
operations = [
13+
migrations.RenameModel(
14+
old_name='SampleTest',
15+
new_name='AnotherMetricFromTimeScaleModel',
16+
),
17+
]

Diff for: example/metrics/models.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ class Metric(models.Model):
1818
timescale = TimescaleManager()
1919

2020

21-
class SampleTest(TimescaleModel):
21+
class AnotherMetricFromTimeScaleModel(TimescaleModel):
2222
value = models.FloatField(default=0.0)

Diff for: example/requirements.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Django
2+
psycopg2
3+
django-extensions
4+
python-dotenv

Diff for: example/timescale/__init__.py

Whitespace-only changes.

Diff for: example/timescale/db/__init__.py

Whitespace-only changes.

Diff for: example/timescale/db/backends/__init__.py

Whitespace-only changes.

Diff for: example/timescale/db/models/__init__.py

Whitespace-only changes.

Diff for: example/timescale/db/models/expressions.py

-69
This file was deleted.

Diff for: example/timescale/db/models/fields.py

-13
This file was deleted.

Diff for: example/timescale/db/models/managers.py

-20
This file was deleted.

Diff for: example/timescale/db/models/models.py

-17
This file was deleted.

Diff for: example/timescale/db/models/querysets.py

-36
This file was deleted.

0 commit comments

Comments
 (0)