Skip to content

Commit

Permalink
Clairvoyance v2.0.0 - Package, Async, Linting (#40)
Browse files Browse the repository at this point in the history
* fix: field validation

* chore: add lint

* chore: add poetry

* chore: add gql

* feat: primitives

* feat: update oracle

* feat: update gql

* feat: config

* feat: client

* chore: remove config

* fix: class & linting

* feat: update

* feat: cli

* chore: add wordlist

* chore: update wordlist

* feat: working

* chore: logger fix

* feat: update docker && ci

* chore: linting

* chore: lint

* chore: downgrade mypy

* fix: update poetry.lock data

* chore: update workflows

* chore: bump pyproject

* feat: add Swan as author

* fix: starting explicit url

* chore: typo regexs

* fix: revert removal of gql

* refactor: test return type

* fix: remove totally gql client

* chore: nomenclature of ignored list

* fix: add default value to ignored list

* chore: tests typing

* feat: logger env variables

* chore: update readme with environment variables

* chore: specify code block language

* refactor: ctx usage for LLV object

* chore: ignore lambda warnings

* fix: lint confirmity and disable errors

* chore: tests quotes conversion

* fix: remove master from workflow

* chore: more linting

* feat: add aiounittest

* tests: greenify

* fix: tests workflows dependencies install

* test: check subprocess returned code

* fix: workflows environment

* fix: workflows and response status

* feat: add vscode debugger

* fix: args verbosity

* fix: workflow exit

* refactor: meta enum for graphql types

* feat: add --verbose

* chore: log consistency

* feat: default wordlist

* fix: safely close client session

* chore: workflow consistency

* chore: remove unecessary statement

* chore: linting consistency

* refactor: GQL kind semenatic

* fix: add primitives to ignored list

* feat: handle more skip messages

* test: remove stderr test

* chore: update to fit tests

Co-authored-by: Antoine Carossio <[email protected]>
  • Loading branch information
nullswan and iCarossio authored Aug 12, 2022
1 parent 9686806 commit d12a41f
Show file tree
Hide file tree
Showing 33 changed files with 13,438 additions and 956 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: cd

on:
push:
tags:
- "v*"

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: softprops/action-gh-release@v1

pypi-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- name: Install dependencies
run: |
pip install poetry
- name: Setup poetry
run: |
poetry config virtualenvs.in-project true
poetry install --no-dev
- name: Build package
run: |
source .venv/bin/activate
poetry build
- name: Upload package
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}

docker-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: ./
file: ./Dockerfile
push: true
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/clairvoyance:latest

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
37 changes: 0 additions & 37 deletions .github/workflows/cicd-to-dockerhub.yml

This file was deleted.

56 changes: 39 additions & 17 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,21 @@ on:
- '.gitignore'
branches:
- main
- master
pull_request:
paths-ignore:
- 'README.md'
- 'LICENSE'
- '.gitignore'
branches:
- main
- master
types:
- opened
- reopened

env:
MODULE_NAME: clairvoyance
MIN_TEST_COV: 0
SERVER: http://localhost:4000

jobs:
unit-tests:
Expand All @@ -27,15 +33,27 @@ jobs:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Test with pytest
pip install poetry
- name: Setup poetry
run: |
python -m unittest tests/*_test.py
poetry config virtualenvs.in-project true
poetry install
- name: Run lint
if: always()
run: |
source .venv/bin/activate
isort -m 9 --line-length 160 $MODULE_NAME tests --check-only
pylint --load-plugins pylint_quotes $MODULE_NAME tests
docformatter --wrap-summaries 160 --wrap-descriptions 160 -cr $MODULE_NAME tests
yapf -rd $MODULE_NAME tests
mypy -V
mypy $MODULE_NAME tests
- name: Run tests
run: |
source .venv/bin/activate
pytest --cov=$MODULE_NAME --cov-report=xml --cov-fail-under=$MIN_TEST_COV tests
system-tests:

Expand All @@ -45,32 +63,36 @@ jobs:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
pip install poetry
- name: Setup poetry
run: |
poetry config virtualenvs.in-project true
poetry install
- uses: actions/setup-node@v2
with:
node-version: '16'
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Install deps and run server
run: |
cd tests/apollo-server
npm install
node src/index.js &
- name: Wait for server
run: |
echo "SERVER=http://localhost:4000" > $GITHUB_ENV
for i in {0..9}; do
for i in {0..10}; do
echo "Sleep for 1 second ..."
sleep 1
if curl -s -o /dev/null "$SERVER"; then
echo "$SERVER returned HTTP response!"
break
fi
if [ $i -eq 10 ]; then
echo "Server did not respond after 10 seconds!"
exit 1
fi
done
- name: Test with pytest
run: |
source .venv/bin/activate
python -m unittest tests/system.py
15 changes: 15 additions & 0 deletions .mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[mypy]
python_version = 3.7
disallow_untyped_defs=True
disallow_untyped_calls=True
disallow_incomplete_defs=True
disallow_untyped_decorators=True
strict_equality=True
show_error_codes=True
warn_unreachable=True
warn_redundant_casts=True
warn_unused_ignores=True
warn_unused_configs=True
pretty=True
exclude=(build|dist|setup.py|.venv)
files=pytemplate,tests
57 changes: 57 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
[MASTER]
# init-hook="from pylint.config import find_pylintrc; import os, sys; sys.path.append(os.path.dirname(find_pylintrc())); import pylint_venv; pylint_venv.inithook('./.venv')"
load-plugins=pylint_absolute_imports, pylint_quotes
ignore=.venv,setup.py

[DESIGN]

# Maximum number of characters on a single line.
max-line-length=160
# Good variable names which should always be accepted, separated by a comma
good-names=i,e
# Maximum number of branch for function / method body
max-branches=15
# Maximum number of arguments for function / method
max-args=10
# Variable naming style
variable-rgx=([a-z_][a-z0-9_]{1,31}|[a-zA-Z0-9_]{1})$
# Argument naming style
argument-rgx=([a-z_][a-z0-9_]{1,31}|[a-zA-Z0-9_]{1})$
# Attribute naming style
attr-rgx=([a-z_][a-z0-9_]{1,31}|[a-zA-Z0-9_]{1})$
# Maximum number of public methods per class
max-public-methods=30
# Maximum number of locals for function / method body
max-locals=20
# Make docstring compulsory for all functions
no-docstring-rgx=$^

# MODULE-PARAM: pylint-quotes
string-quote=single
triple-quote=double
docstring-quote=double

[ELIF]

# Maximum number of nested blocks for function/method body
max-nested-blocks=8


[SIMILARITIES]

# Minimum lines number of a similarity.
min-similarity-lines=15
# Ignore comments when computing similarities.
ignore-comments=yes
# Ignore docstrings when computing similarities.
ignore-docstrings=yes
# Ignore imports when computing similarities.
ignore-imports=yes


[MESSAGES CONTROL]

#TODO: DEV - Fix these one day: broad-except, fixme
disable=logging-format-interpolation, logging-fstring-interpolation, broad-except, fixme, missing-class-docstring, missing-module-docstring, missing-function-docstring
enable=print-statement
extension-pkg-whitelist=lxml
Loading

0 comments on commit d12a41f

Please sign in to comment.