Skip to content

Commit

Permalink
Merge pull request #17 from leopepe/v0.3.0
Browse files Browse the repository at this point in the history
v0.3.0

Major release combining v0.2.1 and v0.3.0:

# DONE: v0.3.0
* Removed rx depdenency
* Make module and package name compatible with PEP-8 (rename to goap)

# DONE: v0.2.1
* Test coverage obove 80%
* Refactor Actions and Sensors to receive func: Callable as parameter (no more ShellCommandAction and ObjectAction)
* Add costs to the actions to guarantee a better performance on long action chains.
* Code quality increased to A level on Codacy
* Test coverage increased to 81%
  • Loading branch information
leopepe authored Oct 2, 2021
2 parents 359ee2c + 127cc63 commit 6cc3c35
Show file tree
Hide file tree
Showing 36 changed files with 466 additions and 474 deletions.
2 changes: 1 addition & 1 deletion .release
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.1
0.3.0
20 changes: 0 additions & 20 deletions Goap/__init__.py

This file was deleted.

Empty file removed Goap/utils/aws/actions.py
Empty file.
134 changes: 0 additions & 134 deletions Goap/utils/aws/sensors.py

This file was deleted.

Empty file removed Goap/utils/os/__init__.py
Empty file.
90 changes: 50 additions & 40 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,34 +1,71 @@
.PHONY: all

# the python version must be inline with:
# * poetry, travis, docker
PYTHON_VERSION=3.8.5
PYTHON_MINOR_VERSION=3.8
# docker
REGISTRY_HOST=docker.io
USERNAME=$(USER)
NAME=$(shell basename $(PWD))

BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
IMAGE=$(shell tr '[:upper:]' '[:lower:]' <<< $(NAME))

#
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
VERSION=$(shell poetry version|cut -d" " -f2)

SHELL=/bin/bash

PYTHON_VERSION=3.8.5
PYTHON_MINOR_VERSION=3.8

all: venv install-in-venv test
all: test build

test: unittest test-coverage
test: format lint unittest test-coverage

req:
ifeq ($(shell which pyenv), "pyenv not found")
@echo "Installing pyenv"
curl https://pyenv.run | bash
endif
ifneq ($(shell python --version|cut -d" " -f2), ${PYTHON_VERSION})
@echo "Installing Python version ${PYTHON_VERSION}"
ifeq ("v$(shell pyenv versions|grep ${PYTHON_VERSION}|sed 's/^[[:space:]]*//g')", "v${PYTHON_VERSION}")
@echo "Local python version must be ${PYTHON_VERSION}"
pyenv local ${PYTHON_VERSION}
else
@echo "Python ${PYTHON_VERSION} not in local pyenv versions. Installing python ${PYTHON_VERSION}"
pyenv install ${PYTHON_VERSION}
endif
pyenv local ${PYTHON_VERSION}
pip install poetry virtualenv
endif
endif

venv: req
poetry install

install:
poetry run python setup.py install

format: venv
poetry run autopep8 --in-place --aggressive --aggressive --aggressive --recursive goap/

lint: format
poetry run flake8 goap/

install-in-venv: venv install
poetry run python setup.py install

unittest: install-in-venv
@echo "Running unit tests"
poetry run pytest -v -s tests/

test-coverage: venv
poetry run coverage run --source=goap/ setup.py test

build:
poetry build

docker-build:
docker build -t goapy:$(shell poetry version|cut -d" " -f2) .

.PHONY: version
version:
@poetry version|cut -d" " -f2

patch:
poetry version patch
Expand All @@ -42,11 +79,9 @@ major:
poetry version major
poetry version|cut -d" " -f2 > .release

.PHONY: version
version:
@poetry version|cut -d" " -f2

release-patch: paatch tag
release-minor: minor tag
release-major: major tag

tag: TAG=$(shell cat .release)
tag: check-status
Expand All @@ -60,31 +95,6 @@ tag: check-status
check-status:
test -n "$(git status -s .)" || (echo "ERROR: there are still outstanding changes" >&2 && exit 1) ;

venv: req
poetry install

install:
python setup.py install

format: venv
autopep8 --in-place --aggressive --aggressive --aggressive --recursive Goap/

install-in-venv: venv install
python setup.py install

unittest: install-in-venv
@echo "Running unit tests"
pytest -v -s tests/

install-coveralls: venv install-in-venv
pip install coveralls

test-coverage: install-coveralls
coverage run --source=Goap/ setup.py test

docker-build:
docker build -t goapy:$(shell poetry version|cut -d" " -f2) .

clean-venv:
rm -rf .venv/

Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# GOAPy
[![Build Status](https://travis-ci.com/leopepe/GOApy.svg?branch=master)](https://travis-ci.com/leopepe/GOApy) [![Coverage Status](https://coveralls.io/repos/github/leopepe/GOApy/badge.svg?branch=master)](https://coveralls.io/github/leopepe/GOApy?branch=master) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/41a49ddaaf54400d9dd3d08f7bb1852a)](https://www.codacy.com/manual/lpepefreitas/GOApy?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=leopepe/GOApy&amp;utm_campaign=Badge_Grade) [![PyPI version](https://badge.fury.io/py/Goap.svg)](https://badge.fury.io/py/Goap) [![Python Formater](https://github.com/leopepe/GOApy/actions/workflows/autopep8.yml/badge.svg?branch=master)](https://github.com/leopepe/GOApy/actions/workflows/autopep8.yml)

**Version**: 0.2.1
**Version**: 0.3.0

![GOAPy](docs/_static/rdaneelolivaw.jpg "Oh my god, it's full of stars!")

Expand All @@ -23,10 +23,10 @@ To perform the search the planner sets a graph using the possible world states a
From the AutomatonController class perspective the usage and interaction should be:

```python
from Goap.utils.os.ShellCommand import ShellCommand
from Goap.Action import Actions
from Goap.Sensor import Sensors
from Goap.Automaton import AutomatonController
from goap.utils.os.shell_command import ShellCommand
from goap.Action import Actions
from goap.Sensor import Sensors
from goap.Automaton import AutomatonController


def setup_sensors():
Expand Down
4 changes: 4 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ NOTES:
The automatons need to be reactive: Change of states needs to trigger a plan
The automatons need to communicate to each other and combine plans

# DONE: v0.3.0
* Removed rx depdenency
* Make module and package name compatible with PEP-8 (rename to goap)

# DONE: v0.2.1
* Test coverage obove 80%
* Refactor Actions and Sensors to receive func: Callable as parameter (no more ShellCommandAction and ObjectAction)
Expand Down
6 changes: 3 additions & 3 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ Based on the state of the directory the automaton would make the decision on wh
### Code

```python
from Goap.Action import Actions
from Goap.Sensor import Sensors
from Goap.Automaton import AutomatonController
from goap.Action import Actions
from goap.Sensor import Sensors
from goap.Automaton import AutomatonController


def setup_sensors():
Expand Down
12 changes: 6 additions & 6 deletions examples/directory_handler/directory_handler.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from Goap.utils.os.ShellCommand import ShellCommand
from Goap.Action import Actions
from Goap.Sensor import Sensors
from Goap.Automaton import AutomatonController
from goap.utils.os.shell_command import ShellCommand
from goap.Action import Actions
from goap.Sensor import Sensors
from goap.Automaton import AutomatonController


def setup_sensors():
Expand Down Expand Up @@ -33,7 +33,7 @@ def setup_actions():
actions = Actions()
actions.add(
name='CreateTmpDir',
pre_conditions={
conditions={
'tmp_dir_state': 'not_exist',
'tmp_dir_content': 'token_not_found'},
effects={
Expand All @@ -42,7 +42,7 @@ def setup_actions():
func=mkdir)
actions.add(
name='CreateToken',
pre_conditions={
conditions={
'tmp_dir_state': 'exist',
'tmp_dir_content': 'token_not_found'},
effects={
Expand Down
10 changes: 5 additions & 5 deletions examples/vuln_scanner/macos_vuln_scanner.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from Goap.utils.os.ShellCommand import ShellCommand
from Goap.Action import Actions
from Goap.Sensor import Sensors
from Goap.Automaton import AutomatonController
from goap.utils.os.shell_command import ShellCommand
from goap.Action import Actions
from goap.Sensor import Sensors
from goap.Automaton import AutomatonController


TARGET_FILE_PATH = '/tmp/target_hosts.txt'
Expand Down Expand Up @@ -56,7 +56,7 @@ def setup_actions() -> Actions:
actions = Actions()
actions.add(
name="scan_http_hosts",
pre_conditions={},
conditions={},
effects={},
func=scan_http_hosts,
cost=0.2
Expand Down
Loading

0 comments on commit 6cc3c35

Please sign in to comment.