Skip to content

Commit

Permalink
Merge branch 'rl-1.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
amenezes committed Dec 9, 2022
2 parents 9c41456 + 6da8191 commit 3a432d9
Show file tree
Hide file tree
Showing 176 changed files with 4,704 additions and 2,954 deletions.
5 changes: 1 addition & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@ root = true
insert_final_newline = true
end_of_line = lf
charset = utf-8
indent_size = 2

[*.py]
indent_style = space
indent_size = 4

[*.{yaml,yml,ini}]
indent_style = space
indent_size = 2

[Makefile]
indent_size = tab

Expand Down
18 changes: 0 additions & 18 deletions .flake8

This file was deleted.

7 changes: 7 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*.pxd text diff=python
*.py text diff=python
*.py3 text diff=python
*.pyw text diff=python
*.pyx text diff=python
*.pyz text diff=python
*.pyi text diff=python
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: ci

on: [ push, pull_request ]

jobs:
tests:
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
os: [ubuntu]
fail-fast: true
runs-on: ${{ matrix.os }}-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@master
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- uses: actions/cache@v2
with:
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements-dev.txt') }}
path: ~/.cache/pip
restore-keys: |
${{ runner.os }}-pip-
- name: Install Python dependencies
uses: py-actions/py-dependency-install@v2
with:
path: "./requirements-dev.txt"
- name: Run lint & tests
run: |
make ci SKIP_STYLE=true
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
file: ./coverage.xml
fail_ci_if_error: true
37 changes: 37 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
fail_fast: false
repos:
- repo: local
hooks:
- id: black
name: black
entry: black
language: system
types: [python]
- id: isort
name: isort
entry: isort
language: system
types: [python]
args: ["--profile", "black"]
- id: flake8
name: flake8
entry: flake8
language: system
types: [ python ]
- id: mypy
name: mypy
entry: mypy
language: system
types: [ python ]
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.3.0
hooks:
- id: forbid-crlf
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-case-conflict
- id: check-merge-conflict
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
22 changes: 0 additions & 22 deletions .travis.yml

This file was deleted.

59 changes: 31 additions & 28 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
.DEFAULT_GOAL := about
VERSION := $(shell cat discovery/__version__.py | cut -d'"' -f2)
DTYPE=server
VERSION := $(shell cat discovery/__init__.py | grep version | cut -d'"' -f2)

lint:
ifeq ($(SKIP_STYLE), )
@echo "> running isort..."
isort -rc discovery
isort -rc tests
isort discovery --profile black
isort tests --profile black
@echo "> running black..."
black discovery
black tests
endif
@echo "> running flake8..."
flake8 discovery
flake8 tests
Expand All @@ -17,43 +18,45 @@ lint:

tests:
@echo "> running tests"
python -m pytest -v --cov-report xml --cov-report term --cov=discovery tests
python -m pytest -vv --no-cov-on-fail --color=yes --cov-report xml --cov-report term --cov=discovery tests

ci: lint tests
ifeq ($(GITHUB_HEAD_REF), false)
@echo "--- codecov report ---"
codecov --file coverage.xml -t $$CODECOV_TOKEN
@echo "--- codeclimate report ---"
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
./cc-test-reporter format-coverage -t coverage.py -o codeclimate.json
./cc-test-reporter upload-coverage -i codeclimate.json -r $$CC_TEST_REPORTER_ID
endif

docs:
@echo "> generate project documentation..."
portray $(DTYPE)
@cp README.md docs/index.md
mkdocs serve

tox:
@echo "> running tox..."
tox -r -p all

install-deps:
@echo "> installing development dependencies..."
@echo "> installing dependencies..."
pip install -r requirements-dev.txt
pre-commit install

about:
@echo "> discovery-client v$(VERSION)"
@echo "> discovery-client $(VERSION)"
@echo ""
@echo "make lint - Runs: [isort > black > flake8 > mypy]"
@echo "make tests - Execute tests"
@echo "make tox - Runs tox"
@echo "make docs - Generate project documentation [DTYPE=server]"
@echo "make ci - Runs: [make lint > make tests]"
@echo "make install-deps - Install development dependencies"
@echo "make tox - Runs tox"
@echo "make docs - Generate project documentation"
@echo "make install-deps - Install development dependencies."
@echo ""
@echo "mailto: [email protected]"

ci: lint tests
ifeq ($(CI), true)
@echo "--- download CI dependencies ---"
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
@echo "--- report upload ---"
codecov --file coverage.xml -t $$CODECOV_TOKEN
./cc-test-reporter format-coverage -t coverage.py -o codeclimate.json
./cc-test-reporter upload-coverage -i codeclimate.json -r $$CC_TEST_REPORTER_ID
endif

tox:
@echo "> running tox..."
tox -r -p all

all: install-deps ci docs
all: ci tox

.PHONY: lint tests docs about ci all
.PHONY: lint tests ci tox docs all
24 changes: 18 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,37 @@
[![Build Status](https://travis-ci.org/amenezes/discovery-client.svg?branch=master)](https://travis-ci.org/amenezes/discovery-client)
[![Maintainability](https://api.codeclimate.com/v1/badges/fc7916aab464c8b7d742/maintainability)](https://codeclimate.com/github/amenezes/discovery-client/maintainability)
[![ci](https://github.com/amenezes/discovery-client/workflows/ci/badge.svg)](https://github.com/amenezes/discovery-client/actions)
[![codecov](https://codecov.io/gh/amenezes/discovery-client/branch/master/graph/badge.svg)](https://codecov.io/gh/amenezes/discovery-client)
[![PyPI version](https://badge.fury.io/py/discovery-client.svg)](https://badge.fury.io/py/discovery-client)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/discovery-client)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

# discovery-client

async client [consul](https://consul.io).
Async Python client for [consul](https://consul.io).

HTTP engine options available:

- aiohttp `default`;
- httpx.

## Installing

Install and update using pip:

### default client

````bash
pip install -U discovery-client
````

### httpx client

````bash
pip install -U 'discovery-client[httpx]'
````

## Links

- License: [Apache License](https://choosealicense.com/licenses/apache-2.0/)
- Code: https://github.com/amenezes/discovery-client
- Issue tracker: https://github.com/amenezes/discovery-client/issues
- Docs: https://discovery-client.amenezes.net
- Code: [https://github.com/amenezes/discovery-client](https://github.com/amenezes/discovery-client)
- Issue tracker: [https://github.com/amenezes/discovery-client/issues](https://github.com/amenezes/discovery-client/issues)
- Docs: [https://discovery-client.amenezes.net](https://discovery-client.amenezes.net)
35 changes: 30 additions & 5 deletions discovery/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
import logging
from . import checks, utils
from ._logger import log
from .api import (
Behavior,
CheckStatus,
HealthState,
IntentionFilter,
IntentionsAction,
LogLevel,
TokenLocality,
TokenType,
kind,
)
from .client import Consul

from discovery.__version__ import __version__

log = logging.getLogger("discovery-client")
log.addHandler(logging.NullHandler())
__version__ = "1.0.0"
__all__ = [
"Consul",
"HealthState",
"LogLevel",
"TokenType",
"checks",
"utils",
"Kind",
"TokenLocality",
"IntentionsAction",
"IntentionFilter",
"IntentionBy",
"CheckStatus",
"Behavior",
]
14 changes: 2 additions & 12 deletions discovery/__main__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
from cleo import Application
from dotenv import load_dotenv

from discovery import __version__
from discovery.cli.commands import CatalogCommand

load_dotenv()

application = Application("discovery-client", f"{__version__}")
application.add(CatalogCommand())

from discovery.cli import cli

if __name__ == "__main__":
application.run()
cli()
1 change: 0 additions & 1 deletion discovery/__version__.py

This file was deleted.

4 changes: 4 additions & 0 deletions discovery/_logger.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import logging

log = logging.getLogger("discovery-client")
log.addHandler(logging.NullHandler())
35 changes: 0 additions & 35 deletions discovery/abc.py

This file was deleted.

Loading

0 comments on commit 3a432d9

Please sign in to comment.