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

v003 #2

Merged
merged 15 commits into from
Nov 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
82 changes: 51 additions & 31 deletions .cpa/flake8.cfg
Original file line number Diff line number Diff line change
@@ -1,46 +1,66 @@
[flake8]
ignore = E203,E231,E501,I100,I201,I202,D102,D100,C901,D104,D101,D105,D107,D400,D103,D205,W503,E402,E266,F841
# E203 whitespace before ':'. Conflicts with how Black formats slicing.
# E231 missing whitespace after ',', ';', or ':'. Conflicts with Black.
# E501 line too long (82 > 79 characters). Ignored because max-line-length is set.
# I100 Import statements are in the wrong order.
# I201 Missing newline between import groups.
# I202 Additional newline in a group of imports.
# D102 Missing docstring in public method.
# D100 Missing docstring in public module.
# C901 function is too complex. Ignored because max-complexity is set.
# D104 Missing docstring in public package.
# D101 Missing docstring in public class.
# D105 Missing docstring in magic method.
# D107 Missing docstring in __init__.
# D400 First line should end with a period.
# D103 Missing docstring in public function.
# D205 1 blank line required between summary line and description.
# W503 line break before binary operator. This is no longer PEP 8 compliant.
# E402 module level import not at top of file.
# E266 too many leading '#' for block comment.
# F841 local variable is assigned to but never used.
ignore =
# C901, # function is too complex. Ignored because max-complexity is set.
D100,
# Missing docstring in public module.
D101,
# Missing docstring in public class.
D102,
# Missing docstring in public method.
D103,
# Missing docstring in public function.
D104,
# Missing docstring in public package.
D105,
# Missing docstring in magic method.
D107,
# Missing docstring in __init__.
D205,
# 1 blank line required between summary line and description.
D400,
# First line should end with a period.
E203,
# whitespace before ':'. Conflicts with how Black formats slicing.
E231,
# missing whitespace after ',', ';', or ':'. Conflicts with Black.
E266,
# too many leading '#' for block comment.
E402,
# module level import not at top of file.
E501,
# line too long (82 > 79 characters). Ignored because max-line-length is set.
F841,
# local variable is assigned to but never used.
I100,
# Import statements are in the wrong order.
I201,
# Missing newline between import groups.
I202,
# Additional newline in a group of imports.
W503
# line break before binary operator. This is no longer PEP 8 compliant.

exclude =
.cache,
.coverage.*,
.env, # Environment directory used by some tools
.git, # Version control directory
.github, # GitHub metadata directory
.env,
.git,
.github,
.gradle,
.hg, # Mercurial directory
.mypy_cache, # MyPy cache directory
.pytest_cache, # PyTest cache directory
.svn, # Subversion directory
.hg,
.mypy_cache,
.pytest_cache,
.svn,
.tox,
.venv, # Common virtual environment directory
.vscode, # VS Code configuration directory
*__pycache__, # Python cache directory
.venv,
.vscode,
*__pycache__,
*.egg-info,
*.pyc,
build,
dist,
htmlcov.*,

# List of application-specific import names.
application-import-names = flake8
# Import statement format style.
Expand Down
26 changes: 21 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,27 @@ jobs:
with:
python-version: "3.10"

- name: Cache pip dependencies
uses: actions/cache@v3
with:
path: ~/.cache/pip
# key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
key: ${{ runner.os }}-pip-
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install pre-commit
pre-commit install
- name: Cache shfmt binary
uses: actions/cache@v3
with:
path: /usr/local/bin/shfmt
# key: ${{ runner.os }}-shfmt-${{ env.SHFMT_VERSION }}
key: ${{ runner.os }}-shfmt-

- name: Install shfmt
run: |
SHFMT_VERSION="v3.7.0"
Expand All @@ -38,8 +54,8 @@ jobs:
- name: Run pre-commits
run: |
pre-commit run --all-files
# pre-commit run --from-ref origin/main --to-ref HEAD
# run: |
# BASE_COMMIT_ID=$(git rev-parse origin/main)
# pre-commit run --from-ref ${{ env.BASE_COMMIT_ID }} --to-ref HEAD
CUR_SHA=$(git log --pretty=tformat:"%H" -n1 .)
echo $CUR_SHA
echo ${{ env.BASE_COMMIT_ID }}
git fetch
pre-commit run --from-ref origin/main --to-ref $CUR_SHA
7 changes: 7 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ jobs:
- name: Print Runner OS
run: echo "Runner OS is ${{ runner.os }}"

- name: Cache target dir
uses: actions/cache@v3
with:
path: |
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Build Release
run: cargo build --release

Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,16 @@ target/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock
# Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb


##########################################################################################
# Misc
##########################################################################################
tmp*
37 changes: 16 additions & 21 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@ repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-ast # Validates the syntax of Python files.
- id: check-case-conflict # Identifies potential case-insensitive file name conflicts.
- id: check-merge-conflict # Searches for merge conflict markers within files.
- id: check-symlinks # Detects broken symlinks.
- id: check-added-large-files # Blocks commits that add large files. Default limit is 500kB.
args: ["--maxkb=1300"]
# Can be configured with args, e.g., '--maxkb=1000' to change the limit.
# Files in 'your_dir/' can be excluded.
# exclude: 'your_dir/.*'
- id: end-of-file-fixer # Ensures files end with a single newline or are empty.
# args: ['--maxkb=5000']
- id: check-case-conflict # Identifies potential case-insensitive file name conflicts.
- id: check-ast # Validates the syntax of Python files.
- id: check-symlinks # Detects broken symlinks.
- id: trailing-whitespace # Removes any trailing whitespace at the end of lines.
- id: end-of-file-fixer # Ensures files end with a single newline or are empty.

#############################################################################
# JSON, TOML
Expand Down Expand Up @@ -48,15 +47,15 @@ repos:
- repo: https://github.com/PyCQA/autoflake
rev: v2.2.1
hooks:
- id: autoflake # Removes unused imports and unused variables from Python code
- id: autoflake # Removes unused imports and unused variables from Python code.
args:
- --in-place
- --remove-all-unused-imports

- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort # Sorts Python imports into sections and by alphabetical order
- id: isort # Sorts Python imports into sections and by alphabetical order.
args:
- --settings-path
- pyproject.toml
Expand All @@ -66,7 +65,7 @@ repos:
- repo: https://github.com/psf/black
rev: 23.10.1
hooks:
- id: black # Formats Python code to conform to the Black code style
- id: black # Formats Python code to conform to the Black code style.
args:
- --config
- pyproject.toml
Expand All @@ -76,42 +75,38 @@ repos:
- repo: https://github.com/pycqa/flake8
rev: 6.1.0
hooks:
- id: flake8 # Lints Python code for errors and code style issues based on PEP8
- id: flake8 # Lints Python code for errors and code style issues based on PEP8.
args:
- --config=.cpa/flake8.cfg
types:
- python

# - repo: https://github.com/astral-sh/ruff-pre-commit
# # Ruff version.
# rev: v0.0.270
# rev: v0.1.4
# hooks:
# - id: ruff

# - repo: https://github.com/python-poetry/poetry
# rev: '1.4.0'
# rev: '1.7.0'
# hooks:
# # https://python-poetry.org/docs/master/pre-commit-hooks/
# # These hooks ensure that our dependencies are being updated only thru poetry.
# - id: poetry-check # Makes sure the poetry configuration does not get committed in a broken state.
# # - id: poetry-lock # Makes sure the lock file is up-to-date when committing changes.
# - id: poetry-lock # Ensures the poetry.lock file is up-to-date with the pyproject.toml changes.

#############################################################################
# CSS, Markdown, JavaScript, TypeScript, YAML style formatter
#############################################################################
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.3
hooks:
- id: prettier
- id: prettier # An opinionated code formatter supporting multiple languages.
name: prettier
entry: prettier
args: [--config, .cpa/prettier.json, --write]
types_or:
- javascript
- css
- scss
- ts
- tsx
- scss
- css
- javascript
- yaml
- markdown
exclude: templates/.pre-commit-config.yaml
Expand Down
Loading