-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
655 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
PROJECT=zabbix_alerta |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[flake8] | ||
ignore = F403, E501, W503 | ||
exclude = *.wsgi | ||
max-line-length = 140 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: CI Tests | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
python-version: [3.7, 3.8] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
id: install-deps | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install flake8 pytest | ||
pip install -r requirements.txt | ||
pip install -r requirements-dev.txt | ||
pip install . | ||
- name: Pre-commit hooks | ||
id: hooks | ||
run: | | ||
pre-commit run -a --show-diff-on-failure | ||
- name: Lint with flake8 | ||
id: lint | ||
run: | | ||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | ||
flake8 . --count --exit-zero --max-complexity=50 --max-line-length=127 --statistics | ||
- name: Test with pytest | ||
id: test | ||
env: | ||
DATABASE_URL: postgres://postgres:postgres@localhost:5432/alerta | ||
run: | | ||
pytest --cov=zabbix-alerta test_*.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[settings] | ||
known_third_party = alertaclient,protobix,pyzabbix,setuptools |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/mirrors-autopep8 | ||
rev: v1.5.1 | ||
hooks: | ||
- id: autopep8 | ||
- repo: https://github.com/pre-commit/pre-commit-hooks.git | ||
rev: v2.5.0 | ||
hooks: | ||
- id: check-added-large-files | ||
- id: check-ast | ||
- id: check-byte-order-marker | ||
- id: check-case-conflict | ||
- id: check-docstring-first | ||
- id: check-json | ||
- id: check-merge-conflict | ||
- id: check-yaml | ||
- id: debug-statements | ||
- id: double-quote-string-fixer | ||
- id: end-of-file-fixer | ||
- id: fix-encoding-pragma | ||
args: ['--remove'] | ||
- id: pretty-format-json | ||
args: ['--autofix'] | ||
- id: name-tests-test | ||
args: ['--django'] | ||
- id: requirements-txt-fixer | ||
- id: trailing-whitespace | ||
- repo: https://gitlab.com/pycqa/flake8 | ||
rev: 3.7.7 | ||
hooks: | ||
- id: flake8 | ||
- repo: https://github.com/asottile/pyupgrade | ||
rev: v1.27.0 | ||
hooks: | ||
- id: pyupgrade | ||
args: ['--py3-plus'] | ||
- repo: https://github.com/asottile/seed-isort-config | ||
rev: v1.9.4 | ||
hooks: | ||
- id: seed-isort-config | ||
- repo: https://github.com/pre-commit/mirrors-isort | ||
rev: v4.3.21 | ||
hooks: | ||
- id: isort |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
#!make | ||
|
||
VENV=venv | ||
PYTHON=$(VENV)/bin/python | ||
PIP=$(VENV)/bin/pip --disable-pip-version-check | ||
PYLINT=$(VENV)/bin/pylint | ||
MYPY=$(VENV)/bin/mypy | ||
BLACK=$(VENV)/bin/black | ||
TOX=$(VENV)/bin/tox | ||
PYTEST=$(VENV)/bin/pytest | ||
DOCKER_COMPOSE=docker-compose | ||
PRE_COMMIT=$(VENV)/bin/pre-commit | ||
WHEEL=$(VENV)/bin/wheel | ||
TWINE=$(VENV)/bin/twine | ||
GIT=git | ||
|
||
.DEFAULT_GOAL:=help | ||
|
||
-include .env .env.local .env.*.local | ||
|
||
ifndef PROJECT | ||
$(error PROJECT is not set) | ||
endif | ||
|
||
VERSION=$(shell cut -d "'" -f 2 $(PROJECT)/version.py) | ||
|
||
PKG_SDIST=dist/*-$(VERSION).tar.gz | ||
PKG_WHEEL=dist/*-$(VERSION)-*.whl | ||
|
||
all: help | ||
|
||
$(PIP): | ||
python3 -m venv $(VENV) | ||
|
||
$(PYLINT): $(PIP) | ||
$(PIP) install pylint | ||
|
||
$(MYPY): $(PIP) | ||
$(PIP) install mypy | ||
|
||
$(BLACK): $(PIP) | ||
$(PIP) install black | ||
|
||
$(TOX): $(PIP) | ||
$(PIP) install tox | ||
|
||
$(PYTEST): $(PIP) | ||
$(PIP) install pytest | ||
|
||
$(PRE_COMMIT): $(PIP) | ||
$(PIP) install pre-commit | ||
|
||
$(WHEEL): $(PIP) | ||
$(PIP) install wheel | ||
|
||
$(TWINE): $(PIP) | ||
$(PIP) install twine | ||
|
||
ifdef TOXENV | ||
toxparams?=-e $(TOXENV) | ||
endif | ||
|
||
## format - Code formatter. | ||
format: $(BLACK) | ||
$(BLACK) -l120 -S -v $(PROJECT) | ||
|
||
## hooks - Run pre-commit hooks. | ||
hooks: $(PRE_COMMIT) | ||
$(PRE_COMMIT) run --all-files --show-diff-on-failure | ||
|
||
## lint - Lint and type checking. | ||
lint: $(PYLINT) $(BLACK) $(MYPY) | ||
$(PYLINT) --rcfile pylintrc $(PROJECT).py | ||
$(BLACK) -l120 -S --check -v $(PROJECT).py || true | ||
$(MYPY) $(PROJECT).py | ||
|
||
## test - Run unit tests. | ||
test: $(PYTEST) | ||
$(PYTEST) | ||
|
||
## help - Show this help. | ||
help: Makefile | ||
@echo '' | ||
@echo 'Usage:' | ||
@echo ' make [TARGET]' | ||
@echo '' | ||
@echo 'Targets:' | ||
@sed -n 's/^##//p' $< | ||
@echo '' | ||
|
||
@echo 'Add project-specific env variables to .env file:' | ||
@echo 'PROJECT=$(PROJECT)' | ||
|
||
.PHONY: help lint test build sdist wheel clean all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,4 +86,3 @@ services: | |
#networks: | ||
# zbxnet: | ||
# driver: bridge | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[mypy] | ||
ignore_missing_imports = True |
Oops, something went wrong.