Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 21 additions & 17 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,33 @@ on:
jobs:
build:

runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [3.7, 3.8]
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.7, 3.8, 3.9]
include:
- os: ubuntu-latest
test_script: make test
cache_path: ~/.cache/pip
- os: macos-latest
test_script: make test
cache_path: ~/Library/Caches/pip
- os: windows-latest
test_script: .\test.ps1
cache_path: ~\AppData\Local\pip\Cache

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Lint with flake8
run: |
pip install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pip install pytest
pytest
- uses: actions/cache@v2
with:
path: ${{ matrix.cache_path }}
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Lint with pylint and test with pytest
run: ${{ matrix.test_script }}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

# Development Directories
.venv
venv
.pytype
# Build Info
*.egg-info
Expand All @@ -15,3 +16,7 @@ __pycache__

# OS generated files #
.DS_Store

coverage.xml
.coverage
cov_html
2 changes: 1 addition & 1 deletion pylintrc → .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ignore-patterns=
#init-hook=

# Use multiple processes to speed up Pylint.
jobs=1
jobs=4

# List of plugins (as comma separated values of python modules names) to load,
# usually to register additional checkers.
Expand Down
40 changes: 25 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
IMAGE_NAME='Forge'
VERSION=1.0.0
PYTHON=python3.7
PYTHON=python


.DEFAULT: help
Expand All @@ -22,35 +21,46 @@ help:

init:
rm -rf .venv
$(PYTHON) -m pip install virtualenv
pip3 install virtualenv
virtualenv --python=$(PYTHON) --always-copy .venv
( \
. .venv/bin/activate; \
pip3 install -r requirements.txt; \
)

lint:
dev: init
( \
. .venv/bin/activate; \
pylint -j 4 --rcfile=pylintrc forge; \
pip3 install -r dev-requirements.txt; \
pip3 install mypy==0.790; \
)


lint: dev
( \
. .venv/bin/activate; \
$(PYTHON) -m pylint -j 4 -r y forge; \
)

type-check:
( \
. .venv/bin/activate; \
$(PYTHON) -m mypy forge; \
)

build:
( \
$(PYTHON) -m pip install --upgrade setuptools wheel; \
. .venv/bin/activate; \
pip3 install --upgrade setuptools wheel; \
$(PYTHON) setup.py sdist bdist_wheel; \
)

install: build
test: lint type-check
( \
$(PYTHON) -m pip install dist/tele_forge-${VERSION}-py3-none-any.whl; \
)
. .venv/bin/activate; \
$(PYTHON) -m pytest -rf -vvv -x --count 5 --cov=forge --cov-fail-under=80 --cov-report term-missing; \
)

test:
$(PYTHON) -m unittest discover -s forge -p '*_test.py'

clean:
rm -rf forge.egg-info/ build/ dist/ .venv/

type-check:
pytype *.py forge
rm -rf forge.egg-info/ build/ dist/ .venv/ venv/ **/__pycache__/ .pytest_cache/ .coverage
112 changes: 57 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,97 +1,99 @@
# forge
# **forge**

There are many adjunct command line utilities that have been created by many [TeleTracking](https://www.teletracking.com)
employees to assist with their everyday activities.
The goal of this tool is to provide an extensible command line utility that will allow
for anyone to create new plugins for it that will be automatically pulled in by the
base tool when placed in the proper directory.
for anyone to create new plugins accessible

In order for a plugin to be used by the utility, a simple contract must be met and a requirements.txt containing all of the packages required by the plugin must be provided at the root directory of the plugin.
Each primary plugin file must have an execute method that accepts an array of args,
a helptext method that returns a very basic explanation of what the module does,
and a register method that accepts an instance of the app and passes the desired name of
the plugin, the execute method, and the value returned from the helptext method.
---

Example as follows shows what would represent the interface to a simple echo example.
## Pre-Requisites

```
def execute(args):
print(args[0])
- Forge is a python package that utilizes many Python dependencies.

- Forge and its plugins uses pipx to isolate dependencies and make self contained globally available executables.

def helptext():
return 'echoes the provided string'
- If you haven't used Python before, you'll need to [install Python 3](https://docs.python-guide.org/starting/installation/) first. (If you're on a Mac, avoid using the default Python installation.)

- You will also need access to `git`.

def register(app):
app.register_plugin('echo', execute, helptext())
```
### **Unix**

## Pre-Requisites and Virtual Environments
Forge is a python package that utilizes many Python dependencies.
```shell
$ apt-get -y install python3-pip
$ apt-get -y install python3-venv
$ apt-get -y install git
$ python3 -m pip install --user pipx
$ echo 'export PIPX_HOME="$HOME/.forge"' >> ~/.profile
$ echo 'export PIPX_BIN_DIR="$HOME/.forge/bin"' >> ~/.profile
$ python3 -m pipx ensurepath
```

As such, it is highly recommended that you install and use forge within a Python virtual environment to avoid any potential issues with version requirements with your existing Python packages.
> **IMPORTANT:** Now reboot/logout to gain access to `pipx`

For those not familiar with using a virtual environment, the ability to initialize a simple one is provided within the Makefile of this repository.
### **Windows**

If you haven't used Python before, you'll need to [install Python 3](https://docs.python-guide.org/starting/installation/) first. (If you're on a Mac, avoid using the default Python installation.)
Go to: https://gitforwindows.org/, then download and install latest git build

In order to activate and use the included virtual environment, proceed with the following steps:
In PowerShell, running as administartor, run the following:

## Unix
```
$ make init
$ . .venv/bin/activate
```shell
python -m pip install --user pipx
$env:PIPX_HOME="~/.forge"
$env:PIPX_BIN_DIR="~/.forge/bin"
python -m pipx ensurepath --force
```

You should see a visual representation on your command prompt that will indicate that you are within the virtual environment.
Anything installed while this virtual environment is active will only be available while you are within. Read more about Python virtual environments [here](https://realpython.com/python-virtual-environments-a-primer/).
> **IMPORTANT:** Now reboot/logout to gain access to `pipx`

You can leave the virtual environment at any time with the following command:
```
$ deactivate
```
---

## Installation
Once within your virtual environment, there are a number of ways that you can install the forge package.

### From Source
If you are already within the repository and using the included virtual environment, you can easily run another single make command in order to install forge from source:
### **Via PyPI**

```
$ make install
```shell
$ pipx install tele-forge
```

To verify your installation was successful:
```
$ which forge
```
should return the installed location of forge and:
```
$ forge
### **From VCS**

```shell
$ pipx install git+ssh://git@github.com:TeleTrackingTechnologies/forge.git
```
should return the simple help interface.

### Via PyPI
### **From Source (after cloning)**

```
$ pip3 install tele-forge
```shell
$ pipx install .
# OR as editable for developing forge changes
$ pipx install -e .
```

To verify your installation was successful:
```
---

## Post Install

To verify your installation was successful

```shell
$ which forge
# OR
where.exe forge
```
should return the installed location of forge and:

should return the installed location of forge, then:

```
$ forge
$ forge -h
```
should return the simple help interface.


should return the simple help interface.

---

## Usage

```
forge <plugin-name> [plugin-arguments]
```
6 changes: 0 additions & 6 deletions bin/forge

This file was deleted.

2 changes: 0 additions & 2 deletions bin/forge.bat

This file was deleted.

7 changes: 7 additions & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pylint==2.6.0
pytest==6.1.2
pytest-randomly==3.5.0
pytest-repeat==0.9.1
pytest-cov==2.10.1
mock==4.0.2
twine==1.13.0
Loading