Skip to content

Commit

Permalink
Merge pull request #211 from pythoninthegrass/main
Browse files Browse the repository at this point in the history
refactor: tooling
  • Loading branch information
moraroy authored Feb 21, 2024
2 parents 4cc95df + 61e19be commit 6177b9c
Show file tree
Hide file tree
Showing 19 changed files with 4,362 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "Dev Environment",
"build": {
"dockerfile": "Dockerfile"
"dockerfile": "../Dockerfile"
},
"customizations": {
"vscode": {
Expand Down
21 changes: 0 additions & 21 deletions .devcontainer/requirements.txt

This file was deleted.

File renamed without changes.
25 changes: 25 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Release Please

on:
push:
branches:
- 'main'

permissions:
contents: write
pull-requests: write

jobs:
release-please:
runs-on: ubuntu-latest

steps:
- name: Release with release-please
uses: google-github-actions/release-please-action@v4
with:
# PAT with write access to the repository
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
# optional. customize path to release-please-config.json
config-file: release-please-config.json
# optional. customize path to .release-please-manifest.json
manifest-file: .release-please-manifest.json
131 changes: 131 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,134 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
43 changes: 43 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
fail_fast: true

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.2
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-yaml
- id: check-added-large-files
args: ['--maxkb=1024']
- id: check-docstring-first
exclude: |
(?x)^(
hello.py
)$
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: check-symlinks
- id: check-toml
- id: check-yaml
args: [--unsafe]
- id: debug-statements
- id: destroyed-symlinks
- id: detect-private-key
- id: end-of-file-fixer
- id: fix-byte-order-marker
- id: mixed-line-ending
- id: pretty-format-json
# https://pre-commit.com/#regular-expressions
exclude: |
(?x)^(
.devcontainer/devcontainer.json|
.vscode/launch.json|
.vscode/settings.json|
.vscode/extensions.json
)$
args: ['--autofix', '--indent=2', '--no-sort-keys']
- id: requirements-txt-fixer
3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "3.8.0"
}
5 changes: 3 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
python 3.11.4
poetry 1.5.1
python 3.11.6
poetry 1.7.1
nodejs 21.4.0
18 changes: 18 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"recommendations": [
"aaron-bond.better-comments",
"codezombiech.gitignore",
"eamodio.gitlens",
"EditorConfig.EditorConfig",
"GitHub.copilot-chat",
"GitHub.copilot",
"mads-hartmann.bash-ide-vscode",
"ms-azuretools.vscode-docker",
"ms-python.python",
"ms-vscode.atom-keybindings",
"ms-vsliveshare.vsliveshare",
"redhat.vscode-yaml",
"timonwong.shellcheck",
"yzhang.markdown-all-in-one"
]
}
File renamed without changes.
99 changes: 86 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,32 +170,105 @@ source .venv/bin/activate
python -m pip install -r requirements.txt
```

### Pre-commit hooks

Pre-commit hooks are installed via `pre-commit` and are run automatically on `git commit`.

Most importantly, `ruff` is used to lint all python code.

* Install [pre-commit](https://pre-commit.com/#install)
* Install pre-commit hooks
```bash
pre-commit install
```
* Trigger pre-commit hooks automatically on `git commit`
```bash
git add .
git commit -m "commit message"
```
* Bypass pre-commit hooks
* Sometimes, it's necessary to bypass pre-commit hooks. This can be done with the `--no-verify` flag.
```bash
git commit -m "commit message" --no-verify
```
### Conventional Commits
While not currently enforced, by using [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/#summary), it's possible to automatically generate changelogs and version numbers via [release-please](https://github.com/googleapis/release-please).

To help with that, the [commitizen](https://commitizen-tools.github.io/commitizen/) tool can be installed.

#### Usage

```bash
# install cz
npm install -g commitizen cz-conventional-changelog
# make repo cz friendly
commitizen init cz-conventional-changelog --save-dev --save-exact
npm install
# add file to commit
git add .gitignore
# run cz
λ git cz
[email protected], [email protected]
? Select the type of change that you're committing: chore: Other changes that don't modify src or test files
? What is the scope of this change (e.g. component or file name): (press enter to skip) .gitignore
? Write a short, imperative tense description of the change (max 81 chars):
(17) update .gitignore
? Provide a longer description of the change: (press enter to skip)
? Are there any breaking changes? No
? Does this change affect any open issues? No
[main 0a9920d] chore(.gitignore): update .gitignore
1 file changed, 131 insertions(+)
λ git push
```

### Formatting

> **TL;DR**: The [Ruff formatter](https://astral.sh/blog/the-ruff-formatter) is an extremely fast Python formatter, written in Rust. It’s over 30x faster than Black and 100x faster than YAPF, formatting large-scale Python projects in milliseconds — all while achieving >99.9% Black compatibility.

* While it runs automatically on commits, it can also be run manually
```bash
# check for errors
ruff check .
# fix (some) errors automatically
ruff check . --fix
```

### Additional tooling

Additional tooling includes but is not limited to:
#### TODO

* Add [devbox](https://www.jetpack.io/devbox/) 👌

#### asdf

* Install [asdf](https://asdf-vm.com/guide/getting-started.html#_2-download-asdf)
* Usage
* Add plugins
```bash
# add python plugin
asdf plugin-add python

asdf plugin-add poetry https://github.com/asdf-community/asdf-poetry.git
asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git
```
* Usage
* Install local plugins in repo
```bash
asdf install
```
* Install specific plugins
```bash
# install stable python
asdf install python <latest|3.11.4>
# set stable to system python
asdf global python latest

# add poetry asdf plugin
asdf plugin-add poetry https://github.com/asdf-community/asdf-poetry.git

# install latest version via asdf
asdf install poetry <latest|1.5.1>

# set latest version as default
asdf global poetry latest
```

#### shellcheck
Expand Down
2 changes: 2 additions & 0 deletions config.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# TODO: export all dynamic vars from NonSteamLaunchers.sh here
# TODO: read into main.py or config.py (latter's preferable)
Loading

0 comments on commit 6177b9c

Please sign in to comment.