Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete overhaul #6

Draft
wants to merge 92 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
a6d78d5
Improve the structure of README
janaSunrise Jun 6, 2022
137c664
Center the headings.
janaSunrise Jun 6, 2022
d87f72e
Remove exclamation and add emojis to headings.
janaSunrise Jun 6, 2022
9241c52
Remove pointless getattr
ItsDrike Jun 6, 2022
05cf5f1
Add poetry files
ItsDrike Jun 6, 2022
e390ab4
Add taskipy to replace pipenv's scripts
ItsDrike Jun 6, 2022
a742d63
Use poetry in the lint workflow
ItsDrike Jun 6, 2022
e7a9b75
Remove pipenv support
ItsDrike Jun 6, 2022
7452a54
Use poetry in pre-commit
ItsDrike Jun 6, 2022
c9a753c
Fill in details in poetry.
janaSunrise Jun 6, 2022
01c8deb
Merge branch 'chore/refactor' of https://github.com/janaSunrise/ZeroC…
janaSunrise Jun 6, 2022
a566651
Don't use tox config file for flake8 config only
ItsDrike Jun 6, 2022
11a35c7
Only ignore unused imports in __init__ files
ItsDrike Jun 6, 2022
87f8853
Remove unused time import from client.py
ItsDrike Jun 6, 2022
faf09ff
Ignore the use of typing.Any
ItsDrike Jun 6, 2022
5358099
Integrate toml instead of ini.
janaSunrise Jun 6, 2022
55a196d
Fix merge conflicts.
janaSunrise Jun 6, 2022
651674f
Uae folders in exclude, instead of expanding glob
ItsDrike Jun 6, 2022
eb23485
Fix list of ignored flake8 errors
ItsDrike Jun 6, 2022
9bf6f7c
Update .gitignore
ItsDrike Jun 6, 2022
ee83475
Add some comments to pre-commit explaining use of options
ItsDrike Jun 6, 2022
e341704
Add yaml checker to pre-commit
ItsDrike Jun 6, 2022
582f0bd
Completely rewrite lint workflow
ItsDrike Jun 6, 2022
fab4f01
Start rewriting the app.
janaSunrise Jun 6, 2022
8149895
Merge branch 'chore/refactor' of https://github.com/janaSunrise/ZeroC…
janaSunrise Jun 6, 2022
257f9fd
Add some more flake8 extensions
ItsDrike Jun 6, 2022
9631cbc
Add black
ItsDrike Jun 6, 2022
bcb868b
Run black
ItsDrike Jun 6, 2022
6674224
Add black to pre-commit
ItsDrike Jun 6, 2022
3e7ab22
Use isort in favor of flake8-import-order
ItsDrike Jun 6, 2022
a13b8bf
Add isort to pre-commit and workflows
ItsDrike Jun 6, 2022
d23e92c
Start out with the basic client model.
janaSunrise Jun 6, 2022
9b637b8
Merge branch 'chore/refactor' of https://github.com/janaSunrise/ZeroC…
janaSunrise Jun 6, 2022
58a9c9f
Run formatters before linters
ItsDrike Jun 6, 2022
cfe1ce2
Add pyright
ItsDrike Jun 6, 2022
a2afdfc
Add pyright to pre-commit and workflow
ItsDrike Jun 6, 2022
8affc27
Run black
ItsDrike Jun 6, 2022
3d72e0b
Switch to GPL
ItsDrike Jun 6, 2022
478387d
Support setting config file with env var
ItsDrike Jun 6, 2022
5523482
Add abstract classes for reader/writer interfaces
ItsDrike Jun 6, 2022
6c91648
Create buffer class for testing and intermediaries
ItsDrike Jun 6, 2022
ca662f9
Create connection class
ItsDrike Jun 6, 2022
bd12c71
Use absolute imports
ItsDrike Jun 6, 2022
98c8c95
Use new protocol connection
ItsDrike Jun 6, 2022
97b47d2
Add logging support with optional coloredlogs
ItsDrike Jun 6, 2022
e58d586
Remove no longer used header length from config
ItsDrike Jun 6, 2022
9a0a1b5
Update license in pyproject.toml
ItsDrike Jun 6, 2022
188ed02
Add pytest
ItsDrike Jun 6, 2022
1478420
Add workflow to auto-run unit-tessts
ItsDrike Jun 6, 2022
69c32ca
Fix unit-test workflow name
ItsDrike Jun 6, 2022
196631a
Ignore annotation errors in tests
ItsDrike Jun 6, 2022
0ebfb58
Add basic tests for reader/writer
ItsDrike Jun 6, 2022
740dc71
Handle adding python executables to windows path
ItsDrike Jun 6, 2022
f4d7f78
Add missing future annotations import
ItsDrike Jun 6, 2022
caa0c38
Add flake8-future-annotations
ItsDrike Jun 6, 2022
2230ca1
Add varint read/write tests
ItsDrike Jun 7, 2022
09bb97e
Add UTF string writing tests
ItsDrike Jun 7, 2022
65cb80d
Add tests for buffer class
ItsDrike Jun 7, 2022
37db14f
Allow initialization directly from socket
ItsDrike Jun 7, 2022
81812e3
Rename app to zerocom
ItsDrike Jun 7, 2022
7db3504
Make critical log use red background
ItsDrike Jun 7, 2022
b844b2b
Setup logging on zerocom's __init__
ItsDrike Jun 7, 2022
8680b4f
Remove from_address (only worked for clients)
ItsDrike Jun 7, 2022
d142df3
Add docstrings to connection and buffer classes
ItsDrike Jun 7, 2022
b1499b3
Rewrite client and move it to network/ dir
ItsDrike Jun 7, 2022
43106d4
Implement basic server class
ItsDrike Jun 7, 2022
537b6d7
Add myself as author
ItsDrike Jun 7, 2022
898e490
Add stop and disconnect_client methods to server
ItsDrike Jun 7, 2022
d94e560
Add simple server script implementation
ItsDrike Jun 7, 2022
2686c37
Add simple client script implementation
ItsDrike Jun 7, 2022
020be8e
Add pytest cache folder to gitignore
ItsDrike Jun 11, 2022
b8157a5
Log sent messages
ItsDrike Jun 11, 2022
b388767
Make connection generic to subclasses of socket
ItsDrike Jun 11, 2022
551cbba
Add tests for connection class
ItsDrike Jun 11, 2022
6cb888a
Test reading more data than was sent
ItsDrike Jun 11, 2022
e1da498
RSA implementation in place.
janaSunrise Jun 14, 2022
81720da
Fix merge conflicts.
janaSunrise Jun 14, 2022
207ae6f
Move pyright config to pyproject.
janaSunrise Jun 14, 2022
3882c6a
Use ignore instead of overriding exclude
ItsDrike Jul 3, 2022
c02e3ef
Add read/write bytearray functions
ItsDrike Jul 3, 2022
0299365
Ignore coverage for abstractmethods and typing-time logic
ItsDrike Jul 3, 2022
7ca728a
Remove tmp/ directory in favor of local gitignore option
ItsDrike Jul 3, 2022
8666455
Remove pyright ignore for tmp/ (we don't track tmp/ folder)
ItsDrike Jul 3, 2022
760d00b
Specify default args for pytest in it's own section
ItsDrike Jul 3, 2022
e12431b
Show exact lines with missing coverage
ItsDrike Jul 3, 2022
2ee0203
Enable branch coverage
ItsDrike Jul 3, 2022
660905a
Use verbose mode on test tasks
ItsDrike Jul 3, 2022
960181e
Merge pull request #4 from janaSunrise/chore/refactor
janaSunrise Jul 5, 2022
e30fd26
Move to rich for logging and remove optional coloredlogs dependency.
janaSunrise Jul 10, 2022
cfc2825
Move to manual handler registering.
janaSunrise Jul 15, 2022
8d139eb
Remove coloredlogs as optional dep.
janaSunrise Jul 17, 2022
5ca6fee
Merge pull request #5 from janaSunrise/chore/rich-logging
janaSunrise Jul 17, 2022
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
5 changes: 5 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[report]
exclude_lines =
pragma: nocover
if TYPE_CHECKING:
@abstractmethod
15 changes: 15 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[flake8]
max_line_length=120
extend-ignore=E203 # flake8 has conflicting handling with black here
application-import-names=zerocom,tests
exclude=.venv,.git,.cache
ignore=
ANN002, # *args
ANN003, # **kwargs
ANN101, # self param annotation
ANN102, # cls param annotation
ANN204, # return type annotation for special methods

E731, # Allow inline lambdas
MD033, # Allow inline HTML in markdown
per-file-ignores=*/__init__.py:F401,test_*.py:ANN
32 changes: 0 additions & 32 deletions .github/workflows/flake8-lint.yml

This file was deleted.

85 changes: 85 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Unit-Tests

on:
push:
branches:
- main
pull_request:
workflow_dispatch:

# Cancel already running workflows if new ones are scheduled
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
# Make sure pip caches dependencies and installs as user
PIP_NO_CACHE_DIR: false
PIP_USER: 1

# Make sure poetry won't use virtual environments
POETRY_VIRTUALENVS_CREATE: false

# Specify paths here, so we know what to cache
POETRY_CACHE_DIR: ${{ github.workspace }}/.cache/py-user-base
PYTHONUSERBASE: ${{ github.workspace }}/.cache/py-user-base

jobs:
unit-tests:
runs-on: ${{ matrix.platform }}

strategy:
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.7", "3.10"]

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Python
id: python
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: Add custom PYTHONUSERBASE to PATH (linux)
if: runner.os != 'Windows'
run: echo '${{ env.PYTHONUSERBASE }}/bin/' >> $GITHUB_PATH

# Windows is an absolute piece of crap, for some reason, instead of using /bin
# dir in the userbase path, it creates additional folder named differently in each version
# in which it makes Scripts/ folder (i.e. USERBASE/Python37/Scripts). To handle this
# we're using python's site module which can output it's own path, getting the dirname
# and adding /Scripts as a suffix which is then added to the path.
- name: Add custom PYTHONUSERBASE to PATH (windows)
if: runner.os == 'Windows'
run: |
dir="$(dirname $(python3 -m site --user-site))\\Scripts"
echo "$dir" >> $GITHUB_PATH
cat "$GITHUB_PATH"
shell: bash

# Cache python dependencies so that unless we change them,
# we won't need to reinstall them with each workflow run.
# The key is a composite of multiple values, which when changed
# the cache won't be restored in order to make updating possible
- name: Python dependency caching
uses: actions/cache@v2
id: python_cache
with:
path: ${{ env.PYTHONUSERBASE }}
key: "python-0-${{ runner.os }}-${{ env.PYTHONUSERBASE }}-\
${{ steps.python.outputs.python-version }}-\
${{ hashFiles('./pyproject.toml', './poetry.lock') }}"

# In case the dependencies weren't restored, install them
- name: Install dependencies using poetry
if: steps.python_cache.outputs.cache-hit != 'true'
run: |
pip install poetry
poetry install

# Run the unit-tests using pytest
- name: Run pytest
run: poetry run task test
92 changes: 92 additions & 0 deletions .github/workflows/validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Validation

on:
push:
branches:
- main
pull_request:

# Cancel already running workflows if new ones are scheduled
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
# Make sure pip caches dependencies and installs as user
PIP_NO_CACHE_DIR: false
PIP_USER: 1

# Make sure poetry won't use virtual environments
POETRY_VIRTUALENVS_CREATE: false

# Specify paths here, so we know what to cache
POETRY_CACHE_DIR: ${{ github.workspace }}/.cache/py-user-base
PYTHONUSERBASE: ${{ github.workspace }}/.cache/py-user-base
PRE_COMMIT_HOME: ${{ github.workspace }}/.cache/pre-commit-cache

jobs:
lint:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Add custom PYTHONUSERBASE to PATH
run: echo '${{ env.PYTHONUSERBASE }}/bin/' >> $GITHUB_PATH

- name: Set up Python
id: python
uses: actions/setup-python@v3
with:
python-version: "3.10.4"

# Cache python dependencies so that unless we change them,
# we won't need to reinstall them with each workflow run.
# The key is a composite of multiple values, which when changed
# the cache won't be restored in order to make updating possible
- name: Python dependency caching
uses: actions/cache@v2
id: python_cache
with:
path: ${{ env.PYTHONUSERBASE }}
key: "python-0-${{ runner.os }}-${{ env.PYTHONUSERBASE }}-\
${{ steps.python.outputs.python-version }}-\
${{ hashFiles('./pyproject.toml', './poetry.lock') }}"

# In case the dependencies weren't restored, install them
- name: Install dependencies using poetry
if: steps.python_cache.outputs.cache-hit != 'true'
run: |
pip install poetry
poetry install

# Cache pre-commit environment
# The key is a composite of multiple values, which when changed
# the cache won't be restored in order to make updating possible
- name: Pre-commit Environment Caching
uses: actions/cache@v2
with:
path: ${{ env.PRE_COMMIT_HOME }}
key: "precommit-0-${{ runner.os }}-${{ env.PRE_COMMIT_HOME }}-\
${{ steps.python.outputs.python-version }}-\
${{ hashFiles('./.pre-commit-config.yaml') }}"

# Run the actual linting steps here:

# We skip the major hooks here, because we want to see their output, and
# success status separately in another task. They are ran below.
- name: Run general pre-commit hooks
run: PIP_USER=0; SKIP=flake8,black,isort,pyright pre-commit run --all-files

- name: Run flake8 linter
run: flake8 .

- name: Run black formatter (check)
run: black --check .

- name: Run isort import formatter (check)
run: isort --check .

- name: Run pyright type checker
run: pyright -v $PYTHONUSERBASE
34 changes: 21 additions & 13 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,28 +1,36 @@
# Python cache
# Python byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
.pytest_cache/

# Virtual environments
.venv/
venv/
env/
ENV/

# Pytest coverage reports
.coverage
htmlcov/

# Editor generated files
.idea/
.vscode/
.spyproject/

# VirtualENV files
env/
venv/
.venv/
.vimrc
.nvimrc
.exerc

# Environmental and personal files
*.env
TODO

# Database files
*.sqlite3
*.sqlite
*.sql
*.db
# Local gitignore (symlinked to .git/info/exclude)
.gitignore_local

# Ignore personal log files
# Ignore generated log files
logs/

# MacOS generatd file
# Auto-generated folder attributes for MacOS
.DS_STORE
37 changes: 33 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ repos:
rev: v4.0.1
hooks:
- id: check-merge-conflict
- id: check-toml
- id: check-toml # For pyproject.toml
- id: check-yaml # For workflows
- id: end-of-file-fixer
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
Expand All @@ -13,14 +14,42 @@ repos:
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0
hooks:
- id: python-check-blanket-noqa
- id: python-use-type-annotations
- id: python-check-blanket-noqa # Enforce specific noqa annotations (noqa: F401,W203)
- id: python-use-type-annotations # Enforce type annotations instead of type comments

- repo: local
hooks:
- id: black
name: Black
description: Auto-format the code with black
entry: poetry run black
language: system
types: [python]

- repo: local
hooks:
- id: isort
name: ISort
description: Sort imports with isort
entry: poetry run isort
language: system
types: [python]

- repo: local
hooks:
- id: flake8
name: Flake8
description: Run flake8 checks on the code
entry: pipenv run flake8
entry: poetry run flake8
language: system
types: [python]

- repo: local
hooks:
- id: pyright
name: Pyright
description: Run pyright type checker
entry: poetry run pyright
language: system
types: [python]
pass_filenames: false # pyright runs for the entire project, it can't run for single files
Loading