Skip to content

Commit

Permalink
Merge pull request #282 from NREL/develop
Browse files Browse the repository at this point in the history
beta release
  • Loading branch information
MatthewSteen committed Sep 15, 2023
2 parents 9819194 + a819b1c commit 87b3862
Show file tree
Hide file tree
Showing 146 changed files with 10,521 additions and 45,988 deletions.
4 changes: 4 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
POSTGRES_DB=buildingmotif
POSTGRES_USER=buildingmotif
POSTGRES_PASSWORD=password
DB_URI="postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}"
3 changes: 3 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
max-line-length = 88
extend-ignore = E203, E501
100 changes: 64 additions & 36 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,49 +7,77 @@ on:
- main
push:
branches:
- develop
- main
release:

jobs:

build:
name: build distribution for Python
# deploy docs for develop and main branches
deploy-docs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10']
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- uses: snok/install-poetry@v1

- name: build
run: poetry build
# setup, checkout pull_request.head.ref for repo-vis
- name: checkout
uses: actions/checkout@v3
with:
ref: ${{github.event.pull_request.head.ref}}
- name: setup-python
uses: actions/setup-python@v3
# # update repo visualization for docs
# - name: repo-visualizer
# uses: githubocto/[email protected]
# with:
# output_file: docs/reference/apidoc/code_visualization.svg
# excluded_paths: ".github"
# commit_message: "repo-visualizer [skip actions]"
# install project, which is required for autodoc of code
- name: install buildingmotif
run: pip install .
# install jupyter-book, which for some reason isn't available with poetry install
- name: install jupyter book
run: pip install jupyter-book
# build docs, which are deployed by repo settings
- name: build docs
run: |
jupyter-book config sphinx ./docs/
sphinx-build ./docs/ docs/_build/html -b html
# TODO can we use an official GitHub Action? https://github.com/actions/deploy-pages
- name: deploy docs
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/_build/html

publish:
name: publish distribution
needs: build
# deploy distribution if a new release and tag are created
deploy-dist:
needs: deploy-docs
if: startsWith(github.ref, 'refs/tags')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: snok/install-poetry@v1

- name: build
run: poetry build

- name: publish distribution 📦 to Test PyPI
if: ${{ github.base_ref == 'main' }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
skip_existing: true

- name: publish distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
# setup
- name: checkout
uses: actions/checkout@v3
- name: setup-python
uses: actions/setup-python@v3
# install poetry and build dist
- name: install-poetry
uses: snok/install-poetry@v1
with:
version: 1.4.0
virtualenvs-in-project: false
virtualenvs-path: ~/.virtualenvs
- name: build dist
run: poetry build
- name: publish distribution to Test PyPI
id: test-pypi
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
skip_existing: true
- name: publish distribution to PyPI
if: steps.test-pypi.outcome == 'success'
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
74 changes: 74 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: continuous integration

on:
push

jobs:

styling:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- name: setup-python
uses: actions/setup-python@v3
- name: install-poetry
uses: snok/install-poetry@v1
with:
version: 1.4.0
virtualenvs-in-project: false
virtualenvs-path: ~/.virtualenvs
- name: poetry install
run: poetry install --all-extras
- name: run isort and black
run: |
poetry run isort . --check
poetry run black . --check
testing:
needs: styling
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10']
steps:
- name: checkout
uses: actions/checkout@v3
- name: setup-python
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: install-poetry
uses: snok/install-poetry@v1
with:
version: 1.4.0
virtualenvs-in-project: false
virtualenvs-path: ~/.virtualenvs
- name: poetry install
run: poetry install --all-extras
- name: lint
run: poetry run flake8 buildingmotif
- name: type check
run: poetry run mypy
- name: unit tests
run: poetry run pytest tests/unit --cov=./ --cov-report=xml
- name: integration tests
run: poetry run pytest tests/integration
- name: bacnet tests
run: |
cd tests/integration/fixtures/bacnet
docker compose build device buildingmotif
docker compose run -d device
docker compose run buildingmotif poetry run pytest -m bacnet
docker compose down
- name: build tests
run: poetry build

coverage:
needs: testing
runs-on: ubuntu-latest
steps:
- uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
46 changes: 0 additions & 46 deletions .github/workflows/docs.yml

This file was deleted.

69 changes: 0 additions & 69 deletions .github/workflows/push.yml

This file was deleted.

23 changes: 0 additions & 23 deletions .github/workflows/repo-vis.yml

This file was deleted.

1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ docs/reference/apidoc/_autosummary


# project
configs.py
buildingmotif-app/node_modules/
**/BuildingMOTIF.log
*.db
19 changes: 11 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
repos:
- repo: https://github.com/gvanderest/pylama-pre-commit
rev: 0.1.2
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: pylama
- id: isort
entry: poetry run isort
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
entry: black --check
- repo: https://github.com/pycqa/isort
rev: 5.10.1
entry: poetry run black
- repo: https://github.com/pycqa/flake8
rev: 5.0.0
hooks:
- id: isort
entry: isort --check
- id: flake8
entry: poetry run flake8 buildingmotif
# can't poetry run becuase not present in repository https://github.com/pre-commit/mirrors-mypy
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.931
hooks:
- id: mypy
args: ["--install-types", "--non-interactive", "--ignore-missing-imports"]
additional_dependencies: [sqlalchemy2-stubs <= 0.0.2a20, SQLAlchemy <= 1.4]
exclude: docs/conf.py
Loading

0 comments on commit 87b3862

Please sign in to comment.