diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..82f6aff --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "pip" + directory: "/" # Location of package manifests + schedule: + interval: "weekly" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..6a3229f --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,62 @@ + +name: "Heizer CI Tests" + +on: [push] + +jobs: + tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.11 + uses: actions/setup-python@v3 + with: + python-version: "3.11" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -e .[test,dev] + + - name: Lint + run: | + pre-commit install + pre-commit run --all-files + + - name: Test with pytest + run: | + python -m pytest -s tests --cov=heizer --cov-report=xml --junit-xml=report.xml + + build_and_upload_doc: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Set up Python 3.11 + uses: actions/setup-python@v3 + with: + python-version: "3.11" + - name: Build Docs + run: | + sudo apt-get install -y zip gzip tar + python -m pip install --upgrade pip + pip install -e .[doc] + mkdocs build -d doc/ + zip -r doc.zip doc/ + - name: Upload Artifact + uses: actions/upload-artifact@v3 + with: + name: doc_zip + path: doc.zip + retention-days: 5 + - name: deploy + if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) + uses: appleboy/scp-action@master + with: + host: ${{ secrets.SERVER_IP }} + username: "root" + password: ${{ secrets.SERVER_PASS }} + source: "doc/" + target: "/var/www/html/pyohm/" + strip_components: 1 + overwrite: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..429be31 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,29 @@ + +name: "publish release" + +on: + release: + types: [published] + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build + - name: Build package + run: | + echo ${{ github.event.release.tag_name }} > pyohm/VERSION + python -m build + - name: Publish package + uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/pyohm/network/assets/model.py b/pyohm/network/assets/model.py index a83eed7..bbd0383 100644 --- a/pyohm/network/assets/model.py +++ b/pyohm/network/assets/model.py @@ -1,6 +1,8 @@ -from pydantic import BaseModel, Field -from typing import Tuple, Optional import enum +from typing import Optional, Tuple + +from pydantic import BaseModel, Field + class AssetType(enum.Enum): """ @@ -21,9 +23,7 @@ class AssetType(enum.Enum): class Model(BaseModel): - id: str = Field(..., alias="id") name: str = Field(..., alias="name") coordinates: Optional[Tuple[float, float]] = Field(..., alias="coordinates", default=None) asset_type: AssetType = Field(..., alias="asset_type") - diff --git a/pyproject.toml b/pyproject.toml index d2f1fb3..31bf2bd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -67,7 +67,7 @@ profile = "black" line_length = 120 max-line-length=120 exclude =[".git", "__pycache__", "venv", "env", 'docs/*'] -include = ["pyohm/*"] +include = ["pyohm/*", "tests/*"] [tool.mypy] strict=true diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_mock.py b/tests/test_mock.py new file mode 100644 index 0000000..e7c7496 --- /dev/null +++ b/tests/test_mock.py @@ -0,0 +1,2 @@ +def test_mock(): + assert True