Skip to content
Open
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
78 changes: 78 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
name: Lint

on:

Check warning on line 4 in .github/workflows/lint.yml

View workflow job for this annotation

GitHub Actions / lint

4:1 [truthy] truthy value should be one of [false, true]
pull_request: {}
push:
branches:
- main

jobs:
lint:
name: lint
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read

steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install Python tooling
run: |
python -m pip install --upgrade pip
python -m pip install black pydocstyle yamllint

- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: "20"

- name: Install markdownlint-cli
run: npm install -g markdownlint-cli

- name: Determine changed files
id: changed-files
uses: tj-actions/changed-files@v44
with:
files_yaml: |
python:
- "**/*.py"
markdown:
- "**/*.md"
yaml:
- "**/*.yml"
- "**/*.yaml"

- name: Run Black (changed files)
if: steps.changed-files.outputs.python_any_changed == 'true'
run: |
black --config pyproject.toml --check ${{ steps.changed-files.outputs.python_all_changed_files }}

- name: Run pydocstyle (changed files)
if: steps.changed-files.outputs.python_any_changed == 'true'
run: |
pydocstyle --config=pyproject.toml ${{ steps.changed-files.outputs.python_all_changed_files }}

- name: Run custom import guard
if: steps.changed-files.outputs.python_any_changed == 'true'
run: |
python scripts/check_imports.py \
--config scripts/import_exceptions.json \
${{ steps.changed-files.outputs.python_all_changed_files }}

- name: Run markdownlint (changed files)
if: steps.changed-files.outputs.markdown_any_changed == 'true'
run: |
markdownlint -c .markdownlint.json ${{ steps.changed-files.outputs.markdown_all_changed_files }}

- name: Run yamllint (changed files)
if: steps.changed-files.outputs.yaml_any_changed == 'true'
run: |
yamllint -c .yamllint.yml ${{ steps.changed-files.outputs.yaml_all_changed_files }}
11 changes: 11 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"default": true,
"MD013": {
"line_length": 120,
"heading_line_length": 120,
"code_block_line_length": 160
},
"MD033": false,
"MD041": false
}

33 changes: 33 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
default_language_version:

Check warning on line 1 in .pre-commit-config.yaml

View workflow job for this annotation

GitHub Actions / lint

1:1 [document-start] missing document start "---"
python: python3.11

repos:
- repo: https://github.com/psf/black
rev: 24.4.2
hooks:
- id: black
name: black
args: ["--config", "pyproject.toml"]
- repo: https://github.com/PyCQA/pydocstyle
rev: 6.3.0
hooks:
- id: pydocstyle
name: pydocstyle
args: ["--config=pyproject.toml"]
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.39.0
hooks:
- id: markdownlint
args: ["-c", ".markdownlint.json"]
- repo: https://github.com/adrienverge/yamllint
rev: v1.35.1
hooks:
- id: yamllint
args: ["-c", ".yamllint.yml"]
- repo: local
hooks:
- id: import-guard
name: import-guard
entry: python scripts/check_imports.py
language: system
types: [python]
8 changes: 8 additions & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
extends: default
rules:
line-length:
max: 120
level: warning
truthy:
level: warning
34 changes: 34 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
PYTHON_SOURCES := $(shell find components pipelines third_party scripts -name "*.py")
MARKDOWN_SOURCES := $(shell find . -name "*.md" -not -path "./.git/*" -not -path "./.venv/*")
YAML_SOURCES := $(shell find . \( -name "*.yml" -o -name "*.yaml" \) -not -path "./.git/*" -not -path "./.venv/*")

BLACK ?= black
PYDOCSTYLE ?= pydocstyle
MARKDOWNLINT ?= markdownlint
YAMLLINT ?= yamllint
PYTHON ?= python3

.PHONY: format lint lint-black lint-docstrings lint-markdown lint-yaml lint-imports check-imports

format:
$(BLACK) --config pyproject.toml $(PYTHON_SOURCES)

lint: lint-black lint-docstrings lint-markdown lint-yaml lint-imports

lint-black:
$(BLACK) --config pyproject.toml --check $(PYTHON_SOURCES)

lint-docstrings:
$(PYDOCSTYLE) --config=pyproject.toml $(PYTHON_SOURCES)

lint-markdown:
$(MARKDOWNLINT) -c .markdownlint.json $(MARKDOWN_SOURCES)

lint-yaml:
$(YAMLLINT) -c .yamllint.yml $(YAML_SOURCES)

lint-imports:
$(PYTHON) scripts/check_imports.py components pipelines third_party scripts

check-imports: lint-imports

20 changes: 20 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[tool.black]
line-length = 120
target-version = ["py311"]
include = '\.pyi?$'
exclude = '''
/(
\.git
| \.venv
| build
| dist
| __pycache__
| node_modules
| .*/_generated/
)/
'''

[tool.pydocstyle]
convention = "google"
add_ignore = ["D100", "D104"]
match_dir = "(?!\\.|build|dist|\\.venv).*"
Loading