Skip to content

Commit c753e75

Browse files
Update README.md
1 parent 077eef7 commit c753e75

File tree

2 files changed

+72
-9
lines changed

2 files changed

+72
-9
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ repos:
4040
- id: pretty-format-json
4141
args: ['--autofix', '--indent=2', '--no-sort-keys']
4242
- id: requirements-txt-fixer
43-
- id: trailing-whitespace
43+
# - id: trailing-whitespace

README.md

Lines changed: 71 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Be the change et al if Windows is your main and you wanna raise a PR with broad
3333
* [MongoDB](#mongodb)
3434
* [Kubernetes (k8s)](#kubernetes-k8s)
3535
* [Terraform](#terraform)
36+
* [git pre-commit hooks](#git-pre-commit-hooks)
3637
* [GitHub Actions](#github-actions)
3738
* [Update submodules recursively](#update-submodules-recursively)
3839
* [Debugging](#debugging)
@@ -44,7 +45,7 @@ Be the change et al if Windows is your main and you wanna raise a PR with broad
4445
* [Further Reading](#further-reading)
4546

4647
## Setup
47-
* Install
48+
* Install
4849
* [editorconfig](https://editorconfig.org/)
4950
* [wsl](https://docs.microsoft.com/en-us/windows/wsl/setup/environment)
5051
* [asdf](https://asdf-vm.com/guide/getting-started.html#_2-download-asdf)
@@ -58,7 +59,7 @@ Be the change et al if Windows is your main and you wanna raise a PR with broad
5859
Development environments and tooling are first-class citizens on macOS and *nix. For Windows faithfuls, please setup WSL below.
5960

6061
### Windows Subsytem for Linux (wsl)
61-
WSL allows Windows users to run Linux (Unix) [locally at a system-level](https://docs.microsoft.com/en-us/windows/wsl/compare-versions). All of the standard tooling is used and community guides can be followed without standard Windows caveats (e.g., escaping file paths, GNU utilities missing, etc.)
62+
WSL allows Windows users to run Linux (Unix) [locally at a system-level](https://docs.microsoft.com/en-us/windows/wsl/compare-versions). All of the standard tooling is used and community guides can be followed without standard Windows caveats (e.g., escaping file paths, GNU utilities missing, etc.)
6263
* Install from the [Setup](#setup) section
6364
* Enable
6465
* Start Menu > search for "Turn Windows Features On" > open > toggle "Windows Subsystem for Linux"
@@ -200,7 +201,7 @@ deactivate
200201
* Normal usage
201202
```bash
202203
# Install (modifies $PATH)
203-
curl -sSL https://install.python-poetry.org | $(which python3) - # append `--no-modify-path` to EOL if you know what you're doing
204+
curl -sSL https://install.python-poetry.org | $(which python3) - # append `--no-modify-path` to EOL if you know what you're doing
204205
205206
# Install via asdf w/version
206207
asdf plugin-add poetry https://github.com/asdf-community/asdf-poetry.git
@@ -385,7 +386,7 @@ deactivate
385386
![Main screen](img/k9s_main.png)
386387
* Describe a pod: `d`
387388
![Describe a pod](img/k9s_describe.png)
388-
* Delete a pod:
389+
* Delete a pod:
389390
* `ctrl-d`
390391
* Replicas rebuild
391392
![Delete a pod](img/k9s_delete_pod.png)
@@ -405,10 +406,10 @@ deactivate
405406
```
406407
* Navigate to https://jade-shooter.rancher.localhost/ in Chrome
407408
* Allow self-signed cert
408-
* Profit 💸
409+
* Profit 💸
409410
410411
### Terraform
411-
* **NOTES**:
412+
* **NOTES**:
412413
* This section depends on Kubernetes and a `~/.kubeconfig` from [above](#kubernetes-k8s)
413414
* `NodePort` was used instead of `LoadBalancer` for `service.type`
414415
* [MetalLB is a stretch goal](https://stackoverflow.com/a/71047314) for future deployments
@@ -452,6 +453,56 @@ deactivate
452453
* Real-time view of pod removal
453454
![Real-time view of pod removal](img/k9s_termination.png)
454455
456+
## git pre-commit hooks
457+
* Install
458+
```bash
459+
# pip
460+
pip install pre-commit
461+
462+
# brew
463+
brew install pre-commit
464+
465+
# install .pre-commit-config.yaml
466+
pre-commit install # install/uninstall
467+
```
468+
* Usage
469+
```bash
470+
# skip pre-commit by ID
471+
SKIP=flake8 git commit -m "foo"
472+
473+
# skip all pre-commit hooks (e.g., bypass false positives like comment preceding docstring)
474+
λ git commit -m "Formatting (WIP)" -m "Debugging formatters" --no-verify
475+
[master d260d56] Formatting (WIP)
476+
1 file changed, 108 insertions(+), 34 deletions(-)
477+
478+
# black dry-run
479+
black --check --diff file_name.py
480+
481+
# skip code block
482+
# fmt: off
483+
484+
import argparse
485+
# from icecream import ic
486+
from pathlib import Path
487+
488+
# fmt: on
489+
490+
# skip individual line (buggy)
491+
# from icecream import ic # fmt: skip
492+
493+
# manually run commit hook against one file
494+
pre-commit run black --files email_it/email_it.py --verbose
495+
496+
# manually run against repo (vs. during commit)
497+
λ pre-commit run --all-files
498+
[INFO] Initializing environment for https://github.com/zricethezav/gitleaks.
499+
<SNIP>
500+
Detect hardcoded secrets.................................................Passed
501+
502+
# update hooks
503+
pre-commit autoupdate
504+
```
505+
455506
## GitHub Actions
456507
### Update submodules recursively
457508
* Add the submodule to the downstream repo
@@ -477,7 +528,7 @@ deactivate
477528
478529
on:
479530
push:
480-
branches:
531+
branches:
481532
- main
482533
- master
483534
@@ -487,7 +538,7 @@ deactivate
487538
488539
steps:
489540
- uses: actions/checkout@v2
490-
with:
541+
with:
491542
repository: username/repo_name
492543
token: ${{ secrets.PRIVATE_TOKEN_GITHUB }}
493544
@@ -616,6 +667,18 @@ deactivate
616667
617668
[Python MongoDB](https://www.w3schools.com/python/python_mongodb_getstarted.asp)
618669
670+
[The 10 tools I wish I knew when I started working with Python | Python in Plain English](https://python.plainenglish.io/10-tools-to-help-claw-your-way-back-to-sanity-while-coding-python-df0af160c33e)
671+
672+
[pre-commit](https://pre-commit.com)
673+
674+
[How to use git pre-commit hooks, the hard way and the easy way | Verdant Fox](https://verdantfox.com/blog/view/how-to-use-git-pre-commit-hooks-the-hard-way-and-the-easy-way)
675+
676+
[The Black Code Style](https://black.readthedocs.io/en/stable/the_black_code_style/)
677+
678+
[How to Auto-Format Your Python Code with Black](https://www.freecodecamp.org/news/auto-format-your-python-code-with-black/)
679+
680+
[Options - isort](https://pycqa.github.io/isort/docs/configuration/options.html)
681+
619682
[Learn GitHub Actions - GitHub Docs](https://docs.github.com/en/actions/learn-github-actions)
620683
621684
[Using scripts to test your code on a runner - GitHub Docs](https://docs.github.com/en/actions/examples/using-scripts-to-test-your-code-on-a-runner)

0 commit comments

Comments
 (0)