Skip to content

Commit af1f8f4

Browse files
authored
Initial commit
0 parents  commit af1f8f4

17 files changed

+1053
-0
lines changed

.github/workflows/code-quality.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Code Quality Checks
2+
on: [push, pull_request]
3+
4+
jobs:
5+
build:
6+
runs-on: ubuntu-latest
7+
name: Code Quality Checks
8+
steps:
9+
- uses: actions/checkout@v4
10+
- uses: actions/setup-python@v5
11+
with:
12+
python-version: 3.9.13
13+
- run: pip install --upgrade pip
14+
- run: pip install "black<23" pylint==v3.0.0a3 mypy==v0.991
15+
- run: black --diff --check $(git ls-files '*.py')
16+
- run: pylint --disable=all --enable=unused-import $(git ls-files '*.py')
17+
- run: mypy --allow-untyped-decorators --ignore-missing-imports --no-warn-return-any --allow-subclassing-any --strict $(git ls-files '*.py')

.github/workflows/dockerbuild.yml

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Container Processing
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
7+
jobs:
8+
9+
build:
10+
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Get tag
16+
id: get_tag
17+
run: |
18+
echo "::set-output name=IMAGE_TAG::$(echo $GITHUB_REF | cut -d / -f 3)"
19+
20+
- name: Set up qemu
21+
uses: docker/setup-qemu-action@v3
22+
with:
23+
platforms: all
24+
25+
- name: Set up Docker Buildx
26+
id: buildx
27+
uses: docker/setup-buildx-action@v3
28+
with:
29+
version: latest
30+
31+
- name: Docker Login
32+
run: echo "${{ secrets.DOCKER_TOKEN }}" | docker login --username "${{ secrets.DOCKER_USERNAME }}" --password-stdin
33+
34+
- name: Get Changes
35+
id: identify
36+
uses: jitterbit/get-changed-files@v1
37+
- run: |
38+
echo ${{ steps.files.output.all }}
39+
- name: Build Images
40+
env:
41+
# Every folder in the repo that has a Dockerfile within it, comma separated
42+
DOCKERFOLDERS: "template"
43+
DOCKERNAMESPACE: ${{ secrets.DOCKER_NAMESPACE }}
44+
PROJECT_NAME: "edgetech"
45+
run: |
46+
IFS=","
47+
read -ra ARR <<< "$DOCKERFOLDERS"
48+
for folder in "${ARR[@]}"
49+
do
50+
IFS="/"
51+
read -ra NAMEFOLDER <<< $folder
52+
SUBNAME=${NAMEFOLDER[0]}
53+
PUBLISHNAME=""
54+
if [ $NAMEFOLDER != $SUBNAME ]; then
55+
PUBLISHNAME=$PROJECT_NAME-$folder-$SUBNAME
56+
else
57+
PUBLISHNAME=$PROJECT_NAME-$folder
58+
fi
59+
echo "Building $folder"
60+
docker buildx build "$folder" --push \
61+
--tag $DOCKERNAMESPACE/$PUBLISHNAME:latest \
62+
--tag $DOCKERNAMESPACE/$PUBLISHNAME:${{ steps.get_tag.outputs.IMAGE_TAG }} \
63+
--platform linux/arm64,linux/amd64
64+
done

.github/workflows/releasetag.yml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Release Tagging
2+
3+
on:
4+
release:
5+
types: [ "published" ]
6+
7+
jobs:
8+
9+
tag-remote:
10+
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Set up Docker Buildx
15+
id: buildx
16+
uses: docker/setup-buildx-action@v3
17+
with:
18+
version: latest
19+
20+
- name: Docker Login
21+
run: echo "${{ secrets.DOCKER_TOKEN }}" | docker login --username "${{ secrets.DOCKER_USERNAME }}" --password-stdin
22+
23+
- name: Build Images
24+
env:
25+
# Every folder in the repo that has a Dockerfile within it, comma separated
26+
DOCKERFOLDERS: "template"
27+
DOCKERNAMESPACE: ${{ secrets.DOCKER_NAMESPACE }}
28+
PROJECT_NAME: "edgetech"
29+
RELEASENAME: ${{ github.event.release.name }}
30+
run: |
31+
IFS=","
32+
read -ra ARR <<< "$DOCKERFOLDERS"
33+
for folder in "${ARR[@]}"
34+
do
35+
IFS="/"
36+
read -ra NAMEFOLDER <<< $folder
37+
SUBNAME=${NAMEFOLDER[0]}
38+
PUBLISHNAME=""
39+
if [ $NAMEFOLDER != $SUBNAME ]; then
40+
PUBLISHNAME=$PROJECT_NAME-$folder-$SUBNAME
41+
else
42+
PUBLISHNAME=$PROJECT_NAME-$folder
43+
fi
44+
echo "TAGGING..."
45+
echo $PUBLISHNAME
46+
echo $RELEASENAME
47+
docker buildx imagetools create $DOCKERNAMESPACE/$PUBLISHNAME:latest --tag $DOCKERNAMESPACE/$PUBLISHNAME:$RELEASENAME
48+
done
49+
50+
51+
52+
53+
54+
55+

.gitignore

+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
pip-wheel-metadata/
24+
share/python-wheels/
25+
*.egg-info/
26+
.installed.cfg
27+
*.egg
28+
MANIFEST
29+
30+
# PyInstaller
31+
# Usually these files are written by a python script from a template
32+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
33+
*.manifest
34+
*.spec
35+
36+
# Installer logs
37+
pip-log.txt
38+
pip-delete-this-directory.txt
39+
40+
# Unit test / coverage reports
41+
htmlcov/
42+
.tox/
43+
.nox/
44+
.coverage
45+
.coverage.*
46+
.cache
47+
nosetests.xml
48+
coverage.xml
49+
*.cover
50+
*.py,cover
51+
.hypothesis/
52+
.pytest_cache/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
target/
76+
77+
# Jupyter Notebook
78+
.ipynb_checkpoints
79+
80+
# IPython
81+
profile_default/
82+
ipython_config.py
83+
84+
# pyenv
85+
.python-version
86+
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
98+
celerybeat-schedule
99+
celerybeat.pid
100+
101+
# SageMath parsed files
102+
*.sage.py
103+
104+
# Environments
105+
.env
106+
.venv
107+
env/
108+
venv/
109+
ENV/
110+
env.bak/
111+
venv.bak/
112+
113+
# Spyder project settings
114+
.spyderproject
115+
.spyproject
116+
117+
# Rope project settings
118+
.ropeproject
119+
120+
# mkdocs documentation
121+
/site
122+
123+
# mypy
124+
.mypy_cache/
125+
.dmypy.json
126+
dmypy.json
127+
128+
# Pyre type checker
129+
.pyre/

CONTRIBUTING.md

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
## How to Contribute
2+
3+
1. Fork the Project
4+
2. Create your Feature Branch (`git checkout -b dev`)
5+
3. Commit your Changes (`git commit -m 'adding some feature'`)
6+
4. Run (and make sure they pass):
7+
```
8+
black --diff --check *.py
9+
10+
pylint --disable=all --enable=unused-import *.py
11+
12+
mypy --allow-untyped-decorators --ignore-missing-imports --no-warn-return-any --strict --allow-subclassing-any *.py
13+
```
14+
If you do not have them installed, you can install them with `pip install "black<23" pylint==v3.0.0a3 mypy==v0.991`.
15+
16+
5. Push to the Branch (`git push origin dev`)
17+
6. Open a Pull Request
18+
19+
---
20+
21+
## A Few Stylistic Things to Note
22+
23+
**These are in an attempt to enforce conformity of all future commits. Please suggest via Pull Request any that should be added/amended.**
24+
25+
All of the functionality should be encapsulated in the `*_pub_sub.py` file that sits in the `module/` directory (in this case `template`). Within this file, a single child class of `BaseMQTTPubSub` should be defined the encapsulates all of the functionality.
26+
27+
All MQTT client setup and connection should be done using `BaseMQTTPubSub` functionality. If a feature does not exist, please suggest it in that [repository](https://github.com/IQTLabs/edgetech-core).
28+
29+
All class attributes should be passed as environment variables through the `docker-compose.yml` file via the `.env` file.
30+
31+
Typing should be included in all cases. Running `mypy` before pushing should enforce this and you will not be allowed to merge until the code checks have passed.
32+
33+
All functions should include docstring comments that generally follow the Google docstring format.
34+
35+
All functions not meant to be called outside of a class should be denoted with a `_` before the function name. In almost every case, each pubsub should only include one `main()` function meant to be called that encapsulates keeping the main thread alive and sets up the relevant services. The majority of the "work" in a module should be done via callbacks.
36+
37+
All unused parameters should be denoted with a `_` in front of them as well.
38+
39+
Only specified exceptions should be handled.
40+
41+
Each pubsub module should publish a registration in the constructor and a heartbeat.
42+
43+
All recurring tasks that need to happen after an interval of time has elapsed should be done so via the [`schedule`](https://schedule.readthedocs.io/en/stable/) library.
44+
45+
All python dependencies other than `poetry` (which is installed via `pip3`) should be installed using [`poetry`](https://python-poetry.org/). All dependencies should be encapsulated in the `Dockerfile`.

0 commit comments

Comments
 (0)