Skip to content

Commit

Permalink
Merge pull request #5 from bonicim/update-tests
Browse files Browse the repository at this point in the history
Add integration tests; rename workflows
  • Loading branch information
shwethanidd authored Nov 22, 2022
2 parents afb86b8 + 59d014b commit 79b6514
Show file tree
Hide file tree
Showing 10 changed files with 227 additions and 111 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/auto-assign-project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Add bugs to bugs project

on:
issues:
types:
- opened

jobs:
add-to-project:
name: Add issue to project
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
# You can target a repository in a different organization
# to the issue
project-url: https://github.com/orgs/eclipse-volttron/projects/3
# project-url: https://github.com/orgs/<orgName>/projects/<projectNumber>
# github-token: ${{ secrets.ADD_TO_PROJECT_PAT }}
github-token: ${{ secrets.AUTO_PROJECT_PAT }}
# labeled: bug, needs-triage
# label-operator: OR
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:

strategy:
matrix:
os: [ubuntu-20.04, ubuntu-22.04]
os: [ubuntu-22.04]
python: ['3.8', '3.9', '3.10']

runs-on: ${{ matrix.os }}
Expand Down
10 changes: 0 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,3 @@ repos:
entry: yapf
language: python
types: [python]


- repo: local
hooks:
- id: pytest
name: Check pytest unit tests pass
entry: poetry run pytest
pass_filenames: false
language: system
types: [python]
124 changes: 34 additions & 90 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
# volttron-lib-fake-driver

![Passing?](https://github.com/VOLTTRON/volttron-lib-fake-driver/actions/workflows/run_tests.yml/badge.svg)
![Passing?](https://github.com/VOLTTRON/volttron-lib-fake-driver/actions/workflows/run-tests.yml/badge.svg)
[![pypi version](https://img.shields.io/pypi/v/volttron-lib-fake-driver.svg)](https://pypi.org/project/volttron-lib-fake-driver/)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

This project contains Drivers supported and maintained by the Volttron team.

# Prerequisites

* Python 3.8
* Poetry 1.2.2

## Python

Expand All @@ -33,111 +31,57 @@ pyenv global system 3.8.10
```
</details>


## Poetry

This project uses `poetry` to install and manage dependencies. To install poetry,
follow these [instructions](https://python-poetry.org/docs/master/#installation).

# Installation

With `pip`:
Create and activate a virtual environment.

```shell
python3.8 -m pip install volttron-lib-fake-driver

# Develop mode
python3.8 -m pip install --editable volttron-lib-fake-driver
python -m venv env
source env/bin/activate
```

# Development

## Environment

Set the environment to be in your project directory:

```poetry config virtualenvs.in-project true```

If you want to install all your dependencies, including dependencies to help with developing your agent, run this command:

```poetry install```

If you want to install only the dependencies needed to run your agent, run this command:

```poetry install --no-dev```

Activate the virtual environment:
Install volttron and start the platform.

```shell
# using Poetry
poetry shell
pip install volttron

# using 'source' command
source "$(poetry env info --path)/bin/activate"
# Start platform with output going to volttron.log
volttron -vv -l volttron.log &
```

## Source Control

1. To use git to manage version control, create a new git repository in your local agent project.

```git init```

2. Then create a new repo in your Github or Gitlab account. Copy the URL that points to that new repo in
your Github or Gitlab account. This will be known as our 'remote'.

3. Add the remote (i.e. the new repo URL from your Github or Gitlab account) to your local repository. Run the following command:

```git remote add origin <my github/gitlab URL>```

When you push to your repo, note that the default branch is called 'main'.

Install the library. You have two options. You can install this library using the version on PyPi:

## Optional Configurations

### Precommit

Note: Ensure that you have created the virtual environment using Poetry

Install pre-commit hooks:

```poetry run pre-commit install```

To run pre-commit on all your files, run this command:

```poetry run pre-commit run --all-files```

If you have precommit installed and you want to ignore running the commit hooks
every time you run a commit, include the `--no-verify` flag in your commit. The following
is an example:

```git commit -m "Some message" --no-verify```


# Publishing to PyPi
```shell
pip install volttron-lib-fake-driver
```

Publishing your Driver module to PyPi is automated through the continuous integration workflow provided in `~/.github/workflows/publish_to_pypi.yml`.
You can update that Github Workflow with your credentials to ensure that publishing to PyPi will succeed. The default behavior of
that workflow is to publish to PyPi when a release has been published. If you want to change this behavior, you can modify the
workflow to publish to PyPi based on whatever desired event; see [Github Workflows docs](https://docs.github.com/en/actions/using-workflows/triggering-a-workflow)
on how to change the events that trigger a workflow.
Or you can install the local version of this library from this repo:

```shell
pip install -e .
```

# Documentation
# Development

To build the docs, navigate to the 'docs' directory and build the documentation:
Please see the following for contributing guidelines [contributing](https://github.com/eclipse-volttron/volttron-core/blob/develop/CONTRIBUTING.md).

```shell
cd docs
make html
```
Please see the following helpful guide about [developing modular VOLTTRON agents](https://github.com/eclipse-volttron/volttron-core/blob/develop/DEVELOPING_ON_MODULAR.md)

After the documentation is built, view the documentation in html form in your browser.
The html files will be located in `~<path to project directory>/docs/build/html`.

**PROTIP: To open the landing page of your documentation directly from the command line, run the following command:**
# Disclaimer Notice

```shell
open <path to project directory>/docs/build/html/index.html
```
This material was prepared as an account of work sponsored by an agency of the
United States Government. Neither the United States Government nor the United
States Department of Energy, nor Battelle, nor any of their employees, nor any
jurisdiction or organization that has cooperated in the development of these
materials, makes any warranty, express or implied, or assumes any legal
liability or responsibility for the accuracy, completeness, or usefulness or any
information, apparatus, product, software, or process disclosed, or represents
that its use would not infringe privately owned rights.

This will open the documentation landing page in your default browsert (e.g. Chrome, Firefox).
Reference herein to any specific commercial product, process, or service by
trade name, trademark, manufacturer, or otherwise does not necessarily
constitute or imply its endorsement, recommendation, or favoring by the United
States Government or any agency thereof, or Battelle Memorial Institute. The
views and opinions of authors expressed herein do not necessarily state or
reflect those of the United States Government or any agency thereof.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ classifiers = [

[tool.poetry.dependencies]
python = ">=3.8,<4.0"
volttron-lib-base-driver = "^0.1.1a0"
volttron-lib-base-driver = "^0.1.1a3"

[tool.poetry.group.dev.dependencies]
volttron-testing = "^0.3.1a7"
volttron-testing = "^0.3.1a9"
pytest = "^6.2.5"
pytest-cov = "^3.0.0"
mock = "^4.0.3"
Expand Down
46 changes: 43 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,47 @@
# -*- coding: utf-8 -*- {{{
# vim: set fenc=utf-8 ft=python sw=4 ts=4 sts=4 et:
#
# Copyright 2020, Battelle Memorial Institute.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# This material was prepared as an account of work sponsored by an agency of
# the United States Government. Neither the United States Government nor the
# United States Department of Energy, nor Battelle, nor any of their
# employees, nor any jurisdiction or organization that has cooperated in the
# development of these materials, makes any warranty, express or
# implied, or assumes any legal liability or responsibility for the accuracy,
# completeness, or usefulness or any information, apparatus, product,
# software, or process disclosed, or represents that its use would not infringe
# privately owned rights. Reference herein to any specific commercial product,
# process, or service by trade name, trademark, manufacturer, or otherwise
# does not necessarily constitute or imply its endorsement, recommendation, or
# favoring by the United States Government or any agency thereof, or
# Battelle Memorial Institute. The views and opinions of authors expressed
# herein do not necessarily state or reflect those of the
# United States Government or any agency thereof.
#
# PACIFIC NORTHWEST NATIONAL LABORATORY operated by
# BATTELLE for the UNITED STATES DEPARTMENT OF ENERGY
# under Contract DE-AC05-76RL01830
# }}}
"""Configuration for the pytest test suite."""

import sys
from pathlib import Path

TESTS_DIR = Path(__file__).parent
TMP_DIR = TESTS_DIR / "tmp"
FIXTURES_DIR = TESTS_DIR / "fixtures"
p = Path(__file__)
if p.parent.parent.parent.resolve().as_posix() not in sys.path:
sys.path.insert(0, p.parent.parent.resolve().as_posix())

from volttrontesting.fixtures.volttron_platform_fixtures import *
Loading

0 comments on commit 79b6514

Please sign in to comment.