Skip to content

Commit

Permalink
Add code style and error check. (#3)
Browse files Browse the repository at this point in the history
### This PR add the code syntax and error check for the whole repo by
following the same principle of
[opentelemetry-python-contrib](https://github.com/open-telemetry/opentelemetry-python-contrib)
and use the following tools:
**codespell**:  Find and fix common spelling mistakes.
**flake8** and **black**: Code style check and code formatting.
**Isort**:  Adjust the import statements.
**pylint**: Configures pylint's style check rules, ignores specific
warnings and statements, defines naming conventions, format logging
style and spelling, etc,.
  • Loading branch information
zzhlogin authored Jan 5, 2024
2 parents a008430 + 2c6b245 commit 9319463
Show file tree
Hide file tree
Showing 13 changed files with 1,382 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[codespell]
# skipping auto generated folders
skip = ./.tox,./.mypy_cache,./target,*/LICENSE,./venv
ignore-words-list = ot
25 changes: 25 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[flake8]
ignore =
# line too long, defer to black
E501

# allow line breaks before binary ops
W503

# allow line breaks after binary ops
W504

# allow whitespace before ':' (https://github.com/psf/black#slices)
E203

exclude =
.bzr
.git
.hg
.svn
.tox
CVS
.venv*/
venv*/
target
__pycache__
39 changes: 39 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This workflow check the code style for the repo
# TODO: add unit test check after adding AWS Distro project
name: AWS Distro Tests

on:
push:
pull_request:

jobs:
misc:
strategy:
fail-fast: false
matrix:
tox-environment: ["spellcheck", "lint"]
name: ${{ matrix.tox-environment }}
runs-on: ubuntu-20.04
steps:
- name: Checkout Contrib Repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v2
- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: "3.10"
- name: Install tox
run: pip install tox==3.27.1
- name: Install libsnappy-dev
if: ${{ matrix.tox-environment == 'lint' }}
run: sudo apt-get install -y libsnappy-dev
- name: Cache tox environment
# Preserves .tox directory between runs for faster installs
uses: actions/cache@v1
with:
path: |
.tox
~/.cache/pip
key: v7-misc-tox-cache-${{ matrix.tox-environment }}-${{ hashFiles('tox.ini',
'dev-requirements.txt') }}
- name: run tox
run: tox -e ${{ matrix.tox-environment }}
60 changes: 60 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
*.py[cod]
*.sw[op]

# C extensions
*.so

# Packages
*.egg
*.egg-info
dist
dist-info
build
eggs
parts
bin
var
sdist
develop-eggs
.installed.cfg
pyvenv.cfg
lib
lib64
__pycache__
venv*/
.venv*/

# Installer logs
pip-log.txt

# Unit test / coverage reports
coverage.xml
.coverage
.nox
.tox
.cache
htmlcov

# Translations
*.mo

# Mac
.DS_Store

# Mr Developer
.mr.developer.cfg
.project
.pydevproject

# JetBrains
.idea

# VSCode
.vscode

# Sphinx
_build/

# mypy
.mypy_cache/
target
19 changes: 19 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[settings]
include_trailing_comma=True
force_grid_wrap=0
use_parentheses=True
line_length=79
profile=black

; 3 stands for Vertical Hanging Indent, e.g.
; from third_party import (
; lib1,
; lib2,
; lib3,
; )
; docs: https://github.com/timothycrosley/isort#multi-line-output-modes
multi_line_output=3
skip=target
skip_glob=**/gen/*,.venv*/*,venv*/*,.tox/*
known_first_party=opentelemetry
known_third_party=psutil,pytest
Loading

0 comments on commit 9319463

Please sign in to comment.