Skip to content

Commit

Permalink
add github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
claudezss committed Jun 15, 2023
1 parent f69730a commit bf359e1
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 5 deletions.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -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"
62 changes: 62 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -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
29 changes: 29 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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 }}
8 changes: 4 additions & 4 deletions pyohm/network/assets/model.py
Original file line number Diff line number Diff line change
@@ -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):
"""
Expand All @@ -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")

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Empty file added tests/__init__.py
Empty file.
2 changes: 2 additions & 0 deletions tests/test_mock.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def test_mock():
assert True

0 comments on commit bf359e1

Please sign in to comment.