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

Commit df4cdb1

Browse files
authored
Merge pull request #40 from 5g-mobility/dev
Merge w/ Main
2 parents 6e63e8c + 9199dfe commit df4cdb1

File tree

244 files changed

+37128
-41
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

244 files changed

+37128
-41
lines changed

.github/workflows/django.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Run Django tests
2+
3+
on:
4+
push:
5+
branches: [ dev, main ]
6+
pull_request:
7+
branches: [ dev, main ]
8+
9+
jobs:
10+
test:
11+
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v2
16+
- name: Set up Python
17+
uses: actions/setup-python@v2
18+
with:
19+
python-version: '3.8'
20+
- name: Create MongoDB container
21+
run: make db-up
22+
- name: Install Django dependencies
23+
run: make install
24+
- name: Make Migrations
25+
run: make migrate
26+
- name: Run tests
27+
run: make test
28+
- name: Install Lint dependencies
29+
run: pip install flake8
30+
- name: Lint with flake8
31+
run: |
32+
# stop the build if there are Python syntax errors or undefined names
33+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude venv
34+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
35+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude venv

.gitignore

Lines changed: 130 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,127 @@
1-
# Byte-compiled / optimized / DLL files
1+
.idea/
2+
3+
# Created by https://www.gitignore.io/api/macos,linux,django,python,pycharm
4+
5+
### Django ###
6+
*.log
7+
*.pot
8+
*.pyc
29
__pycache__/
10+
local_settings.py
11+
db.sqlite3
12+
media
13+
14+
.mapbox_token
15+
16+
# Flower DB
17+
flower/flower
18+
19+
### Linux ###
20+
*~
21+
22+
# temporary files which can be created if a process still has a handle open of a deleted file
23+
.fuse_hidden*
24+
25+
# KDE directory preferences
26+
.directory
27+
28+
# Linux trash folder which might appear on any partition or disk
29+
.Trash-*
30+
31+
# .nfs files are created when an open file is removed but is still being accessed
32+
.nfs*
33+
34+
### macOS ###
35+
*.DS_Store
36+
.AppleDouble
37+
.LSOverride
38+
39+
# Icon must end with two \r
40+
Icon
41+
42+
# Thumbnails
43+
._*
44+
45+
# Files that might appear in the root of a volume
46+
.DocumentRevisions-V100
47+
.fseventsd
48+
.Spotlight-V100
49+
.TemporaryItems
50+
.Trashes
51+
.VolumeIcon.icns
52+
.com.apple.timemachine.donotpresent
53+
54+
# Directories potentially created on remote AFP share
55+
.AppleDB
56+
.AppleDesktop
57+
Network Trash Folder
58+
Temporary Items
59+
.apdisk
60+
61+
### PyCharm ###
62+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
63+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
64+
65+
# User-specific stuff:
66+
.idea/**/workspace.xml
67+
.idea/**/tasks.xml
68+
.idea/dictionaries
69+
70+
# Sensitive or high-churn files:
71+
.idea/**/dataSources/
72+
.idea/**/dataSources.ids
73+
.idea/**/dataSources.xml
74+
.idea/**/dataSources.local.xml
75+
.idea/**/sqlDataSources.xml
76+
.idea/**/dynamic.xml
77+
.idea/**/uiDesigner.xml
78+
79+
# Gradle:
80+
.idea/**/gradle.xml
81+
.idea/**/libraries
82+
83+
# CMake
84+
cmake-build-debug/
85+
86+
# Mongo Explorer plugin:
87+
.idea/**/mongoSettings.xml
88+
89+
## File-based project format:
90+
*.iws
91+
92+
## Plugin-specific files:
93+
94+
# IntelliJ
95+
/out/
96+
97+
# mpeltonen/sbt-idea plugin
98+
.idea_modules/
99+
100+
# JIRA plugin
101+
atlassian-ide-plugin.xml
102+
103+
# Cursive Clojure plugin
104+
.idea/replstate.xml
105+
106+
# Crashlytics plugin (for Android Studio and IntelliJ)
107+
com_crashlytics_export_strings.xml
108+
crashlytics.properties
109+
crashlytics-build.properties
110+
fabric.properties
111+
112+
### PyCharm Patch ###
113+
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
114+
115+
# *.iml
116+
# modules.xml
117+
# .idea/misc.xml
118+
# *.ipr
119+
120+
# Sonarlint plugin
121+
.idea/sonarlint
122+
123+
### Python ###
124+
# Byte-compiled / optimized / DLL files
3125
*.py[cod]
4126
*$py.class
5127

@@ -8,6 +130,7 @@ __pycache__/
8130

9131
# Distribution / packaging
10132
.Python
133+
env/
11134
build/
12135
develop-eggs/
13136
dist/
@@ -20,12 +143,9 @@ parts/
20143
sdist/
21144
var/
22145
wheels/
23-
pip-wheel-metadata/
24-
share/python-wheels/
25146
*.egg-info/
26147
.installed.cfg
27148
*.egg
28-
MANIFEST
29149

30150
# PyInstaller
31151
# Usually these files are written by a python script from a template
@@ -40,26 +160,18 @@ pip-delete-this-directory.txt
40160
# Unit test / coverage reports
41161
htmlcov/
42162
.tox/
43-
.nox/
44163
.coverage
45164
.coverage.*
46165
.cache
47166
nosetests.xml
48167
coverage.xml
49-
*.cover
50-
*.py,cover
168+
*,cover
51169
.hypothesis/
52-
.pytest_cache/
53170

54171
# Translations
55172
*.mo
56-
*.pot
57173

58174
# Django stuff:
59-
*.log
60-
local_settings.py
61-
db.sqlite3
62-
db.sqlite3-journal
63175

64176
# Flask stuff:
65177
instance/
@@ -77,38 +189,22 @@ target/
77189
# Jupyter Notebook
78190
.ipynb_checkpoints
79191

80-
# IPython
81-
profile_default/
82-
ipython_config.py
83-
84192
# pyenv
85193
.python-version
86194

87-
# pipenv
88-
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89-
# However, in case of collaboration, if having platform-specific dependencies or dependencies
90-
# having no cross-platform support, pipenv may install dependencies that don't work, or not
91-
# install all needed dependencies.
92-
#Pipfile.lock
93-
94-
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
95-
__pypackages__/
96-
97-
# Celery stuff
195+
# celery beat schedule file
98196
celerybeat-schedule
99-
celerybeat.pid
100197

101198
# SageMath parsed files
102199
*.sage.py
103200

104-
# Environments
201+
# dotenv
105202
.env
203+
204+
# virtualenv
106205
.venv
107-
env/
108206
venv/
109207
ENV/
110-
env.bak/
111-
venv.bak/
112208

113209
# Spyder project settings
114210
.spyderproject
@@ -120,10 +216,4 @@ venv.bak/
120216
# mkdocs documentation
121217
/site
122218

123-
# mypy
124-
.mypy_cache/
125-
.dmypy.json
126-
dmypy.json
127-
128-
# Pyre type checker
129-
.pyre/
219+
# End of https://www.gitignore.io/api/macos,linux,django,python,pycharm

Dockerfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM python:3.8
2+
ENV PYTHONUNBUFFERED=1
3+
WORKDIR /code
4+
COPY requirements.txt /code/
5+
RUN python -m pip install --upgrade pip
6+
RUN pip install --upgrade -r requirements.txt
7+
RUN apt-get update
8+
RUN apt-get install --yes nginx
9+
RUN apt-get install -y cron && touch /var/log/cron.log
10+
11+
# OSM Client
12+
RUN apt-get update
13+
RUN apt -y install software-properties-common dirmngr apt-transport-https lsb-release ca-certificates
14+
RUN sed -i "/osm-download.etsi.org/d" /etc/apt/sources.list
15+
RUN wget -qO - https://osm-download.etsi.org/repository/osm/debian/ReleaseNINE/OSM%20ETSI%20Release%20Key.gpg | apt-key add -
16+
RUN add-apt-repository -y "deb [arch=amd64] https://osm-download.etsi.org/repository/osm/debian/ReleaseNINE stable devops IM osmclient"
17+
RUN apt-get update
18+
RUN python -m pip install python-magic pyangbind verboselogs
19+
RUN apt-get install -y python3-osmclient
20+
21+
RUN cp -r /usr/lib/python3/dist-packages/osmclient /usr/local/lib/python3.8/site-packages
22+
RUN cp -r /usr/lib/python3/dist-packages/osm_im /usr/local/lib/python3.8/site-packages
23+
RUN pip install pyyaml==5.4.1
24+
RUN pip install pycurl==7.43.0.6
25+
26+
COPY . /code/

Makefile

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
VENV := venv
2+
BIN := $(VENV)/bin
3+
PYTHON := $(BIN)/python
4+
SHELL := /bin/bash
5+
6+
# This ensures make has access to environment variables stored in a file called .env.
7+
# This allows Make to utilize these variables in its commands, for example, the name of my virtual environment, or to pass in $(DBNAME) to psql.
8+
#include .env
9+
10+
.PHONY: help
11+
help: ## Show this help
12+
@egrep -h '\s##\s' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
13+
14+
.PHONY: venv
15+
venv: ## Make a new virtual environment
16+
python3 -m venv $(VENV) && source $(BIN)/activate
17+
18+
.PHONY: install
19+
install: venv ## Make venv and install requirements
20+
$(PYTHON) -m pip install --upgrade pip
21+
$(BIN)/pip install --upgrade -r requirements.txt
22+
23+
.PHONY: freeze
24+
freeze: ## Pin current dependencies
25+
$(BIN)/pip freeze > requirements.txt
26+
27+
.PHONY: migrate
28+
migrate: ## Make and run migrations
29+
$(PYTHON) manage.py makemigrations
30+
$(PYTHON) manage.py migrate
31+
32+
.PHONY: db-up
33+
db-up: ## Pull and start the Docker MongoDB container in the background
34+
cd mongodb && docker-compose up -d
35+
36+
.PHONY: volume-down
37+
volume-down: ## Remove volume of MongoDB Container
38+
docker volume rm mongodb-data
39+
40+
.PHONY: volume-up
41+
volume-up: ## Create volume of MongoDB Container
42+
docker volume create mongodb-data
43+
44+
.PHONY: fixtures
45+
fixtures: ## Load fixtures
46+
$(PYTHON) manage.py loaddata event.json climate.json dailyinflow.json
47+
48+
.PHONY: mqtt-consumer
49+
mqtt-consumer: ## Run MQTT consumer
50+
$(PYTHON) manage.py mqtt_consumer
51+
52+
.PHONY: test
53+
test: ## Run tests
54+
$(PYTHON) manage.py test --verbosity=0 --failfast
55+
56+
.PHONY: test-docker
57+
test-docker: ## Run tests on Docker Container
58+
docker-compose run --service-ports -e DB_USER=admin -e DB_PASSWORD=admin -e DB_AUTH=admin django python manage.py test --verbosity=0 --failfast
59+
60+
.PHONY: run
61+
run: ## Run the Django server
62+
$(PYTHON) manage.py runserver
63+
64+
.PHONY: prod
65+
prod: ## Start all services containers
66+
docker-compose build
67+
docker-compose up -d
68+
69+

0 commit comments

Comments
 (0)