Skip to content

Commit

Permalink
Merge pull request #4 from Axonius/develop
Browse files Browse the repository at this point in the history
Release 2.0
  • Loading branch information
lifehackjim committed Sep 16, 2019
2 parents 22311c8 + 874f8de commit fb41003
Show file tree
Hide file tree
Showing 152 changed files with 15,907 additions and 4,298 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
playground.py

.idea/inspectionProfiles/
### macOS template
# General
Expand Down
4 changes: 1 addition & 3 deletions .python-version
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
3.7.3
3.6.8
2.7.16
3.7.4
82 changes: 46 additions & 36 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
PACKAGE := "axonius_api_client"
PACKAGE := axonius_api_client
VERSION := $(shell grep __version__ $(PACKAGE)/version.py | cut -d\" -f2)

# FUTURE: write Makefile doc
# FUTURE: add check that only master branch can publish / git tag

.PHONY: build docs

help:
@cat Makefile.help

init:
$(MAKE) pip_install_tools
$(MAKE) clean
$(MAKE) pyenv_init
$(MAKE) pipenv_init
$(MAKE) pipenv_install_lint
$(MAKE) pipenv_install_dev
$(MAKE) pipenv_install_docs
$(MAKE) pipenv_install_build

pip_install_tools:
pip install --quiet --upgrade --requirement requirements-pkg.txt
Expand All @@ -27,53 +31,58 @@ pipenv_install_build:
pipenv_install_docs:
pipenv run pip install --quiet --upgrade --requirement docs/requirements.txt

pipenv_clean:
pipenv --rm || true

pipenv_init:
pipenv install --dev --skip-lock

pipenv_clean:
pipenv --rm || true

pyenv_init:
pyenv install 3.7.3 -s || true
pyenv install 3.6.8 -s || true
pyenv install 2.7.16 -s || true
pyenv local 3.7.3 3.6.8 2.7.16 || true
pyenv install 3.7.4 -s || true
pyenv local 3.7.4 || true

lint:
$(MAKE) pipenv_install_lint
pipenv run which black && black $(PACKAGE) setup.py
pipenv run flake8 --max-line-length 89 $(PACKAGE) setup.py
pipenv run bandit -r . --skip B101 -x playground.py,setup.py
pipenv run isort -rc -y $(PACKAGE) setup.py axonshell*.py
pipenv run which black && pipenv run black $(PACKAGE) setup.py axonshell*.py
pipenv run pydocstyle $(PACKAGE) setup.py axonshell*.py
pipenv run flake8 --max-line-length 89 $(PACKAGE) setup.py axonshell*.py
pipenv run bandit --skip B101 -r $(PACKAGE)

test:
$(MAKE) pipenv_install_dev
pipenv run pytest -rA --junitxml=junit-report.xml --cov-config=.coveragerc --cov-report=term --cov-report xml --cov-report=html:cov_html --cov=$(PACKAGE) --showlocals --log-cli-level=INFO --verbose --exitfirst $(PACKAGE)/tests
pipenv run pytest -ra --verbose --junitxml=junit-report.xml --cov-config=.coveragerc --cov-report xml --cov-report=html:cov_html --cov=$(PACKAGE) --showlocals --exitfirst $(PACKAGE)/tests

test_debug:
$(MAKE) pipenv_install_dev
pipenv run pytest -rA --capture=no --showlocals --log-cli-level=DEBUG --verbose --exitfirst $(PACKAGE)/tests
test_dev:
pipenv run pytest -vv --log-cli-level=DEBUG --showlocals --exitfirst $(PACKAGE)/tests

test_cov_open:
open cov_html/index.html

test_clean:
rm -rf .egg .eggs junit-report.xml cov_html .tox .pytest_cache .coverage
rm -rf .egg .eggs junit-report.xml cov_html .tox .pytest_cache .coverage coverage.xml

docs:
$(MAKE) pipenv_install_docs
(cd docs && pipenv run make html SPHINXOPTS="-Wna" && cd ..)

docs_dev:
(cd docs && pipenv run make html SPHINXOPTS="-na" && cd ..)

docs_apigen:
rm -rf docs/api_ref
pipenv run sphinx-apidoc -e -P -M -f -t docs/_templates -o docs/api_ref $(PACKAGE) $(PACKAGE)/tests $(PACKAGE)/cli

docs_open:
open docs/_build/html/index.html

docs_coverage:
$(MAKE) pipenv_install_docs
(cd docs && pipenv run make coverage && cd ..)
cat docs/_build/coverage/python.txt

docs_linkcheck:
$(MAKE) pipenv_install_docs
(cd docs && pipenv run make linkcheck && cd ..)
cat docs/_build/linkcheck/output.txt

docs_clean:
$(MAKE) pipenv_install_docs
(cd docs && pipenv run make clean && cd ..)
rm -rf docs/_build

git_check:
@git diff-index --quiet HEAD && echo "*** REPO IS CLEAN" || (echo "!!! REPO IS DIRTY"; false)
Expand All @@ -84,34 +93,35 @@ git_tag:
@git push --tags
@echo "*** ADDED TAG: $(VERSION)"

publish:
pkg_publish:
# FUTURE: add check that only master branch can publish / git tag
$(MAKE) lint
$(MAKE) build
$(MAKE) pkg_build
$(MAKE) git_check
pipenv run twine upload dist/*

build:
$(MAKE) build_clean
$(MAKE) pipenv_install_build
pkg_build:
$(MAKE) pkg_clean

@echo "*** Building Source and Wheel (universal) distribution"
pipenv run python setup.py sdist bdist_wheel --universal

@echo "*** Checking package with twine"
pipenv run twine check dist/*

build_clean:
pkg_clean:
rm -rf build dist *.egg-info


clean_files:
files_clean:
find . -type d -name "__pycache__" | xargs rm -rf
find . -type f -name ".DS_Store" | xargs rm -f
find . -type f -name "*.pyc" | xargs rm -f

clean:
$(MAKE) clean_files
$(MAKE) build_clean
$(MAKE) files_clean
$(MAKE) pkg_clean
$(MAKE) test_clean
$(MAKE) docs_clean
$(MAKE) pipenv_clean

# FUTURE: add cov_publish
43 changes: 43 additions & 0 deletions Makefile.help
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# venv
pip_install_tools install requirements-pkg.txt into site-packages
pipenv_install_dev install requirements-dev.txt into venv
pipenv_install_lint install requirements-lint.txt into venv
pipenv_install_build install requirements-build.txt into venv
pipenv_install_docs install docs/requirements.txt into venv
pipenv_init build a venv using pipenv
pipenv_clean remove the venv built by pipenv
pyenv_init setup pyenv with python 3.7.3, 3.6.8, 2.7.16

# docs
docs run docs/make html and rebuild ALL docs
docs_dev run docs/make html and only rebuild changed docs
docs_coverage run docs/make coverage
docs_linkcheck run docs/make linkcheck
docs_open open the html docs in a browser
docs_clean make pipenv_install_docs, run docs/make clean

# git fun
git_check check that the repo is clean and a tag exists for current version
git_tag make a tag for current version and push it

# packaging
pkg_build make clean, make pipenv_install_build, build the package
pkg_publish make lint, make pkg_build, make git_check, publish the package to pypi
pkg_clean clean up build folders/files

# testing
lint run black, isort, pydocstyle, flake8, and bandit
test run pytest with coverage reports
test_dev run pytest with logging at debug
test_cov_open open the test coverage html docs in a browser
test_clean clean up test folders/files

# clean up
files_clean clean up a bunch of files
clean make files_clean, make pkg_clean, make test_clean, make docs_clean, make pipenv_clean

# other
help this...

# call me first
init make pip_install_tools, make clean, make py_env, make pipenv_init, make pipenv_install_*
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Installing axonius_api_client via [pip](https://pypi.org/project/pip/) or [pipen

## Documentation

**With the 2.0 release the docs are in the midst of an overhaul.**

Found [here](https://axonius-api-client.readthedocs.io/en/latest/?)

## Examples
Expand Down
56 changes: 0 additions & 56 deletions axonius_api_client.sublime-project

This file was deleted.

44 changes: 32 additions & 12 deletions axonius_api_client/__init__.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,36 @@
# -*- coding: utf-8 -*-
"""Axonius API Client package."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import absolute_import, division, print_function, unicode_literals

from . import api
from . import constants
from . import http
from . import auth
from . import exceptions
from . import version
from . import tools
from . import api, auth, cli, constants, exceptions, http, logs, tools, version
from .api import Adapters, Devices, Enforcements, Users
from .auth import ApiKey
from .connect import Connect
from .http import Http

__all__ = ("api", "constants", "http", "auth", "exceptions", "version", "tools")
__version__ = version.__version__
LOG = logs.LOG

__all__ = (
# Connection handler
"Connect",
# http client
"Http",
# authentication
"ApiKey",
# api
"Users",
"Devices",
"Adapters",
"Enforcements",
# modules
"api",
"auth",
"http",
"exceptions",
"version",
"tools",
"constants",
"cli",
"logs",
)

0 comments on commit fb41003

Please sign in to comment.