Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
robotastic authored Feb 25, 2024
0 parents commit 0f38988
Show file tree
Hide file tree
Showing 17 changed files with 1,053 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Code Quality Checks
on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
name: Code Quality Checks
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.9.13
- run: pip install --upgrade pip
- run: pip install "black<23" pylint==v3.0.0a3 mypy==v0.991
- run: black --diff --check $(git ls-files '*.py')
- run: pylint --disable=all --enable=unused-import $(git ls-files '*.py')
- run: mypy --allow-untyped-decorators --ignore-missing-imports --no-warn-return-any --allow-subclassing-any --strict $(git ls-files '*.py')
64 changes: 64 additions & 0 deletions .github/workflows/dockerbuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Container Processing

on:
push:
branches: [ "main" ]

jobs:

build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Get tag
id: get_tag
run: |
echo "::set-output name=IMAGE_TAG::$(echo $GITHUB_REF | cut -d / -f 3)"
- name: Set up qemu
uses: docker/setup-qemu-action@v3
with:
platforms: all

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
version: latest

- name: Docker Login
run: echo "${{ secrets.DOCKER_TOKEN }}" | docker login --username "${{ secrets.DOCKER_USERNAME }}" --password-stdin

- name: Get Changes
id: identify
uses: jitterbit/get-changed-files@v1
- run: |
echo ${{ steps.files.output.all }}
- name: Build Images
env:
# Every folder in the repo that has a Dockerfile within it, comma separated
DOCKERFOLDERS: "template"
DOCKERNAMESPACE: ${{ secrets.DOCKER_NAMESPACE }}
PROJECT_NAME: "edgetech"
run: |
IFS=","
read -ra ARR <<< "$DOCKERFOLDERS"
for folder in "${ARR[@]}"
do
IFS="/"
read -ra NAMEFOLDER <<< $folder
SUBNAME=${NAMEFOLDER[0]}
PUBLISHNAME=""
if [ $NAMEFOLDER != $SUBNAME ]; then
PUBLISHNAME=$PROJECT_NAME-$folder-$SUBNAME
else
PUBLISHNAME=$PROJECT_NAME-$folder
fi
echo "Building $folder"
docker buildx build "$folder" --push \
--tag $DOCKERNAMESPACE/$PUBLISHNAME:latest \
--tag $DOCKERNAMESPACE/$PUBLISHNAME:${{ steps.get_tag.outputs.IMAGE_TAG }} \
--platform linux/arm64,linux/amd64
done
55 changes: 55 additions & 0 deletions .github/workflows/releasetag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Release Tagging

on:
release:
types: [ "published" ]

jobs:

tag-remote:

runs-on: ubuntu-latest

steps:
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
version: latest

- name: Docker Login
run: echo "${{ secrets.DOCKER_TOKEN }}" | docker login --username "${{ secrets.DOCKER_USERNAME }}" --password-stdin

- name: Build Images
env:
# Every folder in the repo that has a Dockerfile within it, comma separated
DOCKERFOLDERS: "template"
DOCKERNAMESPACE: ${{ secrets.DOCKER_NAMESPACE }}
PROJECT_NAME: "edgetech"
RELEASENAME: ${{ github.event.release.name }}
run: |
IFS=","
read -ra ARR <<< "$DOCKERFOLDERS"
for folder in "${ARR[@]}"
do
IFS="/"
read -ra NAMEFOLDER <<< $folder
SUBNAME=${NAMEFOLDER[0]}
PUBLISHNAME=""
if [ $NAMEFOLDER != $SUBNAME ]; then
PUBLISHNAME=$PROJECT_NAME-$folder-$SUBNAME
else
PUBLISHNAME=$PROJECT_NAME-$folder
fi
echo "TAGGING..."
echo $PUBLISHNAME
echo $RELEASENAME
docker buildx imagetools create $DOCKERNAMESPACE/$PUBLISHNAME:latest --tag $DOCKERNAMESPACE/$PUBLISHNAME:$RELEASENAME
done
129 changes: 129 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
45 changes: 45 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
## How to Contribute

1. Fork the Project
2. Create your Feature Branch (`git checkout -b dev`)
3. Commit your Changes (`git commit -m 'adding some feature'`)
4. Run (and make sure they pass):
```
black --diff --check *.py
pylint --disable=all --enable=unused-import *.py
mypy --allow-untyped-decorators --ignore-missing-imports --no-warn-return-any --strict --allow-subclassing-any *.py
```
If you do not have them installed, you can install them with `pip install "black<23" pylint==v3.0.0a3 mypy==v0.991`.

5. Push to the Branch (`git push origin dev`)
6. Open a Pull Request

---

## A Few Stylistic Things to Note

**These are in an attempt to enforce conformity of all future commits. Please suggest via Pull Request any that should be added/amended.**

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.

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).

All class attributes should be passed as environment variables through the `docker-compose.yml` file via the `.env` file.

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.

All functions should include docstring comments that generally follow the Google docstring format.

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.

All unused parameters should be denoted with a `_` in front of them as well.

Only specified exceptions should be handled.

Each pubsub module should publish a registration in the constructor and a heartbeat.

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.

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`.
Loading

0 comments on commit 0f38988

Please sign in to comment.