-
Notifications
You must be signed in to change notification settings - Fork 15
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
Pre-commit demo #187
base: main
Are you sure you want to change the base?
Pre-commit demo #187
Changes from all commits
fb59f68
7ffc000
b585ad9
7757d59
609af5a
8365673
994fab9
db68ea8
80cbb46
f7dd653
569551b
ebcfa21
6df9915
eae4230
b9b8c67
ec6e2f4
8a6e552
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,30 @@ | ||
--- | ||
name: "Lint" | ||
on: # yamllint disable-line rule:truthy | ||
on: # yamllint disable-line rule:truthy | ||
push: | ||
branches: | ||
- "main" | ||
pull_request: | ||
branches: ["*"] | ||
jobs: | ||
lint: | ||
name: "Format & Lint" | ||
# Uses pre-commit to run all checks | ||
runs-on: "ubuntu-latest" | ||
strategy: | ||
matrix: | ||
python-version: | ||
- "3.10" | ||
fail-fast: false | ||
vroldanbet marked this conversation as resolved.
Show resolved
Hide resolved
|
||
steps: | ||
- uses: "actions/checkout@v4" | ||
- uses: "bewuethr/[email protected]" | ||
- name: "Install Poetry" | ||
uses: "snok/install-poetry@v1" | ||
with: | ||
config-file: ".yamllint" | ||
# This should come from pyproject.toml but poetry | ||
# wasn't picking it up for whatever reason. | ||
virtualenvs-in-project: true | ||
virtualenvs-path: ".venv" | ||
Comment on lines
+15
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not super happy about this, but poetry doesn't otherwise seem to properly respect the pyproject.toml settings for this. |
||
- uses: "actions/setup-python@v5" | ||
with: | ||
python-version: "3.10" | ||
- name: "Setup Python Environment" | ||
run: "pip install -U pip virtualenv" | ||
- name: "Install Dependencies" | ||
run: | | ||
virtualenv ~/.cache/virtualenv/authzedpy | ||
source ~/.cache/virtualenv/authzedpy/bin/activate | ||
pip install poetry | ||
poetry env info | ||
poetry install --only dev | ||
- name: "Pyflakes" | ||
run: | | ||
source ~/.cache/virtualenv/authzedpy/bin/activate | ||
find . -name "*.py" | grep -v "_pb2" | xargs pyflakes | ||
- name: "Blacken" | ||
run: | | ||
source ~/.cache/virtualenv/authzedpy/bin/activate | ||
black --check --diff . | ||
- name: "Isort" | ||
run: | | ||
source ~/.cache/virtualenv/authzedpy/bin/activate | ||
find . -name "*.py" | grep -v "_pb2" | xargs isort --check --diff | ||
python-version: "3.11" | ||
cache: 'poetry' | ||
- run: "poetry install" | ||
- uses: "pre-commit/[email protected]" | ||
vroldanbet marked this conversation as resolved.
Show resolved
Hide resolved
|
||
codeql: | ||
name: "Analyze with CodeQL" | ||
runs-on: "ubuntu-latest" | ||
|
@@ -75,24 +56,3 @@ jobs: | |
uses: "github/codeql-action/upload-sarif@v3" | ||
with: | ||
sarif_file: "trivy-results.sarif" | ||
mypy: | ||
vroldanbet marked this conversation as resolved.
Show resolved
Hide resolved
|
||
name: "Type Check with Mypy" | ||
runs-on: "ubuntu-latest" | ||
steps: | ||
- uses: "actions/checkout@v4" | ||
- uses: "actions/setup-python@v5" | ||
with: | ||
python-version: "3.10" | ||
- name: "Setup Python Environment" | ||
run: "pip install -U pip virtualenv" | ||
- name: "Install Dependencies" | ||
run: | | ||
virtualenv ~/.cache/virtualenv/authzedpy | ||
source ~/.cache/virtualenv/authzedpy/bin/activate | ||
pip install poetry | ||
poetry env info | ||
poetry install --only dev | ||
- name: "mypy" | ||
run: | | ||
source ~/.cache/virtualenv/authzedpy/bin/activate | ||
mypy authzed |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the configuration that will differ across repos. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
repos: | ||
- repo: "https://github.com/astral-sh/ruff-pre-commit" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I switched from black + pyflakes + isort to ruff, which is the current state-of-the-art for python linting and formatting. It's written in rust, opinionated in mostly sane ways, and is hella fast. |
||
# Ruff version. | ||
rev: "v0.6.1" | ||
hooks: | ||
# Run the linter. | ||
- id: "ruff" | ||
exclude: ".*_pb2.*" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ignore the generated files |
||
# Run the formatter. | ||
- id: "ruff-format" | ||
exclude: ".*_pb2.*" | ||
- repo: "https://github.com/adrienverge/yamllint" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can run yamllint through here as well |
||
rev: "v1.35.1" | ||
hooks: | ||
- id: "yamllint" | ||
- repo: "https://github.com/RobertCraigie/pyright-python" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also swapped from mypy to pyright - pyright is the one that vscode uses, and it's got some performance and typing benefits over mypy. There's a comparison here: https://github.com/microsoft/pyright/blob/main/docs/mypy-comparison.md |
||
rev: "v1.1.376" | ||
hooks: | ||
- id: "pyright" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why removal of the name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No strong reason - it was when i was deleting and replacing chunks of the configuration. I can reinstate it.