Skip to content

Commit 1813c6e

Browse files
authored
v003 (#2)
* clean * add version * clean * clean * clean * clean * clean * save * clean * clean * cache target dir * clean * clean * clean * clean
1 parent 2ff40cf commit 1813c6e

21 files changed

Lines changed: 721 additions & 166 deletions

.cpa/flake8.cfg

Lines changed: 51 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,66 @@
11
[flake8]
2-
ignore = E203,E231,E501,I100,I201,I202,D102,D100,C901,D104,D101,D105,D107,D400,D103,D205,W503,E402,E266,F841
3-
# E203 whitespace before ':'. Conflicts with how Black formats slicing.
4-
# E231 missing whitespace after ',', ';', or ':'. Conflicts with Black.
5-
# E501 line too long (82 > 79 characters). Ignored because max-line-length is set.
6-
# I100 Import statements are in the wrong order.
7-
# I201 Missing newline between import groups.
8-
# I202 Additional newline in a group of imports.
9-
# D102 Missing docstring in public method.
10-
# D100 Missing docstring in public module.
11-
# C901 function is too complex. Ignored because max-complexity is set.
12-
# D104 Missing docstring in public package.
13-
# D101 Missing docstring in public class.
14-
# D105 Missing docstring in magic method.
15-
# D107 Missing docstring in __init__.
16-
# D400 First line should end with a period.
17-
# D103 Missing docstring in public function.
18-
# D205 1 blank line required between summary line and description.
19-
# W503 line break before binary operator. This is no longer PEP 8 compliant.
20-
# E402 module level import not at top of file.
21-
# E266 too many leading '#' for block comment.
22-
# F841 local variable is assigned to but never used.
2+
ignore =
3+
# C901, # function is too complex. Ignored because max-complexity is set.
4+
D100,
5+
# Missing docstring in public module.
6+
D101,
7+
# Missing docstring in public class.
8+
D102,
9+
# Missing docstring in public method.
10+
D103,
11+
# Missing docstring in public function.
12+
D104,
13+
# Missing docstring in public package.
14+
D105,
15+
# Missing docstring in magic method.
16+
D107,
17+
# Missing docstring in __init__.
18+
D205,
19+
# 1 blank line required between summary line and description.
20+
D400,
21+
# First line should end with a period.
22+
E203,
23+
# whitespace before ':'. Conflicts with how Black formats slicing.
24+
E231,
25+
# missing whitespace after ',', ';', or ':'. Conflicts with Black.
26+
E266,
27+
# too many leading '#' for block comment.
28+
E402,
29+
# module level import not at top of file.
30+
E501,
31+
# line too long (82 > 79 characters). Ignored because max-line-length is set.
32+
F841,
33+
# local variable is assigned to but never used.
34+
I100,
35+
# Import statements are in the wrong order.
36+
I201,
37+
# Missing newline between import groups.
38+
I202,
39+
# Additional newline in a group of imports.
40+
W503
41+
# line break before binary operator. This is no longer PEP 8 compliant.
2342

2443
exclude =
2544
.cache,
2645
.coverage.*,
27-
.env, # Environment directory used by some tools
28-
.git, # Version control directory
29-
.github, # GitHub metadata directory
46+
.env,
47+
.git,
48+
.github,
3049
.gradle,
31-
.hg, # Mercurial directory
32-
.mypy_cache, # MyPy cache directory
33-
.pytest_cache, # PyTest cache directory
34-
.svn, # Subversion directory
50+
.hg,
51+
.mypy_cache,
52+
.pytest_cache,
53+
.svn,
3554
.tox,
36-
.venv, # Common virtual environment directory
37-
.vscode, # VS Code configuration directory
38-
*__pycache__, # Python cache directory
55+
.venv,
56+
.vscode,
57+
*__pycache__,
3958
*.egg-info,
4059
*.pyc,
4160
build,
4261
dist,
4362
htmlcov.*,
63+
4464
# List of application-specific import names.
4565
application-import-names = flake8
4666
# Import statement format style.

.github/workflows/ci.yaml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,27 @@ jobs:
2323
with:
2424
python-version: "3.10"
2525

26+
- name: Cache pip dependencies
27+
uses: actions/cache@v3
28+
with:
29+
path: ~/.cache/pip
30+
# key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
31+
key: ${{ runner.os }}-pip-
32+
restore-keys: |
33+
${{ runner.os }}-pip-
34+
2635
- name: Install dependencies
2736
run: |
2837
python -m pip install pre-commit
2938
pre-commit install
3039
40+
- name: Cache shfmt binary
41+
uses: actions/cache@v3
42+
with:
43+
path: /usr/local/bin/shfmt
44+
# key: ${{ runner.os }}-shfmt-${{ env.SHFMT_VERSION }}
45+
key: ${{ runner.os }}-shfmt-
46+
3147
- name: Install shfmt
3248
run: |
3349
SHFMT_VERSION="v3.7.0"
@@ -38,8 +54,8 @@ jobs:
3854
3955
- name: Run pre-commits
4056
run: |
41-
pre-commit run --all-files
42-
# pre-commit run --from-ref origin/main --to-ref HEAD
43-
# run: |
44-
# BASE_COMMIT_ID=$(git rev-parse origin/main)
45-
# pre-commit run --from-ref ${{ env.BASE_COMMIT_ID }} --to-ref HEAD
57+
CUR_SHA=$(git log --pretty=tformat:"%H" -n1 .)
58+
echo $CUR_SHA
59+
echo ${{ env.BASE_COMMIT_ID }}
60+
git fetch
61+
pre-commit run --from-ref origin/main --to-ref $CUR_SHA

.github/workflows/release.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ jobs:
3939
- name: Print Runner OS
4040
run: echo "Runner OS is ${{ runner.os }}"
4141

42+
- name: Cache target dir
43+
uses: actions/cache@v3
44+
with:
45+
path: |
46+
target
47+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
48+
4249
- name: Build Release
4350
run: cargo build --release
4451

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,16 @@ target/
174174

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

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

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

185+
186+
##########################################################################################
187+
# Misc
188+
##########################################################################################
185189
tmp*

.pre-commit-config.yaml

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,16 @@ repos:
88
- repo: https://github.com/pre-commit/pre-commit-hooks
99
rev: v4.5.0
1010
hooks:
11-
- id: check-ast # Validates the syntax of Python files.
12-
- id: check-case-conflict # Identifies potential case-insensitive file name conflicts.
1311
- id: check-merge-conflict # Searches for merge conflict markers within files.
14-
- id: check-symlinks # Detects broken symlinks.
1512
- id: check-added-large-files # Blocks commits that add large files. Default limit is 500kB.
16-
args: ["--maxkb=1300"]
1713
# Can be configured with args, e.g., '--maxkb=1000' to change the limit.
18-
# Files in 'your_dir/' can be excluded.
1914
# exclude: 'your_dir/.*'
20-
- id: end-of-file-fixer # Ensures files end with a single newline or are empty.
15+
# args: ['--maxkb=5000']
16+
- id: check-case-conflict # Identifies potential case-insensitive file name conflicts.
17+
- id: check-ast # Validates the syntax of Python files.
18+
- id: check-symlinks # Detects broken symlinks.
2119
- id: trailing-whitespace # Removes any trailing whitespace at the end of lines.
20+
- id: end-of-file-fixer # Ensures files end with a single newline or are empty.
2221

2322
#############################################################################
2423
# JSON, TOML
@@ -48,15 +47,15 @@ repos:
4847
- repo: https://github.com/PyCQA/autoflake
4948
rev: v2.2.1
5049
hooks:
51-
- id: autoflake # Removes unused imports and unused variables from Python code
50+
- id: autoflake # Removes unused imports and unused variables from Python code.
5251
args:
5352
- --in-place
5453
- --remove-all-unused-imports
5554

5655
- repo: https://github.com/pycqa/isort
5756
rev: 5.12.0
5857
hooks:
59-
- id: isort # Sorts Python imports into sections and by alphabetical order
58+
- id: isort # Sorts Python imports into sections and by alphabetical order.
6059
args:
6160
- --settings-path
6261
- pyproject.toml
@@ -66,7 +65,7 @@ repos:
6665
- repo: https://github.com/psf/black
6766
rev: 23.10.1
6867
hooks:
69-
- id: black # Formats Python code to conform to the Black code style
68+
- id: black # Formats Python code to conform to the Black code style.
7069
args:
7170
- --config
7271
- pyproject.toml
@@ -76,42 +75,38 @@ repos:
7675
- repo: https://github.com/pycqa/flake8
7776
rev: 6.1.0
7877
hooks:
79-
- id: flake8 # Lints Python code for errors and code style issues based on PEP8
78+
- id: flake8 # Lints Python code for errors and code style issues based on PEP8.
8079
args:
8180
- --config=.cpa/flake8.cfg
8281
types:
8382
- python
8483

8584
# - repo: https://github.com/astral-sh/ruff-pre-commit
86-
# # Ruff version.
87-
# rev: v0.0.270
85+
# rev: v0.1.4
8886
# hooks:
8987
# - id: ruff
9088

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

9995
#############################################################################
10096
# CSS, Markdown, JavaScript, TypeScript, YAML style formatter
10197
#############################################################################
10298
- repo: https://github.com/pre-commit/mirrors-prettier
10399
rev: v3.0.3
104100
hooks:
105-
- id: prettier
101+
- id: prettier # An opinionated code formatter supporting multiple languages.
106102
name: prettier
107-
entry: prettier
108103
args: [--config, .cpa/prettier.json, --write]
109104
types_or:
110-
- javascript
105+
- css
106+
- scss
111107
- ts
112108
- tsx
113-
- scss
114-
- css
109+
- javascript
115110
- yaml
116111
- markdown
117112
exclude: templates/.pre-commit-config.yaml

0 commit comments

Comments
 (0)