Skip to content
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
9 changes: 5 additions & 4 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
jobs:
pre-commit:
runs-on: ubuntu-latest
name: Run pre-commit hooks on Go, Rust, JavaScripts, Markdown and Python files
name: Run pre-commit hooks check file lint

steps:
- name: Check out the repo
Expand Down Expand Up @@ -47,6 +47,7 @@ jobs:
build-essential \
pkg-config
npm install -g markdownlint-cli
pip install --user yamllint

- name: Cache Rust dependencies
uses: actions/cache@v4
Expand Down Expand Up @@ -82,10 +83,10 @@ jobs:
- name: Install pre-commit
run: pip install pre-commit

- name: Run pre-commit on Go, Rust, JavaScript, Markdown and Python files
- name: Run pre-commit on Go, Rust, JavaScript, Markdown, Yaml and Python files
run: |
# Find all Go, Rust, JavaScripts, Markdown and Python files (excluding vendored/generated code)
FILES=$(find . -type f \( -name "*.go" -o -name "*.rs" -o -name "*.py" -o -name "*.js" -o -name "*.md" \) \
FILES=$(find . -type f \( -name "*.go" -o -name "*.rs" -o -name "*.py" -o -name "*.js" -o -name "*.md" -o -name "*.yaml" -o -name "*.yml" \) \
! -path "./target/*" \
! -path "./candle-binding/target/*" \
! -path "./.git/*" \
Expand All @@ -100,7 +101,7 @@ jobs:
echo "Running pre-commit on files: $FILES"
pre-commit run --files $FILES
else
echo "No Go, Rust, JavaScript, Markdown or Python files found to check"
echo "No Go, Rust, JavaScript, Markdown, Yaml, or Python files found to check"
fi

- name: Show pre-commit results
Expand Down
136 changes: 73 additions & 63 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,79 +2,89 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
# Basic hooks for Go, Rust, Python And JavaScript files only
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: trailing-whitespace
files: \.(go|rs|py|js)$
- id: end-of-file-fixer
files: \.(go|rs|py|js)$
- id: check-added-large-files
args: ['--maxkb=500']
files: \.(go|rs|py|js)$
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: trailing-whitespace
files: \.(go|rs|py|js)$
- id: end-of-file-fixer
files: \.(go|rs|py|js)$
- id: check-added-large-files
args: ['--maxkb=500']
files: \.(go|rs|py|js)$

# Go specific hooks
- repo: local
hooks:
- id: go-fmt
name: go fmt
entry: gofmt -w
language: system
files: \.go$
- repo: local
hooks:
- id: go-fmt
name: go fmt
entry: gofmt -w
language: system
files: \.go$

# Markdown specific hooks
- repo: local
hooks:
- id: md-fmt
name: md fmt
entry: bash -c "make markdown-lint"
language: system
files: \.md$
exclude: ^(\node_modules/)
- repo: local
hooks:
- id: md-fmt
name: md fmt
entry: bash -c "make markdown-lint"
language: system
files: \.md$
exclude: ^(\node_modules/)

# Yaml specific hooks
- repo: local
hooks:
- id: yaml-and-yml-fmt
name: yaml/yml fmt
entry: bash -c "make markdown-lint"
language: system
files: \.(yaml|yml)$
exclude: ^(\node_modules/)

# JavaScript specific hooks
- repo: local
hooks:
- id: js-lint
name: js lint
entry: bash -c 'cd website && npm install 2>/dev/null || true && npm run lint'
language: system
files: \.js$
exclude: ^(\node_modules/)
pass_filenames: false
- repo: local
hooks:
- id: js-lint
name: js lint
entry: bash -c 'cd website && npm install 2>/dev/null || true && npm run lint'
language: system
files: \.js$
exclude: ^(\node_modules/)
pass_filenames: false

# Rust specific hooks
- repo: local
hooks:
- id: cargo-fmt
name: cargo fmt
entry: bash -c 'cd candle-binding && rustup component add rustfmt 2>/dev/null || true && cargo fmt'
language: system
files: \.rs$
pass_filenames: false
- id: cargo-check
name: cargo check
entry: bash -c 'cd candle-binding && cargo check'
language: system
files: \.rs$
pass_filenames: false
# Rust specific hooks
- repo: local
hooks:
- id: cargo-fmt
name: cargo fmt
entry: bash -c 'cd candle-binding && rustup component add rustfmt 2>/dev/null || true && cargo fmt'
language: system
files: \.rs$
pass_filenames: false
- id: cargo-check
name: cargo check
entry: bash -c 'cd candle-binding && cargo check'
language: system
files: \.rs$
pass_filenames: false

# Python specific hooks
- repo: https://github.com/psf/black
rev: 25.1.0
hooks:
- id: black
language_version: python3
files: \.py$
exclude: ^(\.venv/|venv/|env/|__pycache__/|\.git/|site/)
- repo: https://github.com/psf/black
rev: 25.1.0
hooks:
- id: black
language_version: python3
files: \.py$
exclude: ^(\.venv/|venv/|env/|__pycache__/|\.git/|site/)

- repo: https://github.com/PyCQA/isort
rev: 6.0.1
hooks:
- id: isort
args: ["--profile", "black"]
files: \.py$
exclude: ^(\.venv/|venv/|env/|__pycache__/|\.git/|site/)
- repo: https://github.com/PyCQA/isort
rev: 6.0.1
hooks:
- id: isort
args: ["--profile", "black"]
files: \.py$
exclude: ^(\.venv/|venv/|env/|__pycache__/|\.git/|site/)

# Commented out flake8 - only reports issues, doesn't auto-fix
# - repo: https://github.com/PyCQA/flake8
Expand Down
57 changes: 57 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
ignore: |
# This directory fails checks since many files
# are templated. Instead, we run the linter
# after running `make generate-manifests` which creates
# the Install YAML in bin/
.git
.github
node_modules

rules:
braces:
min-spaces-inside: 0
max-spaces-inside: 0
min-spaces-inside-empty: -1
max-spaces-inside-empty: -1
brackets:
min-spaces-inside: 0
max-spaces-inside: 1
min-spaces-inside-empty: -1
max-spaces-inside-empty: -1
colons:
max-spaces-before: 0
max-spaces-after: 1
commas:
max-spaces-before: 1
min-spaces-after: 1
max-spaces-after: 1
comments:
level: warning
require-starting-space: true
min-spaces-from-content: 2
comments-indentation:
level: warning
document-end: disable
document-start: disable
empty-lines:
max: 2
max-start: 0
max-end: 1
empty-values:
forbid-in-block-mappings: false
forbid-in-flow-mappings: true
hyphens:
max-spaces-after: 1
indentation:
spaces: 2
indent-sequences: consistent
check-multi-line-strings: false
key-duplicates: enable
key-ordering: disable
new-line-at-end-of-file: enable
new-lines:
type: unix
trailing-spaces: enable
truthy:
check-keys: false
level: warning
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -387,3 +387,7 @@ markdown-lint:
markdown-lint-fix:
@echo "Fixing markdown lint issues..."
markdownlint -c markdownlint.yaml "**/*.md" --ignore node_modules --ignore website/node_modules --fix

yaml-lint:
@echo "Linting YAML files..."
yamllint --config-file=.yamllint .
Loading
Loading